---
title: "Quickstart"
description: "A signed-in app in about three minutes with no account anywhere, then credits bought on Polar's sandbox and spent by a metered action in about five more."
canonical_url: "https://nuxt-backend.dev/docs/start/quickstart"
---
# Quickstart

> A signed-in app in about three minutes with no account anywhere, then credits bought on Polar's sandbox and spent by a metered action in about five more.

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

Two checkpoints take you from an empty folder to a signed-in app that sells and spends credits. The first needs no account: the app runs on a local deployment, and sign-in codes print in your terminal. The second adds a Polar sandbox account, so checkout runs on Polar's own test server.

<table>
<thead>
  <tr>
    <th>
      Checkpoint
    </th>
    
    <th>
      Accounts
    </th>
    
    <th>
      Time
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a href="#checkpoint-1-a-signed-in-app">
        1. A signed-in app
      </a>
    </td>
    
    <td>
      None
    </td>
    
    <td>
      About 3 minutes
    </td>
  </tr>
  
  <tr>
    <td>
      <a href="#checkpoint-2-credits-bought-and-spent">
        2. Credits bought and spent
      </a>
    </td>
    
    <td>
      A Polar sandbox account
    </td>
    
    <td>
      About 5 minutes
    </td>
  </tr>
  
  <tr>
    <td>
      <a href="#next-email-and-webhooks">
        Next: email and webhooks
      </a>
    </td>
    
    <td>
      A Resend account, and a Convex account for a cloud deployment
    </td>
    
    <td>
      About 10 minutes
    </td>
  </tr>
</tbody>
</table>

