Skip to main content
Use environment variables for app settings, API keys, and database connections. Locus resolves them when you deploy, so services can find each other without hardcoded addresses. Add variables in the dashboard or through the API. Redeploy after changes to make them available to your running app.

Set variables

Use PATCH to add or update values while keeping existing variables:
Update service variables
PUT on the same route replaces all variables for the service. Keep secrets server-side and out of committed .locusbuild files.

Service-to-service references

Locus injects sibling service URLs automatically. A service named api gives other services these variables: Names are uppercased, with non-alphanumeric characters replaced by underscores.

Template syntax

Use templates to connect a setting to a service or addon. For example, set DATABASE_URL to ${{db.DATABASE_URL}} to connect to a Postgres addon named db. Addon templates also expose HOST and PORT; Postgres adds USERNAME and DATABASE. Wait until the addon is available before deploying a service that references it. Only services with explicit addon references receive those connection variables.

Full-stack .locusbuild example

This connects an API to Postgres and Redis, and a frontend to the API:
.locusbuild

Variable scopes

When the same name exists in multiple scopes, service variables take priority over environment variables, which take priority over addon variables.

Get resolved variables

Preview values before deploying:
Preview resolved variables
Treat the response as sensitive; it can contain credentials. See the Build API reference for all variable operations.