Skip to content

Environment variables

Environment variables hold your app's configuration: an API URL, a feature flag, a database password. They're stored per environment, and each one is available at build, at runtime, or both.

BuildRuntime
Read byThe install and build commandsYour app's code at the edge
ForFrontends: Vite's import.meta.env.VITE_*, Rasengan.js's RASENGAN_*Hono, Futon, server-rendered Rasengan.js
AppliesFrom the next buildFrom the next deployment
SecretsNeverYes

See Build variables and Reading variables. Hiraiship also sets a few system variables of its own, like the environment's name and URL.

Adding variables

In the dashboard, open the project's Environment variables and choose Add variable:

  1. Choose Secret or Config. See Secrets.
  2. Choose where they're available: Build, Runtime, or both. The dashboard picks from your project's framework (Build for Vite and static sites, Runtime for Hono and Futon, both for Rasengan.js); a secret is Runtime only.
  3. Enter one or more key and value pairs. Pasting the content of a .env file fills them all at once.
  4. Each variable starts with the type and availability chosen above, and can change them on its own: a .env file's secrets, config values and build variables go in one save.
  5. Choose the environments they apply to.

The project's page lists each key once, with the environments that have it, and whether the value is the same in each.

Keys and values

  • Keys use uppercase letters, digits and underscores, and don't start with a digit: DATABASE_URL, STRIPE_SECRET_KEY.
  • Values are up to 4,096 characters.
  • A key exists once per environment. Adding one that already exists in an environment is refused, and the dashboard names the conflicts.
  • Don't use ASSETS as a key: it's the name your static files are served through.
  • HIRAISHIP and keys starting with HIRAISHIP_ are refused: they're Hiraiship's system variables. So are PATH, HOME, HTTP_PROXY, HTTPS_PROXY and NO_PROXY, which the build machine needs as they are.

Different values per environment

A key can have a different value in each environment: API_URL pointing at a staging API in staging and the real one in production. Edit the key and set each environment's value.

When changes apply

A change applies from the next deployment of each environment it touches; the deployment running now keeps the values it was published with. A build variable is baked into the files by the build, so it needs a new build: rolling back to an older deployment brings back that deployment's values. After a change, the dashboard offers to redeploy the affected environments.

  • Deployed from GitHub: Redeploy from the dashboard.
  • Deployed with the CLI: run hiraiship deploy again.

See Redeploy.

Who can change them

Owners, admins and developers can add, edit and remove variables. Viewers see the keys, and the values of variables that aren't secret.