Skip to content

Consider dropping Oxygen.env and use process.env instead #1226

@jplhomer

Description

@jplhomer

In #55, we decided to introduce first-class Oxygen.env support for Hydrogen. This was designed around the intent that Oxygen would inject this in its Web runtime.

However, we've since pivoted away from that plan, and Oxygen is no longer going to do that. This means Hydrogen is responsible for injecting this variable on its own.

This is confusing for a number of reasons, primarily because it means Hydrogen builds a unique affordance for runtime environment variables that doesn't exist on any platform — literally.

Meanwhile, Vite now supports process.env in SSR runtimes (it previously did not).

I propose that we adopt process.env for runtime environment variables in Hydrogen.

This means populating a process.env in our platforms/worker.ts file. It also means updating all instances of Oxygen.env with process.env.

I think this better matches the behavior in other frameworks deployed to Workers runtimes as well.

Drawbacks

  • Does the presence of process trick any 3p libs into thinking we are running in Node, thus causing compatibility issues?
  • Is it going to be confusing that other process properties are not available?

Metadata

Metadata

Assignees

Labels

frameworkRelated to framework aspects of Hydrogen

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions