---
title: "Deploy a demo or staging app"
description: "Run a public demo or a staging copy of your app in production mode while every provider stays in its test mode, with BACKEND_ENVIRONMENT set to sandbox, a Convex project of its own, Polar's sandbox and Resend's test addresses."
canonical_url: "https://nuxt-backend.dev/docs/ship/deploy/staging"
---
# Deploy a demo or staging app

> Run a public demo or a staging copy of your app in production mode while every provider stays in its test mode, with BACKEND_ENVIRONMENT set to sandbox, a Convex project of its own, Polar's sandbox and Resend's test addresses.

Version: nuxt-backend 0.6.x · Tab: Ship · Kind: how-to · Status: stable

Every page: [llms.txt](https://nuxt-backend.dev/llms.txt) · Skill for coding agents: [nuxt-backend](https://nuxt-backend.dev/.well-known/skills/nuxt-backend/SKILL.md)

Commands use npm; use your project's package manager.

A demo or a staging app runs the same build as production, on the providers' test modes. Set `BACKEND_ENVIRONMENT=sandbox` on its deployment: visitors sign in with test addresses and pay with a test card, and the package charges and mails nobody for real. Use it for a public demo of your product, or to try a release on a real host before it reaches production.

`sandbox` keeps production's posture and only swaps the providers:

<table>
<thead>
  <tr>
    <th>
      
    </th>
    
    <th>
      <code>
        sandbox
      </code>
    </th>
    
    <th>
      <code>
        production
      </code>
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      Email
    </td>
    
    <td>
      Test mode: only Resend's test addresses receive mail
    </td>
    
    <td>
      Live
    </td>
  </tr>
  
  <tr>
    <td>
      Billing
    </td>
    
    <td>
      Polar's sandbox, with the test card
    </td>
    
    <td>
      Live
    </td>
  </tr>
  
  <tr>
    <td>
      Local origins trusted
    </td>
    
    <td>
      No
    </td>
    
    <td>
      No
    </td>
  </tr>
  
  <tr>
    <td>
      Sign-in codes in the logs
    </td>
    
    <td>
      No
    </td>
    
    <td>
      No
    </td>
  </tr>
  
  <tr>
    <td>
      Bot checks and rate limits
    </td>
    
    <td>
      As in production
    </td>
    
    <td>
      On
    </td>
  </tr>
  
  <tr>
    <td>
      Monitoring's environment name
    </td>
    
    <td>
      <code>
        sandbox
      </code>
      
      , so its errors stay apart from production's
    </td>
    
    <td>
      <code>
        production
      </code>
    </td>
  </tr>
</tbody>
</table>

A demo cannot prove what only production holds: your Polar organization's live settings, your sending domain's reputation and production's webhook secrets. `doctor --prod` checks those against production itself ([Prepare for launch](https://nuxt-backend.dev/docs/ship/checklist)).

## Before you start

- A production deployment of your own app already works as [Deploy to production](https://nuxt-backend.dev/docs/ship/deploy) describes. The demo takes the same build command.
- A Polar sandbox organization with an access token ([Polar](https://nuxt-backend.dev/docs/services/polar#create-the-account)).
- A Resend team of its own for the demo, with an API key. A Resend webhook receives the events of every email its team sends, so a demo that shares production's team would also receive production's delivery events ([Resend](https://nuxt-backend.dev/docs/services/resend#create-the-account)).

`npx nuxt-backend deploy --sandbox`, run with the demo's production deploy key in your shell, takes every step below in one command, and later runs of `deploy` keep `sandbox` ([Deploy in one command](https://nuxt-backend.dev/docs/ship/deploy/one-command#deploy-a-demo-or-staging-app)). By hand, they are:

<steps level="3">

### Give the demo a Convex project of its own

Create a second project in the Convex dashboard, and generate a production deploy key for its production deployment. A project of its own keeps the demo's accounts, data and env apart from your real production. On your host, create a second project from the same repository, with that key as `CONVEX_DEPLOY_KEY` and the [build command](https://nuxt-backend.dev/docs/ship/deploy#one-command-on-any-host) production uses.

### Set the environment first

With the demo's deploy key in your shell, set its own values. Set `BACKEND_ENVIRONMENT` before you push the rest: `env push --prod` sets `production` only where the deployment has no value yet.

```bash
printf %s sandbox | npx convex env set --prod BACKEND_ENVIRONMENT
openssl rand -base64 32 | npx convex env set --prod AUTH_SECRET
printf %s https://demo.example.com | npx convex env set --prod SITE_URL
npx convex env set --prod BILLING_ACCESS_TOKEN   # asks for the sandbox token
npx convex env set --prod EMAIL_API_KEY          # asks for the Resend key
npx convex env set --prod EMAIL_DEV_INBOX 1      # visitors read their codes off the page
npx nuxt-backend env push --prod
```

### Sync the catalog to the sandbox

```bash
npx nuxt-backend billing sync --env sandbox
```

It creates your catalog in the Polar sandbox organization the token belongs to, registers the webhook at the demo's `/billing/events` and stores its secret there. The sandbox ids sit beside production's in `backend/billing.generated.ts`, so one repository serves both.

### Point the email webhook at the demo

In Resend's dashboard, add a webhook for the email events at `https://<demo-slug>.convex.site/email/events`. Set its signing secret on the demo as `EMAIL_WEBHOOK_SECRET`. Delivery events from the test addresses then reach the demo, as real ones reach production. [`npx nuxt-backend email sync --prod`](https://nuxt-backend.dev/docs/reference/cli#email-sync) takes this step for you: it points a webhook at the demo, stores its secret as `EMAIL_WEBHOOK_SECRET`, and creates the demo's email topics too.

### Deploy and check

Deploy the demo's host project, then run the launch gate against it:

```bash
npx nuxt-backend doctor --prod
```

`doctor --prod` fails a deployment left at a default, and only warns on `sandbox`, which you chose. It probes the demo's live site the same way it probes production's.

</steps>

## What visitors do in a demo

- **Sign in** with a test address, such as `delivered+ada@resend.dev`. Anyone can create an account this way, so keep the rate limits and the bot check on. Mail to any other address is refused with a message that says the app is in test mode. The [dev inbox](https://nuxt-backend.dev/docs/develop/dev-inbox) reads the test addresses' mail back through Resend, so your sign-in page can show the code under the form.
- **Pay** with Polar's test card, `4242 4242 4242 4242`, any future expiry date and any CVC. Plans, credits and gifts behave as they will in production.
- **Use AI** at its real cost, through the Convex AI Gateway or `AI_GATEWAY_API_KEY`. Credits come from the sandbox, but the gateway bills you for real calls. Set a spending limit on the gateway before you open a demo to the public ([AI gateway](https://nuxt-backend.dev/docs/services/ai-gateway#go-to-production)), and a daily `spendLimit` in `setupAi`, without which a demo makes no model call.

## What a demo refuses

Anyone can sign up to a public demo. So a deployment with `BACKEND_ENVIRONMENT=sandbox` refuses the admin actions that would reach a provider for real, even for its administrator:

- **A broadcast** of an announcement, refused as `unavailable`, reason `test_mode`, as everywhere outside `production` ([Announce product news](https://nuxt-backend.dev/docs/build/growth/engage/announcements)).
- **A webhook replay**, refused as `not_ready`, reason `sandbox` ([Replay a webhook delivery](https://nuxt-backend.dev/docs/ship/operate/replay#limits)).
- **Lifting an email suppression**, refused as `not_ready`, reason `sandbox` ([Handle suppressed addresses](https://nuxt-backend.dev/docs/build/email/delivery/suppressions#limits)).

Its model calls are real, so a demo also refuses AI until you cap it. Without `setupAi({ spendLimit: { usdPerDay } })`, every metered call, stream, job and chat reply is refused as `not_ready`, reason `no_budget`, and `doctor --prod` reports `ai-spend-limit`. With one, the app turns `pause_ai` on once a UTC day costs that much, records `ai.spend_limit_reached`, raises the `ai_spend_limit` alert, and lifts the pause when the next day begins ([Cap the daily spend](https://nuxt-backend.dev/docs/build/ai/models#cap-the-daily-spend)).

A demo's [dev inbox](https://nuxt-backend.dev/docs/develop/dev-inbox) is public, so anyone can read a test account's sign-in codes. Its administrators therefore sign in with passkeys only. On `sandbox`, the `admin` tier, the admin console and Better Auth's `/admin/*` routes refuse an administrator whose account is not [passkey-only](https://nuxt-backend.dev/docs/build/auth/sign-in#passkey-only-accounts), or whose session a code opened, as `forbidden`, reason `passkey_only_admin`; so do billing's admin functions, `listAllActivity` and the health detail. The inbox also shows no mail for an administrator or a passkey-only account. On the demo, sign in, save a passkey and turn on passkey-only sign-in under Security (it signs the account's other sessions out), sign in again with the passkey, then make that account the administrator.

The replay and the lift run on `production` and `development` alone, not only off `sandbox`. A `preview` deployment refuses them too, and so does one whose `BACKEND_ENVIRONMENT` is unset or mistyped, as `not_ready`, reason `environment`: a deployment that does not say what it is never reaches a provider for an administrator.

## The public demo's own limits

The [demo on this site](https://nuxt-backend.dev/docs/start/playground) is Panels on a `sandbox` deployment. Beside the package's rules above, the template holds itself to a public demo there (`backend/demo.ts`, `backend/auth.ts`, `backend/storage.ts`, `backend/ai.ts`, `backend/crons.ts`). Take the same limits for a demo of your own:

- **Generated addresses only.** `canSignIn`, `canInvite` and a user-update hook admit `delivered+<label>@resend.dev` with a random label of 16 or more characters, and nothing else.
- **Canned ideas.** A strip starts from one of four canned ideas. Once the administrator draws them from the admin console's Demo tab, a strip copies their panels at 0 credits, with no model call.
- **An idea of one's own needs a passkey sign-in**, refused as `forbidden`, reason `passkey_required`, for a session that signed in with a code.
- **No share links.** `canShare` answers `false` on a sandbox.
- **A daily spend limit**, `spendLimit: { usdPerDay: 5 }`, past which `pause_ai` holds until the UTC day ends.
- **A nightly reset.** A cron at 03:00 UTC deletes every strip older than a day, with its files, its share link and its notifications.

## Related

- [Deploy to production](https://nuxt-backend.dev/docs/ship/deploy): the build command and the env split this page reuses.
- [Try the demo](https://nuxt-backend.dev/docs/start/playground): Panels on this site, with these limits.
- [Preview environments](https://nuxt-backend.dev/docs/ship/deploy/previews): a short-lived backend per branch, also on the test modes.
- [Environments](https://nuxt-backend.dev/docs/start/concepts/environments): what each value of `BACKEND_ENVIRONMENT` turns on.
- [Develop on real sandboxes](https://nuxt-backend.dev/docs/develop/sandboxes): the sandbox token, the test addresses and the test card.


## Sitemap

See the full [sitemap](https://nuxt-backend.dev/sitemap.md) for all pages.
