Env
rayfin env emits a framework-specific .env.local from rayfin/.env — flags, auto-detection, and why scaffolded projects run it in predev and prebuild.
rayfin env reads the RAYFIN_PUBLIC_* subset of rayfin/.env and writes it out as a
framework-specific .env.local your frontend build actually reads. It's the same mechanism
rayfin up uses to keep .env.local in sync — exposed as its own command so you can
regenerate it without a full deploy.
npx rayfin env --framework viteWhy it runs in predev / prebuild
Scaffolded projects wire this into package.json:
{
"scripts": {
"predev": "rayfin env --framework vite",
"prebuild": "rayfin env --framework vite",
"dev": "rayfin up --exclude-services staticHosting && vite",
"build": "tsc -b && vite build"
}
}npm runs pre* scripts automatically before the matching script. Regenerating
.env.local on every dev/build invocation means the frontend always builds against the
current deployment's API URL, publishable key, and other RAYFIN_PUBLIC_* values — you
never hand-copy them, and a stale .env.local left over from a previous deployment can't
silently point the frontend at a backend that no longer exists.
Flags
| Flag | Description |
|---|---|
--framework <framework> | Target framework: vite, nextjs, or plain. Auto-detected from vite.config.*, next.config.*, or package.json dependencies when omitted. |
--output <dir> | Directory to write .env.local into, relative to the project root. Defaults to services.staticHosting.path from rayfin.yml when set (multi-package projects), otherwise the project root. |
--show | Print resolved public variables to stdout and exit, without writing a file. |
If no framework can be detected and --framework isn't passed, the command errors with a
hint to pass it explicitly.
Inspect without writing
npx rayfin env --showPrints each resolved RAYFIN_PUBLIC_* variable, mapped to the target framework's naming,
without touching disk.
Framework mapping
rayfin env maps each RAYFIN_PUBLIC_* variable in rayfin/.env to a framework-specific
name in .env.local — for example RAYFIN_PUBLIC_API_URL becomes VITE_RAYFIN_API_URL
for Vite, NEXT_PUBLIC_RAYFIN_API_URL for Next.js, or API_URL for plain. See
Environment variables
for the complete variable-by-variable table.
Manual regeneration
Run this any time you want to refresh .env.local without a full deploy — for example
after manually editing rayfin/.env:
npx rayfin env --framework viteMy Rayfin project's rayfin/.env has values from a previous deploy, but .env.local wasn't
regenerated for my Next.js app. Run `npx rayfin env --framework nextjs` and show me the
resulting file.Secret
rayfin secret set and secret list manage secrets on a deployed Rayfin item — masked interactive input, names/timestamps only, no bulk .env import.
rayfin functions
rayfin functions init scaffolds a serverless TypeScript Functions project under rayfin/functions/ that shares entity types with your Rayfin data model.