Skip to content
Dashboard

Variables

Copy page
View as Markdown

A variable is a name and a value your service reads from its environment, such as an API key. Each service has its own variables. Grayspar encrypts each value when it saves the value, and neither the CLI nor the dashboard shows a saved value again.

To set a variable, run grayspar env set with the variable written as KEY=VALUE. Grayspar saves the value and redeploys the service, and the command waits until the service is live again:

Terminal window
grayspar env set STRIPE_KEY=sk_test_123
Terminal window
✓ Set variable STRIPE_KEY on app
✓ Redeployed <project-name>

When a project has several services, name the service with --service:

Terminal window
grayspar env set STRIPE_KEY=sk_test_123 --service api

To list the variables of a project, run grayspar env. The list shows names and dates and never shows values:

Terminal window
SERVICE NAME UPDATED
app STRIPE_KEY 2026-11-07

To remove a variable, run grayspar env remove with its name. The service redeploys without it:

Terminal window
grayspar env remove STRIPE_KEY

A deploy reads .env, .env.production and .env.local, in that order, so a value in a later file wins. In a monorepo, the CLI reads the project’s root folder and then the service’s own folder, and a value beside the service wins. The files themselves are never uploaded. Only the variables you agree to send leave your computer.

When a deploy finds variables that are new to the project, the CLI lists their names and asks before sending them:

Terminal window
Found 2 new variables
SERVICE VARIABLE FILE
app STRIPE_KEY .env
app SESSION_SECRET .env
Send 2 variables to <project-name>? (Y/n)

A value that points at localhost or 127.0.0.1 stays on your computer, because it only works there. The CLI names each one, with the command that sets its production value.

When a value in a file differs from the saved value, the CLI asks which one wins. To answer ahead of time, pass --env-conflict saved or --env-conflict file.

To read no file, deploy with --no-env. To read one more file, name it with --env-file:

Terminal window
grayspar deploy --no-env
grayspar deploy --env-file .env.staging

A service built with Railpack can read every variable during its build, so changing any variable builds the service again. A service with a Dockerfile reads only the variables its Dockerfile declares as build arguments or secrets, and builds again only when one of those changes.

A framework can copy some variables into the code it sends to the browser. Next.js does this with every variable whose name starts with NEXT_PUBLIC_, so keep secrets out of those names.

Grayspar sets GRAYSPAR_VOLUME_PATH itself and refuses that name as a variable. Grayspar also refuses names that start with RAILPACK_. To choose a language version, use your project’s own files, such as engines in package.json or a .python-version file.