You need Node 24.11 or later. Deploying is not part of the Quickstart: [Deploy](https://nuxt-backend.dev/docs/ship/deploy) takes it from here.

## Checkpoint 1: a signed-in app

<steps level="3">

### Create the app

<code-group>

```bash [new app]
npm create nuxt@latest my-app -- -t gh:qruto/nuxt-backend/templates/starter
cd my-app
```

```bash [existing app]
npx nuxt module add nuxt-backend
```

</code-group>

The [starter](https://nuxt-backend.dev/docs/start/templates#starter) is a Nuxt app with the module installed and its backend files written. In an app you already have, `nuxt module add` is the whole install: the module's install step adds `convex`, writes the same files into `backend/`, points the `dev` script at `nuxt-backend dev`, swaps `<NuxtWelcome />` for `<NuxtPage />` and adds a home page when the app has none. It asks a few questions in the terminal, and the defaults are fine for this page. [Installation](https://nuxt-backend.dev/docs/start/installation) covers strict pnpm, the install through a coding agent and the install by hand.

### Start it

```bash
npx nuxt-backend dev --anonymous
```

`npx nuxt-backend dev` runs Convex and Nuxt together, and the `dev` script runs the same command. `--anonymous` creates a local deployment that needs no account, on macOS, Linux and Windows alike. A plain `npm run dev` asks instead, and **Start without an account** is the same answer. The first run writes `CONVEX_DEPLOYMENT` to `.env.local`, then gives the deployment its `AUTH_SECRET`, a `SITE_URL` of `http://localhost:3000` and a `BACKEND_ENVIRONMENT` of `development`. Its last check reads `backend preflight: …`, and the email and billing findings in it are expected until you connect those services.

### Sign in with the code in the terminal

Open [localhost:3000/login](http://localhost:3000/login), type your email and ask for a code. No email provider is connected, and a `development` deployment logs every code, so it prints in the terminal running `dev`. Paste it, and you are signed in, with a personal workspace of your own.

</steps>

**You should now see** your email and your workspace on `/app`, which the starter's home page opens. In an app you already have, open `/settings`, which the module mounts.

## Checkpoint 2: credits bought and spent

The starter's catalog, `backend/billing.catalog.ts`, declares two plans and two credit packs. This checkpoint creates them in Polar's sandbox, buys a pack with a test card and spends one credit.

<steps level="3">

### Connect Polar's sandbox

Sign up at [sandbox.polar.sh](https://sandbox.polar.sh/start), create an organization and an organization access token, and put the token in `.env.local`:

```bash [.env.local]
BILLING_ACCESS_TOKEN=your_sandbox_access_token
```

Then push it to the deployment and create the catalog in the sandbox:

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

`billing sync` creates the meter, the plans and the packs, and writes their ids to `backend/billing.generated.ts`. [`/pricing`](http://localhost:3000/pricing) lists them now.

### Buy a credit pack

On `/app`, press **Buy 500 credits**. Polar's sandbox checkout opens: pay with the card `4242 4242 4242 4242`, any future expiry and any CVC, then press **Pay**. Back on `/app`, the balance reads 500. The return from checkout refreshes it, since Polar's webhooks cannot reach a deployment on your machine.

### Spend a credit

Press **Spend 1 credit**. It calls `transform` from `backend/ai.ts`, a metered action: it reserves a credit, runs, then settles the spend with Polar, and the balance drops to 499. A run that fails releases its reservation and charges nothing.

</steps>

**You should now see** 499 credits on `/app` and in the credits section of `/settings`.

In an app you already have, these two buttons are one page:

```vue [app/pages/credits.vue]
<script setup lang="ts">
import { api } from '#backend/api'

definePageMeta({ auth: true })

const { products } = useBilling()
const { balance, topUp } = useCredits({ meter: 'credits' })
const spend = useAction(api.ai.transform)
</script>

<template>
  <p>{{ balance ?? '…' }} credits</p>
  <button v-if="products?.credits500" @click="topUp(products.credits500.id)">
    Buy 500 credits
  </button>
  <button @click="spend({ prompt: 'hello' })">Spend 1 credit</button>
</template>
```

`definePageMeta({ auth: true })` sends a visitor who is not signed in to `/login` and back. `useCredits` reads the balance live, so the page updates the moment a purchase or a spend settles.

## Next: email and webhooks

Codes in the terminal and a refresh after checkout cover a first run. Two more steps make development behave like production. The [Service map](https://nuxt-backend.dev/docs/services) gives the order, and each service's page its keys:

- **Email.** Put a Resend key in `.env.local` as `EMAIL_API_KEY`, with `EMAIL_FROM`, and run `npx nuxt-backend env push` ([Resend](https://nuxt-backend.dev/docs/services/resend)). In development, mail goes only to Resend's test addresses: sign in as `delivered+you@resend.dev`, and read the code with `npx nuxt-backend inbox`.
- **Webhooks.** `npx convex login` links the deployment to your Convex account, and a cloud dev deployment has the public URL Polar and Resend post to ([Convex](https://nuxt-backend.dev/docs/services/convex)). Run `npx nuxt-backend billing sync` and `npx nuxt-backend email sync` again to register it.

[Develop on real sandboxes](https://nuxt-backend.dev/docs/develop/sandboxes) covers both, and the AI gateway for a real model call.

## Where to go next

- [Build a creative app](https://nuxt-backend.dev/docs/start/tutorial): the tutorial, from this starter to Panels, a comic-strip maker in production.
- [Service map](https://nuxt-backend.dev/docs/services): every provider, what it powers, and the order to connect them in.
- [What you got](https://nuxt-backend.dev/docs/start/what-you-got): every file, page, route and composable the first run gave you.
- [Feature map](https://nuxt-backend.dev/docs/start/feature-map): everything else the package does, capability by capability.
- [Run the dev loop](https://nuxt-backend.dev/docs/develop/dev-loop): the daily loop, and the other kinds of deployment.
- [Try the demo](https://nuxt-backend.dev/docs/start/playground): Panels, the tutorial's app, running live in sandbox mode, before you build anything.

## First-run troubleshooting

<table>
<thead>
  <tr>
    <th>
      What you see
    </th>
    
    <th>
      Why, and the fix
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      The Nuxt welcome page instead of the app
    </td>
    
    <td>
      <code>
        app/app.vue
      </code>
      
       still renders <code>
        <NuxtWelcome />
      </code>
      
      . <a href="https://nuxt-backend.dev/docs/ship/operate/troubleshooting#login-shows-the-nuxt-welcome-page">
        Render <code>
          <NuxtPage />
        </code>
      </a>
      
       instead.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        convex dev
      </code>
      
       can't resolve <code>
        @convex-dev/…
      </code>
    </td>
    
    <td>
      Strict pnpm hides the components Convex bundles. <a href="https://nuxt-backend.dev/docs/start/installation#using-strict-pnpm">
        Hoist them
      </a>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      "This app is in test mode and only emails test addresses, so this address can't receive mail here."
    </td>
    
    <td>
      Email is connected and in test mode, which delivers only to Resend's test addresses. Sign in as <code>
        delivered+you@resend.dev
      </code>
      
      , and read the code in the terminal or with <code>
        npx nuxt-backend inbox
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      "This app can't send email yet."
    </td>
    
    <td>
      The deployment has no email provider, and it is not a <code>
        development
      </code>
      
       one, so it does not log codes either. Run <code>
        npx nuxt-backend env push
      </code>
      
      , which sets <code>
        BACKEND_ENVIRONMENT
      </code>
      
       on a dev deployment.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        /pricing
      </code>
      
       is empty
    </td>
    
    <td>
      The catalog never reached the deployment. With <code>
        dev
      </code>
      
       running, run <code>
        npx nuxt-backend billing sync
      </code>
      
      , then see <a href="https://nuxt-backend.dev/docs/ship/operate/troubleshooting#pricing-is-empty-although-the-catalog-synced">
        Pricing is empty
      </a>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        billing sync
      </code>
      
       says the token is invalid
    </td>
    
    <td>
      It is a production token. Polar's sandbox takes only a token created in the sandbox itself.
    </td>
  </tr>
</tbody>
</table>

Anything else: [Troubleshooting](https://nuxt-backend.dev/docs/ship/operate/troubleshooting) lists every message the package prints, and `npx nuxt-backend doctor` names what is missing ([Diagnose your setup](https://nuxt-backend.dev/docs/develop/doctor)).


## Sitemap

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