---
title: "Run the dev loop"
description: "The daily loop with npx nuxt-backend dev, on a cloud, local or account-free deployment (dev --anonymous), and what it keeps in step for you: codegen, the deployment's env, BACKEND_ENVIRONMENT and sign-in codes in the terminal."
canonical_url: "https://nuxt-backend.dev/docs/develop/dev-loop"
---
# Run the dev loop

> The daily loop with npx nuxt-backend dev, on a cloud, local or account-free deployment (dev --anonymous), and what it keeps in step for you: codegen, the deployment's env, BACKEND_ENVIRONMENT and sign-in codes in the terminal.

Version: nuxt-backend 0.6.x · Tab: Develop · 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.

One command runs the whole app: Convex and Nuxt in one terminal, on a deployment that is yours alone. It provisions what a new deployment needs before anything starts, so the first run and every later one look the same.

- **What powers it natively:** `convex dev`, which pushes your functions on save and regenerates their types, and `nuxt dev`.
- **What the package adds:** `npx nuxt-backend dev`, which provisions the deployment's env first, sets `BACKEND_ENVIRONMENT`, and runs both in one process.

<steps level="3">

### Start it

```bash
npm run dev   # the dev script the install writes: nuxt-backend dev
```

`npx nuxt module add nuxt-backend` points the `dev` script at `nuxt-backend dev` when it installs the package, and `npx nuxt-backend init` does the same later. `npx nuxt-backend dev` runs it where the `dev` script is one of your own. Arguments after it go to `nuxt dev` (`npm run dev -- --port 3001`), and Ctrl-C stops Convex, Nuxt and a local backend together.

### Pick a deployment, once

The first run asks which deployment to use and writes the answer to `.env.local` as `CONVEX_DEPLOYMENT`. Every later run reuses it.

<table>
<thead>
  <tr>
    <th>
      Kind
    </th>
    
    <th>
      <code>
        CONVEX_DEPLOYMENT
      </code>
    </th>
    
    <th>
      Needs
    </th>
    
    <th>
      Good for
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      Account-free local
    </td>
    
    <td>
      <code>
        anonymous:…
      </code>
    </td>
    
    <td>
      Nothing: <strong>
        Start without an account
      </strong>
      
      , or <code>
        npx nuxt-backend dev --anonymous
      </code>
    </td>
    
    <td>
      Trying the package, agents and CI
    </td>
  </tr>
  
  <tr>
    <td>
      Local
    </td>
    
    <td>
      <code>
        local:…
      </code>
    </td>
    
    <td>
      A Convex account
    </td>
    
    <td>
      Working offline on a project of yours
    </td>
  </tr>
  
  <tr>
    <td>
      Cloud dev
    </td>
    
    <td>
      <code>
        dev:…
      </code>
    </td>
    
    <td>
      A Convex account
    </td>
    
    <td>
      Webhooks from Polar and Resend, the Convex AI Gateway on a paid plan, a team sharing one deployment
    </td>
  </tr>
</tbody>
</table>

`--anonymous` skips the question and starts on an account-free local deployment, the same way on macOS, Linux and Windows. It replaces setting `CONVEX_AGENT_MODE=anonymous` in the shell, which only works in POSIX shells. When `.env.local` already names a deployment, `dev` keeps it and says so: remove `CONVEX_DEPLOYMENT` from it to start an account-free one.

A local deployment runs only while `dev` runs, and providers cannot reach it from the internet. `npx convex login` turns an account-free deployment into one of your account's, and `npx convex dev --configure` points the app at another deployment.

### Change things

- **Backend code** in `backend/` is pushed on save, and `backend/_generated/` is regenerated, so `#backend/api` is typed at once.
- **A missing backend file** comes back with `npx nuxt-backend init`, which never touches a file that exists.
- **A value in .env.local** reaches the deployment with `npx nuxt-backend env push`, which never replaces a value already there (`--force` does).
- **The billing catalog** reaches Polar's sandbox with `npx nuxt-backend billing sync` ([Develop with real sandboxes](https://nuxt-backend.dev/docs/develop/sandboxes#billing-on-polars-sandbox)).

