toes/docs/ENV.md
2026-02-01 23:27:22 -08:00

42 lines
893 B
Markdown

# Environment Variables
Store API keys and secrets outside your app code.
## Using env vars
Access them via `process.env`:
```tsx
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
```bash
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.