Dyrected
Deployment & OperationsInfrastructure

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:

  • .env or .env.local for Next.js
  • .env for Nuxt
  • .env for 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_URL
  • NUXT_PUBLIC_DYRECTED_URL
  • DYRECTED_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_KEY for server-side or shared runtime configuration
  • NEXT_PUBLIC_DYRECTED_API_KEY when a Next integration needs that key in browser-visible runtime config
  • NUXT_PUBLIC_DYRECTED_API_KEY when 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_ID
  • NEXT_PUBLIC_DYRECTED_SITE_ID
  • NUXT_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_URL
  • DYRECTED_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.

On this page

Dyrected| Cloud

Get your backend ready in minutes

Use a managed database, storage, APIs, and admin dashboard without setting up the infrastructure yourself.

Set Up My Backend