Secrets
Where the keys for outside services live, how backend functions use them, importing a .env file, and rotating a key.
On this page
A key for an outside service, such as a payment provider or a mapping service, is a secret. Secrets live on the Secrets tab. Anything you put in code can be read by anyone who opens your website; a secret cannot.
How they work
- A saved value is never shown again, not even to you. Saving the same name again replaces it. To check a value, look it up where you got it.
- Only backend functions can read a secret, and only the functions that declared it. Page code has no access.
- Name them the way the service does: capitals and underscores, such as
STRIPE_SECRET_KEY.
Adding secrets
| Way | When |
|---|---|
| A secret card in the builder | The builder asks for a key at the start of a job. Paste it and the next message resumes. |
| Add secret on the Secrets tab | Any time, by name and value. |
| Import .env | Upload a .env file or paste its contents. Each KEY=value line becomes a secret; existing names are replaced. Nothing is sent until you press Import. |
Rotating a key
Save the new value under the same name. Functions read the current value on each run, so the change takes effect immediately.
Publishable versus secret keys. Some providers give you two keys. A publishable key is designed to sit in a page and can go in the code. A secret key never can: it goes in Secrets and is used only inside a backend function.
Was this page helpful?
What went wrong? Pick any that apply.
Don't include passwords or personal details.
That didn't send. Try again in a moment.
Thanks. Your note goes to the team that writes these docs.