Rayfin

rayfin env

Emit framework-specific .env.local files from rayfin/.env for Vite, Next.js, or plain frontend tooling.

rayfin env reads RAYFIN_PUBLIC_* values from rayfin/.env and writes the framework-specific .env.local file that the frontend reads.

npx rayfin env --framework vite

rayfin dev, rayfin up, and rayfin up switch can call the same emitter automatically.

Why projects regenerate .env.local

Frontend frameworks do not read rayfin/.env directly. They read their own conventions: Vite reads VITE_*, Next.js reads NEXT_PUBLIC_*, and plain tooling may read unprefixed keys. rayfin env performs that projection so source-controlled Rayfin configuration and local framework configuration stay in sync.

Scaffolded templates call the emitter before production builds:

package.json
{
  "scripts": {
    "prebuild": "rayfin env --framework vite",
    "dev": "rayfin dev",
    "dev:frontend": "vite",
    "build": "tsc -b && vite build",
    "build:fabric": "tsc -b && vite build"
  }
}

rayfin dev also regenerates .env.local after it resolves the backend and local ports, unless --no-emit-env is passed. This prevents stale frontend values from pointing at an old deployment.

Options

OptionDefaultDescription
--framework <framework>auto-detectTarget framework: vite, nextjs, or plain. Auto-detected from package.json and framework config when omitted.
--output <dir>project rootDirectory for .env.local, relative to the project root.
--showfalsePrint resolved public variables to stdout and exit without writing.

Auto-detection

The CLI detects Vite, Next.js, or plain output from project files. In multi-package projects, pass --output or set services.staticHosting.path so the file lands next to the frontend package.

Inspect without writing

npx rayfin env --show

Only variables whose source key starts with RAYFIN_PUBLIC_ are emitted. See Environment variables for the full mapping.

Manual regeneration

Run the command after editing rayfin/.env by hand or after switching branches that use a different frontend package path.

npx rayfin env --framework vite

For Next.js:

npx rayfin env --framework nextjs --output .
PromptRegenerate frontend environment variables
Run `npx rayfin env --framework vite --show` to inspect the public Rayfin values, then run `npx rayfin env --framework vite` to regenerate .env.local for my Vite frontend.
Something wrong on this page?Report an issueEdit this page

On this page