One Logo Pool Ball
wwwwwwwwwwwwwwwwwww

Environment

Variables

Loading .env files and process.env

One handles environment variables for you in a few ways.

First, it handles loading .env files during development and in production. In order to ease compatibility with ESM and CJS, One makes your loaded environment variables (from .env and from process.env) automatically be defined onto both import.meta.env and process.env.

Second, One ensures that all environment variables loaded are only available to the server-side functionality, unless they are prefixed with VITE_ (Vite convention), EXPO_PUBLIC_ (Expo convention), or ONE_PUBLIC_.

So, for example ONE_PUBLIC_DAYTIME=false one dev would set both process.env.ONE_PUBLIC_DAYTIME and import.meta.env.ONE_PUBLIC_DAYTIME to be the string “false” on both server and client.

ONE_PUBLIC_ is One’s default naming convention, while EXPO_PUBLIC_ remains fully supported. A ONE_PUBLIC_ variable is also exposed under the matching EXPO_PUBLIC_ name when that Expo variable is absent. One does not create ONE_PUBLIC_ variables from Expo variables, and an explicitly defined Expo variable keeps its own value.

But, SOME_RANDOM_VAR=2 would not be exposed to the client side, because it lacks the appropriate prefix.

Preset environment variables

One also sets some environment variables for you, available on both process.env and import.meta.env.

Server

Port priority (highest wins):

  1. ONE_FORCE_PORT
  2. --port CLI flag
  3. ONE_PORT
  4. Built-in defaults (8081 for dev, 3000 for serve)

Core Variables

Platform Detection

React Native

Available in native builds:

TypeScript Types

One provides TypeScript types for all preset environment variables. To enable them, add a triple-slash reference to your project:

/// <reference types="one/env" />

You can add this to any .d.ts file in your project (such as env.d.ts or vite-env.d.ts), or include it in a file that’s part of your TypeScript compilation.

This gives you autocomplete and type checking for import.meta.env.VITE_ENVIRONMENT, process.env.VITE_NATIVE, and all other One environment variables.

Edit this page on GitHub.