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.
| Build | Runtime | |
|---|---|---|
| Read by | The install and build commands | Your app's code at the edge |
| For | Frontends: Vite's import.meta.env.VITE_*, Rasengan.js's RASENGAN_* | Hono, Futon, server-rendered Rasengan.js |
| Applies | From the next build | From the next deployment |
| Secrets | Never | Yes |
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:
- Choose Secret or Config. See Secrets.
- 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.
- Enter one or more key and value pairs. Pasting the content of a
.envfile fills them all at once. - Each variable starts with the type and availability chosen above, and can change them on its own: a
.envfile's secrets, config values and build variables go in one save. - 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
ASSETSas a key: it's the name your static files are served through. HIRAISHIPand keys starting withHIRAISHIP_are refused: they're Hiraiship's system variables. So arePATH,HOME,HTTP_PROXY,HTTPS_PROXYandNO_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 deployagain.
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.