---
title: "Preview environments for every version, with while.sh"
url: https://while.sh/en/guides/preview-environments/
author: "Aloïs Oddon, co-founder of Nextmap"
updated: 2026-11-02
---

# See every new version before production, like a staging environment, from your AI agent

You want to see a version before it reaches production. Your AI agent opens a preview of every version, at its own address, with its own databases, and removes it after 24 hours. Your colleagues point out what's wrong, right on the page.

## Prerequisites

- An app deployed on while.
- Your AI agent, connected to while over MCP.

## Step 1: Ask for a preview

> You, to your agent: Show me the new page before you deploy it.

Your agent opens a preview and gives you its address, for example `https://mon-appli-essai.while.cloud`.

## Step 2: Look at it, then approve

You try the new version. If you're happy with it, your agent puts it into production. If not, it fixes the problem, and the preview follows.

## What your agent does

A preview is your app as it runs in production, with its own variables and its own databases, empty by default, at its own address. It removes itself, after 24 hours by default, and your production doesn't notice a thing.

## Try it with real data

> You, to your agent: Open a preview with a copy of the production database.

Your agent copies the production database into the preview, from its latest backup, if your permissions allow it. Allow a minute or more, depending on its size.

## Collect notes on the page

> You, to your agent: Add the feedback button to the preview.

Your agent adds it to the preview, never to production. Your colleagues point out what's wrong, right on the page, and your agent reads their notes to fix it.

```html
<script src="/__while/retours.js" defer></script>
```

## Show the preview to a customer

> You, to your agent: Open the preview to our customer, with a password.

Your agent makes the preview private. Then, on its page in while, you create a link that lasts 1, 7 or 30 days, with a password your agent will never see.

## Go back to the previous version

> You, to your agent: Go back to the previous version.

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

## Next steps

- [Show your app with a link and a password](/en/guides/share-app-with-password/)
- [Roll back to the previous version in a second](/en/guides/rollback/)
- [Deploy a Next.js app](/en/guides/deploy-nextjs/)

## Questions

### Does a preview touch my production data?

No. Its databases start empty, or from a copy of production if you ask for one, and its files are new.

### Are my production variables in it?

No. A preview has its own variables.

### Do I need a Git branch?

Not necessarily: your agent sends the version to try from your folder.
