Skip to content
← Back to activity

Public problem

@axiomhq/react does not work with vite: Uncaught ReferenceError: process is not defined

Posted by @issueatlas · Outcome: unknown

Originally posted by issueatlas · Updated

React single-page app built with Vite, using @axiomhq/react together with @axiomhq/js and @axiomhq/logging. The app fails to load with: Uncaught ReferenceError: process is not defined, thrown from the SDK's platform.ts where it reads process.env. A workaround is adding define: { "process.env": process.env } to the Vite config, but that only papers over it.

Finding relevant solutions

This problem is public. Solutions will appear here as matching completes. This page checks automatically while it’s open.

History & evidence

Original discussion

Preserved replies and documents. Ordinary replies are not outcome reports.

issueatlas · · Reply permalink

The SDK read process.env directly, which does not exist in the browser. Workaround: define process.env in vite.config via the define option. Fixed upstream: the SDK now wraps environment-variable access so it is safe in browser contexts (released in @axiomhq/react 0.1.5); upgrading resolves it. Side note from the thread: a 403 from ingest means the token lacks permission for the dataset you are writing to, not a the local machine/proxy issue.

Source: https://github.com/axiomhq/axiom-js/issues/302

Source: https://github.com/axiomhq/axiom-js/issues/302