Skip to content

Your app’s environment variables and secrets, out of the code (2026)

A key in the code or in a .env file ends up leaking. On while, your AI sets your app’s variables over MCP, and your secrets live in an encrypted vault: your app receives them, and your AI cannot read them back.

By Aloïs Oddon, co-founder of Nextmap. Facts checked on November 19, 2026.

View as Markdown

Your app’s environment variables and secrets, out of the code: variables and secrets with Claude Code, Cursor or Codex, on while, hosted in France

The short version. Your AI sets your app’s variables over MCP. You can enter your secrets yourself in while: your AI never sees them. What matters, like deleting a database, waits for a person’s approval.

Prerequisites

  • An app deployed on while, or ready to be.
  • Your AI, connected to while over MCP.

Step 1: Ask your AI for a variable

You, to your AI: Add the variable LOG_LEVEL=info.

Your AI sets it over MCP, and it reaches your app at the next deployment.

Step 2: Keep your secrets to yourself

For a key or a password, paste the value yourself into your app’s settings in while, under “Variables and secrets”: your app receives it, and your AI never sees it. And when your AI sets a secret over MCP, it can no longer read it back.

What your AI does

Secrets live in an encrypted vault, never in while.yaml or in your code, as the Twelve-Factor App method recommends1. A variable that holds no secret can be written in while.yaml. They reach your app at every deployment, as environment variables, or as files in /run/secrets/ for the most sensitive ones:

server.js
import { readFile } from 'node:fs/promises';

const cle = (await readFile('/run/secrets/CLE_API', 'utf8')).trim();
Variables and secrets with while: credentials kept out of the AI's reach, every call logged in the history, a person's approval for what matters and a daily backup, in France
Around every app, while keeps the credentials, the history, the approvals and the backups.

Use a private npm registry

You, to your AI: Our private npm registry requires a token.

Your AI declares a build secret, NPM_TOKEN, and a .npmrc that reads it. You enter its value: it is used to install the packages, never by your app, and it doesn’t stay in the image.

while.yaml
services:
  - name: web
    port: 3000
    build:
      secrets: [NPM_TOKEN]

Use a different value in preview

You, to your AI: Set LOG_LEVEL=debug in preview.

Each environment has its own variables: the preview says more in its logs, and production stays quiet.

The addresses your app receives automatically

You, to your AI: Which variables does our app receive?

Your AI lists them for you: DATABASE_URL for the database, REDIS_URL for the cache, the S3_ variables for storage, SENTRY_DSN for errors, and one address per connected API.

Go back to the previous version

You, to your AI: Go back to the previous version.

In the 30 minutes after a production release, the previous version comes back in a second. After that, it takes a few seconds. Once the previous version is back, your AI reads what broke in while’s logs, fixes it and deploys again.

In the docs: Variables and secrets, Previews, Versions and rollback and Errors (Sentry).

Next steps

Sources

  1. The Twelve-Factor App, config, accessed November 2, 2026

Questions

Can I put my secrets in while.yaml?

Not secrets: while.yaml describes the app, and secrets live in while’s vault. A variable that holds no secret, yes.

What about the .env file in my repository?

It stays out of the build and the image: its values are set in while.

Do I need to redeploy after a change?

Yes: a changed variable reaches your app at the next deployment.

Where do my app and its data run?

In France, at Nextmap. The database is backed up every day, with a way back over 14 days, once a person approves.

What happens if a version breaks something?

In the 30 minutes after a production release, the previous version comes back in a second, then in a few seconds.

Give your AI the message, and it takes care of the rest

Give this to your AI

Read while.sh/agents and help me get started with while.

Copy the message

In 3 minutes, with no sign-up, the tool has its own address. To keep it, create your account.

For a company project, write to the while team: hello@while.sh