Skip to content
Dashboard

Environment Variables

Configure build-time and runtime values for a NexHost service without committing them to source.

Environment Variables#

Use the service configuration screen to supply values that vary by environment, such as database connection strings, API credentials, and feature flags. Keep these values out of source archives and repositories.

Scopes#

Each variable can be available during one or both parts of a deployment:

ScopeUse it when
BuildA build tool needs the value while generating the application output
RuntimeThe running process needs the value after it starts
BothThe value is required during the build and by the running service

Static-site values are incorporated into the built output. Change a build-time value and deploy again so a new artifact is produced. Runtime services receive their runtime configuration when they start; redeploy or restart the service after changing values that affect startup.

Set a value#

  1. Open the service settings in the dashboard.
  2. Add the key, value, and appropriate scope.
  3. Save the configuration.
  4. Start a deployment when the change needs a new build or runtime process.

Keep secrets server-side#

Do not use browser-exposed variables for credentials. Frontend frameworks may embed specially prefixed values into client-side bundles; check your framework’s documentation before putting any sensitive value in a build-time variable.

Runtime port#

Public Node services receive PORT from the runtime. Do not replace it with a hard-coded port; configure the application to listen on the provided value instead.