Environment Variables
Configure Dyrected URLs, API keys, database connections, and other secrets through environment variables.
Dyrected uses environment variables for URLs, API keys, database connections, JWT secrets, and provider credentials. Keep those values outside your config file so the same code can run safely across local, staging, and production environments.
If you install with npx dyrected init, the CLI writes a .env.example for you. The exact variables depend on your framework and whether you are self-hosting or connecting to Dyrected Cloud.
Start with an env file
In most projects, you define Dyrected variables in your framework's normal env file:
.envor.env.localfor Next.js.envfor Nuxt.envfor other server or build setups
The main rule is simple: framework-prefixed values are exposed to browser-side runtime config, while unprefixed values stay server-side.
Core categories
API base URL
The base URL tells SDK and framework helpers where Dyrected is running.
Common examples:
NEXT_PUBLIC_DYRECTED_URLNUXT_PUBLIC_DYRECTED_URLDYRECTED_URL
In Next.js, @dyrected/next reads NEXT_PUBLIC_DYRECTED_URL and falls back to DYRECTED_URL or http://localhost:3000.
In Nuxt, @dyrected/nuxt reads NUXT_PUBLIC_DYRECTED_URL and falls back to DYRECTED_URL.
API keys
Dyrected uses API keys for authenticated SDK and HTTP access.
Common examples:
DYRECTED_API_KEYfor server-side or shared runtime configurationNEXT_PUBLIC_DYRECTED_API_KEYwhen a Next integration needs that key in browser-visible runtime configNUXT_PUBLIC_DYRECTED_API_KEYwhen a Nuxt integration needs that key in public runtime config
Dyrected Cloud does not split keys into separate "public" and "private" key types. The framework-prefixed versions are the same API key, exposed through that framework's public runtime config when the integration needs it.
Site ID
Cloud or multi-site setups may also require a site identifier:
DYRECTED_SITE_IDNEXT_PUBLIC_DYRECTED_SITE_IDNUXT_PUBLIC_DYRECTED_SITE_ID
Use the variable shape your integration expects.
Database and provider secrets
Self-hosted projects also need infrastructure variables such as:
DATABASE_URLDYRECTED_JWT_SECRET- storage provider credentials such as S3, B2, or Cloudinary keys
- provider-specific secrets for email, revalidation, or admin SSO
The exact list depends on your database adapter, storage adapter, and auth setup.
Next.js example
# .env.local
DATABASE_URL=postgresql://user:pass@localhost:5432/mydb
DYRECTED_JWT_SECRET=change-me-32-characters-minimum
# Dyrected site URL
NEXT_PUBLIC_DYRECTED_URL=http://localhost:3000
# API key
DYRECTED_API_KEY=sk_live_...
# Optional framework-prefixed API key
NEXT_PUBLIC_DYRECTED_API_KEY=sk_live_...
# Optional site identifier
NEXT_PUBLIC_DYRECTED_SITE_ID=site_...DyrectedAdmin can read the standard Next.js variables automatically, so you usually do not need to pass them manually unless you want to override the defaults.
Nuxt example
# .env
DYRECTED_JWT_SECRET=change-me-32-characters-minimum
NUXT_PUBLIC_DYRECTED_URL=https://api.dyrected.cloud
NUXT_PUBLIC_DYRECTED_API_KEY=sk_live_...
NUXT_PUBLIC_DYRECTED_SITE_ID=site_...For self-hosted Nuxt projects, you also add your database and secret values in the same env file.
Practical rules
- Keep secrets out of
dyrected.config.ts. - Use framework-prefixed variables only when that integration needs the value in public runtime config.
- Prefer unprefixed server-side variables when browser exposure is not required.
- Use server-side variables for JWT signing, database access, and provider credentials.
- Update env values when you move between local and production environments instead of hardcoding environment-specific URLs in code.
Related pages
- Read Overview for the root config shape.
- Read Collections and Globals once your environment is in place.
- Go back to Installation if you want the CLI-generated setup path first.
Migrations
How Dyrected keeps your database in step with your schema — automatic schema sync, safe field renames, and pushing schema to Dyrected Cloud.
Logging and Observability
Configure Dyrected's root logger, request logging, redaction, transports, tracing, metrics, and sampling from `dyrected.config.ts`.