---
title: "Convex"
description: "Set up the Convex deployment the backend runs on: the account, the region, dev and production deployments, and the keys the app and the CLI read."
canonical_url: "https://nuxt-backend.dev/docs/services/convex"
---
# Convex

> Set up the Convex deployment the backend runs on: the account, the region, dev and production deployments, and the keys the app and the CLI read.

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

Convex runs your database, your functions and the packaged `backend` component. It is the one service every app needs.

<table>
<thead>
  <tr>
    <th>
      You need
    </th>
    
    <th>
      Time
    </th>
    
    <th>
      Cost to start
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      A Convex account, or none for a local deployment
    </td>
    
    <td>
      5 minutes
    </td>
    
    <td>
      Free: the free plan covers development
    </td>
  </tr>
</tbody>
</table>

## What it powers

<table>
<thead>
  <tr>
    <th>
      Capability
    </th>
    
    <th>
      What Convex gives
    </th>
    
    <th>
      Build pages
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        data
      </code>
    </td>
    
    <td>
      The database with realtime queries, full-text search and file storage
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/build/data/read-write">
        Query and update data
      </a>
      
      , <a href="https://nuxt-backend.dev/docs/build/data/files">
        Files
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        jobs
      </code>
    </td>
    
    <td>
      The scheduler, crons, and the workflow and workpool components
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/build/data/jobs">
        Background work
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        auth
      </code>
    </td>
    
    <td>
      The functions Better Auth runs in, inside the <code>
        backend
      </code>
      
       component
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/build/auth/setup">
        Auth setup
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ai
      </code>
    </td>
    
    <td>
      The Convex AI Gateway, on a paid plan, where <code>
        setupAi({ gateway })
      </code>
      
       names <code>
        'convex'
      </code>
      
       (the default order does)
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/services/ai-gateway#choose-a-gateway">
        AI gateway
      </a>
    </td>
  </tr>
</tbody>
</table>

