---
title: "Env var templates"
description: "Write {URL}, {GENERATED_HEX_64}, {OWNER_EMAIL} or {ENV:NAME} in .env.example, and ExtraOrbital fills those variables when it provisions resources and when it deploys, previews and production alike."
canonical_url: "https://extraorbital.dev/docs/env-templates"
last_updated: "2026-11-30"
---

# Env var templates

> Write {URL}, {GENERATED_HEX_64}, {OWNER_EMAIL} or {ENV:NAME} in .env.example, and ExtraOrbital fills those variables when it provisions resources and when it deploys, previews and production alike.

<Callout title="In brief">

- A value in `.env.example` that holds a token in braces is a template: `NEXT_PUBLIC_APP_URL={URL}`.
- ExtraOrbital fills it in production at every deploy, on previews, and locally in `.env.local` with `npx extraorbital provision`.
- Generated values (`{GENERATED_HEX_64}`) are made once per project and environment, stored encrypted, and never made again.
- A value from a resource, from ExtraOrbital, or set by you always wins over a template.
- A plain placeholder (`your-key-here`) is not a template: it is still reported as missing.

</Callout>

An app often needs variables no service provides: its own URL, a random key it refuses to boot without, the admin's email, a sender address built from the sending domain. Write how to build them in `.env.example`, and ExtraOrbital fills them wherever the app runs.

```sh title=".env.example"
NEXT_PUBLIC_APP_URL={URL}
WEBHOOK_URL=https://{DOMAIN}/api/webhooks/ses
SUPPRESSION_HASH_KEY={GENERATED_HEX_64}
ADMIN_EMAILS={OWNER_EMAIL}
EMAIL_FROM="Acme <hello@{ENV:SES_FROM_DOMAIN}>"
STRIPE_SECRET_KEY=your-key-here
```

The first five are templates. `STRIPE_SECRET_KEY` is not: production lists it as missing, as before.

## Tokens

| Token | Value |
| --- | --- |
| `{DOMAIN}` | The host the app answers at in that environment. Production: its primary domain once live, else `<project>.extraorbital-apps.com`. A preview: its own host. Locally: `localhost:3000`. |
| `{URL}` | `https://{DOMAIN}`. Locally: `http://localhost:3000`. |
| `{PROJECT}` | The project's id. |
| `{ENVIRONMENT}` | `production` or `preview`. Locally: `development`. |
| `{OWNER_EMAIL}` | The email of the account that deploys (on a preview, that adds its resources; locally, that is signed in). |
| `{ENV:NAME}` | The value of another variable of the same environment, once resources are set: `{ENV:SES_FROM_DOMAIN}`, `{ENV:MONGODB_URI}`, or another template's. |
| `{GENERATED_HEX_<N>}` | N random characters, `0-9a-f`. |
| `{GENERATED_BASE64_<N>}` | N random characters of base64 (`A-Za-z0-9+/`, no padding). |
| `{GENERATED_BASE64URL_<N>}` | N random characters of base64url (`A-Za-z0-9-_`). |
| `{GENERATED_ALNUM_<N>}` | N random characters, `A-Za-z0-9`. |
| `{GENERATED_UUID}` | A random UUID v4. |

N is between 16 and 256. Random values come from a cryptographic generator. A value can mix text and several tokens: `https://{DOMAIN}/api/webhooks/ses`, `{PROJECT}-{GENERATED_HEX_16}`.

Anything else in braces stays as written. `{HOSTNAME}` is no token, so it is kept as is and the CLI warns about it. `${NAME}` (dotenv-expand) and JSON such as `{"a":1}` are never read as tokens.

## Where they are filled

| Where | When | `{DOMAIN}` |
| --- | --- | --- |
| Production | Every deploy, from the CLI (`npx extraorbital deploy`) or the MCP server (`deploy`). | The primary domain once live, else `<project>.extraorbital-apps.com` |
| A preview | When it gets resources (creating it, `env_add`, `add_feature`), and on `restart_preview`. | The preview's own host |
| Locally | `npx extraorbital provision`, after the resources are written. Values go into the `.env.local` block of generated secrets. | `localhost:3000` |

The CLI reads `.env.example` in the folder and sends only the templated values with the deployment, as written. Your `.env` files never leave the folder. A preview's deploy reads `.env.example` on the preview.

Templates that do not generate anything are filled again at every deploy, so `{URL}` follows your primary domain once it goes live.

## What wins

A template only fills a variable that nothing else sets:

1. **A resource's variables.** `MONGODB_URI` comes from the project's `mongo` resource, whatever `.env.example` says.
2. **ExtraOrbital's own.** `BETTER_AUTH_SECRET`, `PREVIEW_URL` and the log variables are never set from a template.
3. **A value you set.** On a preview, a variable you set with `env_set`, which production also gets. A variable already on production that no template set, such as `SES_FROM_DOMAIN` set by [emails](/docs/emails). Locally, any value in `.env` or `.env.local` that is not a placeholder.
4. **The template.**

## Generated values

A `{GENERATED_…}` value is made the first time a template asks for it, then kept:

- **Once per project and environment.** Production has its values, and every preview of the project shares another set. A preview never gets production's.
- **Stored encrypted.** They are kept with the project, sealed with AES-256-GCM like other stored credentials, and deploys use them again. They never appear in a tool result, a CLI report or a log: reports give the variable names only.
- **Never regenerated.** A new `SUPPRESSION_HASH_KEY` would orphan every hash made with the old one. A token is kept by its variable and its place in the value. Changing `{GENERATED_HEX_64}` to `{GENERATED_HEX_32}` makes a new value.

Locally, the generated value is written into `.env.local` and is kept there. `provision` never fills a variable that already has a value.

## When a template waits

`{ENV:NAME}` needs `NAME` to have a value. If it has none, the variable is left unset and reported as waiting. It is filled at a later deploy (or `provision`) once `NAME` exists:

```text
✓ Filled 4 variables from .env.example templates — NEXT_PUBLIC_APP_URL, WEBHOOK_URL, SUPPRESSION_HASH_KEY, ADMIN_EMAILS
! EMAIL_FROM waits for SES_FROM_DOMAIN · filled by a later deploy once it is set
```

`{DOMAIN}` and `{OWNER_EMAIL}` wait the same way when they are not known yet. `{OWNER_EMAIL}` waits for a machine that is not linked to an account, and locally with `provision --local`.

`npx extraorbital deploy --check` shows which templates the next deploy would fill and which would wait, before anything is deployed. With `--json`, the deploy's answer has a `templates` object: `filled`, `pending` (each with `waitingFor`), `overridden` and `warnings`.

## Example: an app that needs 55 variables

An open-source app whose `.env.example` lists every variable can deploy on its first try once the variables no service provides are templates:

```sh title=".env.example"
# Provided by resources: npx extraorbital add mongo ses
MONGODB_URI=
SES_FROM_DOMAIN=

# Filled by ExtraOrbital
NEXT_PUBLIC_APP_URL={URL}
SUPPRESSION_HASH_KEY={GENERATED_HEX_64}
UNSUBSCRIBE_SECRET={GENERATED_BASE64URL_43}
ADMIN_EMAILS={OWNER_EMAIL}
EMAIL_FROM="Mailcheap <hello@{ENV:SES_FROM_DOMAIN}>"

# Yours to set
STRIPE_SECRET_KEY=your-key-here
```

The same file still documents every variable for someone who runs the app elsewhere.

---

More for agents: [Sitemap](https://extraorbital.dev/sitemap.md) · [llms.txt](https://extraorbital.dev/llms.txt) · [agents.md](https://extraorbital.dev/agents.md)
