Environment
Environment
MANIC_PUBLIC_ prefix, getEnv, getPublicEnv, and server-side env access.
Environment API
Runtime helpers live in manicjs/env. They complement build-time injection documented under Environment variables.
Functions
getEnv
Single key — public prefix enforced in browser
getPublicEnv
All MANIC_PUBLIC_* keys as an object
import { getEnv, getPublicEnv } from 'manicjs/env';Server-side access
On the server, prefer process.env directly for secrets:
const databaseUrl = process.env.DATABASE_URL;Environment files
Common layout:
| File | Scope |
|---|---|
.env | Defaults |
.env.local | Machine-specific (gitignored) |
.env.development / .env.production | Mode overrides |
Best practices
Only MANIC_PUBLIC_* belongs in browser bundles. Never expose database credentials or API tokens client-side.