Every other capability keeps its state in the same deployment, so one Convex backup holds the whole app ([Back up, restore and roll back](https://nuxt-backend.dev/docs/ship/operate/backup)).

## Create the account

<steps level="3">

### Start without an account, if you like

`npx nuxt-backend dev --anonymous` runs a local deployment on your machine with no account, on every OS. Everything but the AI Gateway works there. Link it to an account later with `npx convex login`.

### Sign up

Open [dashboard.convex.dev](https://dashboard.convex.dev) and sign in with GitHub or Google. Convex creates a team for you.

### Pick the region before the first project

In the team's settings, set the default region: US East (Virginia), EU West (Ireland), Canada Central or Asia Pacific (Sydney). A deployment keeps the region it was created in. Read [Data and compliance](#data-and-compliance) before you choose.

### Create the project

Run `npx nuxt-backend dev` in your app. The first run asks you to log in, creates the project and your dev deployment, and writes `CONVEX_DEPLOYMENT` to `.env.local`. Each developer who runs it gets a dev deployment of their own in the same project.

</steps>

**Who should own it.** Create the project in a team, not a personal account, and invite each developer to the team. The person who answers for production keeps the production deploy key. The team's plan pays for every deployment in it.

## Sandbox and test mode

Convex has no test mode: a deployment is real wherever it runs. The kind of deployment keeps development apart, and `env push` sets `BACKEND_ENVIRONMENT` from it:

<table>
<thead>
  <tr>
    <th>
      Deployment
    </th>
    
    <th>
      <code>
        CONVEX_DEPLOYMENT
      </code>
    </th>
    
    <th>
      <code>
        BACKEND_ENVIRONMENT
      </code>
    </th>
    
    <th>
      Used for
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      Local or account-free
    </td>
    
    <td>
      <code>
        local:…
      </code>
      
      , <code>
        anonymous:…
      </code>
    </td>
    
    <td>
      <code>
        development
      </code>
    </td>
    
    <td>
      Your machine. Provider webhooks need a tunnel to reach it
    </td>
  </tr>
  
  <tr>
    <td>
      Cloud dev
    </td>
    
    <td>
      <code>
        dev:…
      </code>
    </td>
    
    <td>
      <code>
        development
      </code>
    </td>
    
    <td>
      One per developer, with a public URL providers can reach
    </td>
  </tr>
  
  <tr>
    <td>
      Preview
    </td>
    
    <td>
      <code>
        preview:…
      </code>
    </td>
    
    <td>
      <code>
        preview
      </code>
    </td>
    
    <td>
      One per branch, deleted after 5 days (14 on Professional)
    </td>
  </tr>
  
  <tr>
    <td>
      Production
    </td>
    
    <td>
      <code>
        prod:…
      </code>
    </td>
    
    <td>
      <code>
        production
      </code>
    </td>
    
    <td>
      The live app. Set <code>
        sandbox
      </code>
      
       on purpose for a <a href="https://nuxt-backend.dev/docs/ship/deploy/staging">
        demo or staging app
      </a>
    </td>
  </tr>
</tbody>
</table>

[Environments and deployments](https://nuxt-backend.dev/docs/start/concepts/environments#backend_environment) has what each value turns on.

## Keys and environment

<table>
<thead>
  <tr>
    <th>
      Variable
    </th>
    
    <th>
      Where to find it
    </th>
    
    <th>
      Dev
    </th>
    
    <th>
      Prod
    </th>
    
    <th>
      Secret
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        CONVEX_DEPLOYMENT
      </code>
    </td>
    
    <td>
      Written to <code>
        .env.local
      </code>
      
       by the first <code>
        npx nuxt-backend dev
      </code>
      
      . The platform's own name: read it, never author it
    </td>
    
    <td>
      <code>
        dev:<slug>
      </code>
    </td>
    
    <td>
      <code>
        prod:<slug>
      </code>
      
       on the host, optional
    </td>
    
    <td>
      No
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        NUXT_PUBLIC_BACKEND_URL
      </code>
    </td>
    
    <td>
      Derived from <code>
        CONVEX_DEPLOYMENT
      </code>
      
      . The production build gets it from <code>
        convex deploy
      </code>
    </td>
    
    <td>
      Derived
    </td>
    
    <td>
      <code>
        https://<slug>.convex.cloud
      </code>
    </td>
    
    <td>
      No
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        CONVEX_DEPLOY_KEY
      </code>
    </td>
    
    <td>
      The production deployment's <strong>
        Settings
      </strong>
      
      , <strong>
        Deploy keys
      </strong>
      
      . Preview deploy keys sit in the project's settings
    </td>
    
    <td>
      Not used
    </td>
    
    <td>
      In the host's build env
    </td>
    
    <td>
      Yes
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        AUTH_SECRET
      </code>
    </td>
    
    <td>
      Generate it: <code>
        openssl rand -base64 32
      </code>
    </td>
    
    <td>
      Provisioned for you
    </td>
    
    <td>
      32 random bytes of production's own
    </td>
    
    <td>
      Yes
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        SITE_URL
      </code>
    </td>
    
    <td>
      The origin your app answers on
    </td>
    
    <td>
      Provisioned for you
    </td>
    
    <td>
      <code>
        https://app.example.com
      </code>
    </td>
    
    <td>
      No
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        BACKEND_ENVIRONMENT
      </code>
    </td>
    
    <td>
      Set by <code>
        env push
      </code>
      
       from the deployment's kind
    </td>
    
    <td>
      <code>
        development
      </code>
    </td>
    
    <td>
      <code>
        production
      </code>
      
      , or <code>
        sandbox
      </code>
      
       for a demo
    </td>
    
    <td>
      No
    </td>
  </tr>
</tbody>
</table>

A self-hosted backend uses the platform's `CONVEX_SELF_HOSTED_URL` and `CONVEX_SELF_HOSTED_ADMIN_KEY` instead of a deploy key ([Self-host and add domains](https://nuxt-backend.dev/docs/ship/deploy/self-hosting)).

## Link it

<steps level="3">

### Provision the dev deployment

`npx nuxt-backend dev` pushes `backend/` on every save, and provisions the dev deployment's `AUTH_SECRET`, `SITE_URL` and `BACKEND_ENVIRONMENT`.

### Forward what you add to `.env.local`

```bash
npx nuxt-backend env push
```

It forwards the package's names from `.env.local` to the dev deployment, and generates the web push key pair ([`env push`](https://nuxt-backend.dev/docs/reference/cli#env-push)).

### Give new preview deployments a starting env

In the project's **Settings**, set default environment variables for preview deployments, `AUTH_SECRET` at least. Defaults apply only to deployments created after you set them ([Set up preview environments](https://nuxt-backend.dev/docs/ship/deploy/previews)).

</steps>

## Check it

```bash
npx nuxt-backend doctor --only data
```

<table>
<thead>
  <tr>
    <th>
      Finding
    </th>
    
    <th>
      What it checks
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/cli/diagnostics#deployment-env">
        <code>
          deployment-env
        </code>
      </a>
    </td>
    
    <td>
      The CLI can read the deployment's env
    </td>
  </tr>
  
  <tr>
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/cli/diagnostics#backend-site-url">
        <code>
          backend-site-url
        </code>
      </a>
    </td>
    
    <td>
      The app finds the deployment's HTTP origin
    </td>
  </tr>
  
  <tr>
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/cli/diagnostics#env-defaults">
        <code>
          env-defaults
        </code>
      </a>
    </td>
    
    <td>
      A new preview deployment starts with the env its first push needs
    </td>
  </tr>
  
  <tr>
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/cli/diagnostics#convex-config">
        <code>
          convex-config
        </code>
      </a>
    </td>
    
    <td>
      <code>
        backend/convex.config.ts
      </code>
      
       mounts the <code>
        backend
      </code>
      
       component
    </td>
  </tr>
  
  <tr>
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/cli/diagnostics#deployment-backend-environment">
        <code>
          deployment-backend-environment
        </code>
      </a>
    </td>
    
    <td>
      The deployment holds <code>
        BACKEND_ENVIRONMENT
      </code>
      
      , and under <code>
        --prod
      </code>
      
       that it says <code>
        production
      </code>
    </td>
  </tr>
</tbody>
</table>

## Go to production

<steps level="3">

### Generate the production deploy key

Open the production deployment's settings in the dashboard and generate a deploy key. Put it in the host's env as `CONVEX_DEPLOY_KEY`, and export it in your shell for the commands below.

### Set production's own values

```bash
openssl rand -base64 32 | npx convex env set --prod AUTH_SECRET
printf %s https://app.example.com | npx convex env set --prod SITE_URL
npx nuxt-backend env push --prod
```

`--prod` sets `BACKEND_ENVIRONMENT=production` and never copies a secret from `.env.local`.

### Deploy and check

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

`deploy` takes the first production deploy step by step, and every step looks before it writes, so it is safe to run again. After it, the host's build command runs `npx convex deploy --cmd 'npm run build' --cmd-url-env-var-name NUXT_PUBLIC_BACKEND_URL` ([Deploy to production](https://nuxt-backend.dev/docs/ship/deploy)).

</steps>

## Costs and limits

Checked on 2026-10-25 against [Convex pricing](https://www.convex.dev/pricing) and [limits](https://docs.convex.dev/production/state/limits):

<table>
<thead>
  <tr>
    <th>
      
    </th>
    
    <th>
      Free and Starter
    </th>
    
    <th>
      Professional
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      Price
    </td>
    
    <td>
      $0. Free stops at its limits; Starter bills usage past them
    </td>
    
    <td>
      $25 per developer a month
    </td>
  </tr>
  
  <tr>
    <td>
      Function calls
    </td>
    
    <td>
      1M a month
    </td>
    
    <td>
      25M a month
    </td>
  </tr>
  
  <tr>
    <td>
      Database storage
    </td>
    
    <td>
      0.5 GB
    </td>
    
    <td>
      50 GB
    </td>
  </tr>
  
  <tr>
    <td>
      File storage
    </td>
    
    <td>
      1 GB
    </td>
    
    <td>
      100 GB
    </td>
  </tr>
  
  <tr>
    <td>
      Data egress
    </td>
    
    <td>
      1 GB
    </td>
    
    <td>
      50 GB
    </td>
  </tr>
  
  <tr>
    <td>
      Action compute
    </td>
    
    <td>
      20 GB-hours
    </td>
    
    <td>
      250 GB-hours
    </td>
  </tr>
  
  <tr>
    <td>
      Concurrent queries and mutations
    </td>
    
    <td>
      16
    </td>
    
    <td>
      256
    </td>
  </tr>
  
  <tr>
    <td>
      Concurrent actions
    </td>
    
    <td>
      64
    </td>
    
    <td>
      512
    </td>
  </tr>
</tbody>
</table>

- **Paid plans only:** the AI Gateway (Starter and Professional). On Professional: log streams, exception reporting, periodic backups and custom domains.
- **Regions:** usage outside the US costs 1.3 times as much. The included amounts are shared across regions.
- **Function limits:** a query or mutation runs at most 1 second of your code, and a document holds at most 1 MiB.
- **On the Free plan,** writes past the storage limit fail. Watch the usage page before launch, or move to Starter.

## Data and compliance

- **What it holds:** everything your app stores: accounts, sessions, workspaces, billing state, email logs, files and your own tables.
- **Region:** a deployment stays in the region you chose, and its storage providers are located there. Moving to another region means a new deployment and a [restored backup](https://nuxt-backend.dev/docs/ship/operate/backup).
- **Role:** Convex processes data on your behalf. Its [DPA](https://www.convex.dev/legal/dpa) includes the standard contractual clauses, and it lists its [subprocessors](https://www.convex.dev/legal/subprocessors).
- **Certifications:** SOC 2 Type 2, and HIPAA with a BAA on Professional. Data is encrypted at rest with AES-256 ([Convex security](https://www.convex.dev/security)).

Name Convex in your privacy policy as a processor ([Privacy, GDPR and cookies](https://nuxt-backend.dev/docs/ship/compliance/privacy)). This is not legal advice.

## Related

- [Environments and deployments](https://nuxt-backend.dev/docs/start/concepts/environments): what each deployment kind turns on.
- [Deploy to production](https://nuxt-backend.dev/docs/ship/deploy): the first deploy, step by step.
- [Set up preview environments](https://nuxt-backend.dev/docs/ship/deploy/previews): a backend per branch.
- [Back up, restore and roll back](https://nuxt-backend.dev/docs/ship/operate/backup): backups, and moving a deployment.
- [Service map](https://nuxt-backend.dev/docs/services): every service, and the order to set them up in.


## Sitemap

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