893 B
893 B
Environment Variables
Store API keys and secrets outside your app code.
Using env vars
Access them via process.env:
const apiKey = process.env.OPENAI_API_KEY
if (!apiKey) throw new Error('Missing OPENAI_API_KEY')
Env vars are injected when your app starts. Changing them restarts the app automatically.
Managing env vars
CLI
toes env my-app # list env vars
toes env my-app set KEY value # set a var
toes env my-app set KEY=value # also works
toes env my-app rm KEY # remove a var
Dashboard
The .env tool in the tab bar lets you view and edit vars for the selected app. Values are masked until you click Reveal.
Format
Standard .env syntax:
OPENAI_API_KEY=sk-...
DATABASE_URL=postgres://localhost/mydb
DEBUG=true
Keys are uppercased automatically. Quotes around values are stripped.