</steps>

## Check it works

The dev console ends its start with one line, `backend preflight: …`, which counts the checks that pass and names the findings that do not. `npx nuxt-backend status` gives the state of each [capability](https://nuxt-backend.dev/docs/start/concepts/capabilities), and the [DevTools tab](https://nuxt-backend.dev/docs/develop/devtools) shows the same, live.

## What the first run provisions

Before Convex pushes anything, `dev` gives a new deployment the values it cannot start without, and never replaces one that is set:

- `AUTH_SECRET`, generated for this deployment;
- `SITE_URL`, set to `http://localhost:3000`;
- `BACKEND_ENVIRONMENT`, derived from `CONVEX_DEPLOYMENT`: `development` on every dev deployment.

`development` turns on what this page relies on. Sign-in codes print in the terminal running `dev`, email stays in test mode, billing uses Polar's sandbox, and auth trusts every local origin of your machine (another port, or a `https://*.localhost` name) as well as `SITE_URL`. None of it reaches a preview or production deployment ([Environments](https://nuxt-backend.dev/docs/start/concepts/environments#backend_environment)).

## What the dev server keeps out of the browser

Vite serves a pre-bundled dependency, such as `vue.js?v=…`, as immutable for a year, and Safari keeps it across dev server restarts. Once the dependencies are optimized again, under a new `?v=`, a page can run an old copy of Vue beside the new one. Their reactivity does not cross, and a signed-in page ends on a 500. So on `nuxt dev` the module:

- sends every dev module with `Cache-Control: no-cache` (`vite.server.headers`), so the browser checks each one with the dev server before it uses it: an unchanged module costs a `304`, and a changed one comes back whole;
- serves the modules from `/_dev/` instead of `/_nuxt/` (`app.buildAssetsDir`). That reaches the copies a browser already stored as immutable, from an earlier dev server: the browser never asks about those, so no header can, and at the new path it never asks for them again.

A production build is untouched: its assets are hashed and cached for a year, under `/_nuxt/`. A setting of your own wins: a `Cache-Control` in `vite.server.headers`, or any `app.buildAssetsDir`, at the top level or under `$development` (`'/_nuxt/'` written out keeps Nuxt's). The rate limiter and HSTS stay off on `nuxt dev` as well, unless your config or a layer turns one on under `$development` or `$env.development` ([Content Security Policy](https://nuxt-backend.dev/docs/ship/security#content-security-policy)).

## Reach your machine from outside

Polar's sandbox and Resend post their webhooks to a public URL. On a cloud dev deployment that URL is the deployment's own, and it works as it is. A local deployment has none: run a tunnel to it, and pass the tunnel's URL to [`billing sync`](https://nuxt-backend.dev/docs/reference/cli#billing-sync) as `--webhook`, and to Resend's webhook settings.

## Why a dev command of its own

Convex starts the command it runs only after a push succeeds, and a new deployment's first push fails until `AUTH_SECRET` and `SITE_URL` are on it. Started that way, a new app waits forever. `nuxt-backend dev` provisions first and then hands over to the same `convex dev --start`. `doctor` reports the old script as [`dev-script`](https://nuxt-backend.dev/docs/reference/cli/diagnostics#dev-script), and `doctor --fix` rewrites it. Two terminals work too: `npx convex dev` in one and `nuxt dev` in the other, in either order.

## Related

- [Develop with real sandboxes](https://nuxt-backend.dev/docs/develop/sandboxes): Polar's sandbox, Resend's test addresses, the dev inbox and the AI gateway.
- [DevTools](https://nuxt-backend.dev/docs/develop/devtools): the Backend tab, each capability's light as you work.
- [`dev`](https://nuxt-backend.dev/docs/reference/cli#dev) and [`env push`](https://nuxt-backend.dev/docs/reference/cli#env-push) in the CLI reference: every step and flag.
- [Diagnose your setup](https://nuxt-backend.dev/docs/develop/doctor): when the preflight line names a finding.
- [Environment variables](https://nuxt-backend.dev/docs/reference/configuration/environment-variables): every name the deployment and the app read.


## Sitemap

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