Deploying

Environment Variables

Configure your services with environment variables

Environment variables let you pass configuration to your services without hardcoding values. They are available during both the build step and the runtime step, so your app can use them at compile time (e.g., NEXT_PUBLIC_* in Next.js) and at runtime.

How the agent sets variables

Your agent passes environment variables as key-value pairs in the env_vars parameter when calling create_service or update_service.

During service creation:

Tool Call
(
  : ,
  : ,
  : {
    "DATABASE_URL": "postgres://...",
    "API_KEY": "sk-...",
    "NODE_ENV": "production"
  }
)

Updating variables on an existing service:

Tool Call
(
  : ,
  : {
    "DATABASE_URL": "postgres://new-host/...",
    "NEW_VAR": "value"
  }
)

When updating, the provided variables are merged with existing ones. The update triggers a redeployment so the new values take effect.

Available in build and run

Environment variables are injected into both stages of the deployment:

StageHow they're used
BuildAvailable during npm run build, go build, etc. Use them for compile-time configuration like public API URLs or feature flags.
RunAvailable to your running application process. Use them for secrets, database connections, and runtime config.

This means a variable like DATABASE_URL is accessible whether your ORM runs a migration during build or connects at runtime.

Framework prefixes

Some frontend frameworks only expose environment variables to client-side code if they use a specific prefix. Variables without the prefix are available server-side but won't be bundled into the browser build.

FrameworkRequired prefixExample
Next.jsNEXT_PUBLIC_NEXT_PUBLIC_API_URL
Vite (React, Vue, Svelte, etc.)VITE_VITE_API_URL
Create React AppREACT_APP_REACT_APP_API_URL
NuxtNUXT_PUBLIC_NUXT_PUBLIC_API_URL

Variables like DATABASE_URL or API_KEY that should stay server-side don't need a prefix — and shouldn't have one, to avoid leaking secrets into the client bundle.

Snapshots

Environment variables are snapshotted at deployment time. If you update variables via update_service, a new deployment is triggered automatically and the updated values take effect in the new build and runtime.

Common use cases

  • Database URLs — connection strings for your databases
  • API keys — third-party service credentials
  • Build-time config — public URLs, feature flags, NODE_ENV
  • Runtime config — port numbers, log levels, secrets

Security

  • Variables are stored encrypted at rest
  • Never logged or exposed in build output
  • Only accessible to the build and runtime environments of your service

On this page