---
title: "Principles"
description: "The decisions behind nuxt-backend and the reason for each, from passkeys and sign-in codes, one module and native first to detected capabilities, real sandboxes with no simulators, a headless-capable UI with no UI kit, and the guardrails on growth features."
canonical_url: "https://nuxt-backend.dev/docs/start/concepts/principles"
---
# Principles

> The decisions behind nuxt-backend and the reason for each, from passkeys and sign-in codes, one module and native first to detected capabilities, real sandboxes with no simulators, a headless-capable UI with no UI kit, and the guardrails on growth features.

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

Most "why does the package not do X" questions have their answer here. Each principle is a decision, not a gap waiting for a release. Together they keep the package to one way of doing each job, and leave each job to the service built for it.

<table>
<thead>
  <tr>
    <th>
      Principle
    </th>
    
    <th>
      Why
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a href="#email-codes-and-passkeys-only">
        Email codes and passkeys only
      </a>
    </td>
    
    <td>
      One way to prove an account means one recovery path, one step-up and no password to leak.
    </td>
  </tr>
  
  <tr>
    <td>
      <a href="#one-module-not-a-nuxt-layer">
        One module, not a Nuxt layer
      </a>
    </td>
    
    <td>
      One entry in <code>
        modules
      </code>
      
       gives the whole backend, and upgrades never fight a copy of the package's files in your app.
    </td>
  </tr>
  
  <tr>
    <td>
      <a href="#native-first">
        Native first
      </a>
    </td>
    
    <td>
      The providers already do these jobs well, and a second copy of their work would drift from theirs.
    </td>
  </tr>
  
  <tr>
    <td>
      <a href="#brand-neutral-names">
        Brand-neutral names
      </a>
    </td>
    
    <td>
      Code written against neutral names reads as your product, and outlives a change underneath.
    </td>
  </tr>
  
  <tr>
    <td>
      <a href="#one-way-per-action">
        One way per action
      </a>
    </td>
    
    <td>
      Two APIs for one job split the docs, the tests and your team's habits in two.
    </td>
  </tr>
  
  <tr>
    <td>
      <a href="#workspaces-everywhere">
        Workspaces, everywhere
      </a>
    </td>
    
    <td>
      One word for the unit that pays, holds members and owns data keeps every name and label in step.
    </td>
  </tr>
  
  <tr>
    <td>
      <a href="#capabilities-are-detected-never-switched">
        Capabilities are detected, never switched
      </a>
    </td>
    
    <td>
      A switch can disagree with what is configured, and the env and a check cannot.
    </td>
  </tr>
  
  <tr>
    <td>
      <a href="#real-sandboxes-in-development">
        Real sandboxes in development
      </a>
    </td>
    
    <td>
      A flow you test against the provider's own test mode behaves the way production will, webhooks included.
    </td>
  </tr>
  
  <tr>
    <td>
      <a href="#one-environment-name">
        One environment name
      </a>
    </td>
    
    <td>
      One value says what kind of deployment runs, so test mode, sandbox billing and code logging never disagree.
    </td>
  </tr>
  
  <tr>
    <td>
      <a href="#vercel-first-not-vercel-only">
        Vercel first, not Vercel only
      </a>
    </td>
    
    <td>
      The platform's own services make the defaults better there, without tying your app to it.
    </td>
  </tr>
  
  <tr>
    <td>
      <a href="#headless-capable-ui-no-ui-kit">
        Headless-capable UI, no UI kit
      </a>
    </td>
    
    <td>
      Styled pages get you to launch, and your own design system can take over any part without a second library underneath.
    </td>
  </tr>
  
  <tr>
    <td>
      <a href="#customize-by-climbing-the-ladder">
        Customize by climbing the ladder
      </a>
    </td>
    
    <td>
      You change only as much as you need, and every update below that rung keeps working.
    </td>
  </tr>
  
  <tr>
    <td>
      <a href="#edges-fail-closed">
        Edges fail closed
      </a>
    </td>
    
    <td>
      Something not configured does less, never more, so a missing secret is never a hole.
    </td>
  </tr>
  
  <tr>
    <td>
      <a href="#guardrails-on-growth-features">
        Guardrails on growth features
      </a>
    </td>
    
    <td>
      Waitlists, referrals, gifts, promotions and cancellations are where apps run into consumer and marketing law.
    </td>
  </tr>
  
  <tr>
    <td>
      <a href="#what-it-never-does">
        What it never does
      </a>
    </td>
    
    <td>
      Seats, passwords, teams inside a workspace and a money ledger each cost more than they give here.
    </td>
  </tr>
</tbody>
</table>

## Email codes and passkeys only

Sign-in is a passkey or an email sign-in code, powered by Better Auth's passkey and email OTP plugins. There are no passwords to store, reset or leak, no social sign-in and no magic links. There is no separate two-factor setup either: a passkey already pairs the device with a fingerprint, a face or a PIN, and the package requires that check at every passkey sign-in (user verification), so holding the device is not enough. With one way to prove an account, recovery, account merging and the recent sign-in that sensitive actions ask for each have one path.

Both halves are hardened:

- **Codes, not links.** Corporate mail scanners open links before people do, so a link can be spent by a robot. A code is typed by the person who asked for it.
- **A code works only in the browser that asked for it.** The request sets an HttpOnly cookie, and the code is refused anywhere else. Codes live for minutes and allow a few attempts.
- **The email says who asked.** It shows the requesting device, an approximate place and the time, so a person can tell a request that is not theirs.
- **Passkeys come next.** After a code sign-in, the sign-in flow offers to add a passkey. A person can then make the account passkey-only, which refuses codes, with "Lost your passkey?" as the recovery path.

An app that must offer passwords or "Sign in with …" needs another auth package ([Sign users in](https://nuxt-backend.dev/docs/build/auth/sign-in)).

## One module, not a Nuxt layer

nuxt-backend is one Nuxt module: you add `'nuxt-backend'` to `modules`, never to `extends`. A Nuxt layer merges its pages, components and config into your app as files you then live beside. A module registers what it gives through Nuxt's own hooks, so your app keeps a single source for each thing:

- **Your files are yours.** `backend/` holds the setup files the install wrote once. The package never rewrites them, and `npx nuxt-backend upgrade` repairs only what is missing.
- **The package's code stays in the package.** Pages, components and composables come from `node_modules`, so an upgrade replaces them whole.
- **Overrides are explicit.** A component of yours with a part's name replaces it everywhere, and `npx nuxt-backend eject` copies a part's source when you want to own it ([Customize by climbing the ladder](#customize-by-climbing-the-ladder)).

`npx nuxt module add nuxt-backend` is the whole install. The module's install step adds `convex`, writes `backend/`, and asks whether to write the agent files ([Installation](https://nuxt-backend.dev/docs/start/installation)).

## Native first

Where a provider already does the job, the package uses its native capability and writes nothing of its own. Each [Services](https://nuxt-backend.dev/docs/services) page lists what its provider does natively and what the package adds on top.

- **Credits are Polar's meters.** Balances, grants and usage live with the billing provider, and the package keeps a cache it can rebuild. There is no local ledger to reconcile.
- **Receipts, trial reminders and dunning are Polar's emails,** and the customer portal is Polar's, opened by a link.
- **Email preferences are Resend's topics,** lifecycle flows run on Resend's automations, and inbound mail is Resend's receiving.
- **Models go through the Convex AI Gateway,** which holds the provider credentials for your deployment.
- **Convex's own components come before code of its own.** Rate limiting, workflows, queues, migrations, aggregates and cached actions run on the official components. Your app imports them directly when it needs them.

When the package does write its own, the reason sits beside it. Feature flags, for one, must be read inside your own functions, which a hosted flag service cannot do ([Why flags are the package's own](https://nuxt-backend.dev/docs/ship/operate/flags#why-flags-are-the-packages-own)).

## Brand-neutral names

The public API says what a thing does, never which service does it: `useCredits`, `nuxt-backend/billing`, `<PricingTable>`, `BILLING_ACCESS_TOKEN`. Brands appear in prose only, to say what powers a capability. The variables the platform owns keep the platform's names (`CONVEX_DEPLOYMENT`). The package reads them and never asks you to write one.

Two verbs name every setup call. `setupX(components, options)` wires an integration and returns its helpers with `api`. `defineX(...)` declares data: the billing catalog, flags, search, an email sequence, a retention rule, a job queue.

## One way per action

Each job has one API. `useLoginFlow` is the only way to sign in, and `useAuth` only reads the session and signs out. `definePageMeta({ auth })` is the one page guard, `<Gate>` the one gate in a template, and `backend/functions.ts` calls `createFunctions` once for every access tier. Where two APIs once did the same thing, `0.2.0` keeps one.

## Workspaces, everywhere

A workspace is the unit that pays, holds members and owns data, one level deep. Every account gets a personal one, so a person working alone and a team run the same code. Every public name, label, error code, URL and CLI line says workspace: `useWorkspace`, `ctx.workspace`, `<WorkspaceSettings>`. Better Auth's organization plugin powers it, and its `organization` and `member` tables stay inside the backend component. Custom roles and ownership transfer wait for a later release ([Roadmap](https://nuxt-backend.dev/docs/start/roadmap)).

## Capabilities are detected, never switched

There is no option and no switch that turns a capability on. Every capability ships in the package and starts working once its env or its catalog exists, and its state comes from the env and `doctor`'s checks. So `npx nuxt-backend status`, DevTools, the health endpoint and the docs always agree with what is configured ([Capabilities](https://nuxt-backend.dev/docs/start/concepts/capabilities)).

## Real sandboxes in development

Development runs on each provider's own test mode. There are no simulators and no stand-in model:

- **Billing** runs in Polar's sandbox, with the test card `4242 4242 4242 4242`.
- **Email** runs in Resend's test mode. Its test addresses (`delivered@resend.dev` and its siblings) send real delivery webhooks, and `npx nuxt-backend inbox` reads what was sent.
- **AI** answers through the Convex AI Gateway, the same route production uses.
- **Sign-in codes** print in your terminal until email is connected.

A stand-in drifts from the real service, and its bugs are not production's bugs. Unit tests keep `nuxt-backend/test` and `createBackendMock`, so a test suite still needs no network ([Develop on real sandboxes](https://nuxt-backend.dev/docs/develop/sandboxes)).

## One environment name

`BACKEND_ENVIRONMENT` says what kind of deployment runs: `development`, `preview`, `sandbox` or `production`. `npx nuxt-backend env push` derives it from `CONVEX_DEPLOYMENT`, and every mode follows from it: email test mode, Polar's sandbox, trusted local origins, sign-in codes in the logs and the monitoring environment. You set `sandbox` on purpose, for a demo or staging app that runs in production mode on the providers' test modes ([Environments](https://nuxt-backend.dev/docs/start/concepts/environments)).

## Vercel first, not Vercel only

On Vercel the package takes what the platform gives: BotID's invisible bot check, the env Sentry's Vercel integration sets, and `npx nuxt-backend deploy`, which writes your app's Vercel env. Off Vercel every capability still works. A Turnstile challenge takes BotID's place, and `npx convex deploy --cmd` ships to any host that runs Nuxt ([Deploy](https://nuxt-backend.dev/docs/ship/deploy)).

## Headless-capable UI, no UI kit

The packaged pages and components work out of the box, and none of them depends on a UI library. Each one is a `.vue` component built in three layers you can peel apart:

- **Styled defaults.** Tokens (`--bk-*`) sit on `:root` inside the `@layer nuxt-backend` cascade layer, so any rule of yours wins without a specificity fight. State shows as `data-*` attributes (`data-state`, `data-loading`, `data-invalid`) you can style.
- **Headless composables.** Each component's logic is a composable that returns state, actions and attribute bindings. Your own markup keeps the focus handling, labels and live regions.
- **Your design system on top.** Use any component library next to the package, or none. Set the module's `css` option to `false`, and no package CSS loads at all.

The package meets WCAG 2.2 AA in its defaults, the bar the European Accessibility Act points to ([Accessibility](https://nuxt-backend.dev/docs/build/ui/accessibility)).

## Customize by climbing the ladder

Change only as much as you need, one rung at a time ([Customization ladder](https://nuxt-backend.dev/docs/build/ui/customize)):

1. **Mount** a packaged page or component as it is.
2. **Tokens** restyle it with CSS variables.
3. **Labels** change its words, in every language.
4. **Slots** replace a region inside it.
5. **Swap a part:** a component of yours with the part's name replaces it everywhere, packaged pages included.
6. **Headless composables** drive markup that is all yours.
7. **Eject** copies the part's source into your app with a version stamp, and `upgrade` shows what changed since.

Each rung leaves the ones below it working, so an upgrade keeps everything you did not touch.

## Edges fail closed

A webhook without its secret answers `503` instead of trusting its caller. An email that would not arrive is refused on the request rather than reported as sent. A guarded page is refused on the server before any of it renders. When something is not configured, the package says so and does less.

## Guardrails on growth features

The growth features ship with these rules as their defaults, and their pages link here ([Grow your app](https://nuxt-backend.dev/docs/build/growth) lists the features):

- **Sharing and invitations.** Share text discloses its incentive. The app never emails someone without an account on a user's behalf: people share their own link. Transactional notices carry no promotion.
- **Marketing email and consent.** Launch news goes only to people who opted into its topic, and each consent is recorded with the version of the text they agreed to. Every marketing email carries a one-click unsubscribe and a postal address, and stops after six months without engagement.
- **Prices and offers.** A promotion shows its real end date and the regular price, never a countdown that resets. A price test is disclosed to the people in it. A trial is lengthened by 30 days at most. A reward is never described as tax-free, and admission is never for sale.
- **Cancellation, deletion and contests.** Cancelling takes one step. A save offer, where you turn one on, is one optional step on the way out, and never stands between a person and the right to cancel. Deleting an account waits out a grace period the person can cancel. There are no sweepstakes.
- **Data.** Attribution travels in the link, with an explicit claim step and nothing stored on the device, and erasure reaches people without accounts too.

These defaults keep an app on the safe side. They are not legal advice: check them against the law where you sell ([Compliance](https://nuxt-backend.dev/docs/ship/compliance)).

## What it never does

- **No per-seat billing.** A plan is priced per workspace, and members are free: adding a teammate is never a billing event.
- **No passwords, social sign-in or magic links,** for the reasons [above](#email-codes-and-passkeys-only).
- **No teams inside a workspace.** Roles and a second workspace cover what teams would, with one level to reason about.
- **No money ledger.** Credits, gifts and rewards are units of service on the provider's meters, never money the app holds.
- **No auto top-up.** A balance grows when someone buys a pack, never by the app charging a card on its own.
- **No UI library dependency.** The package works beside any component library, and integrates none.

API keys and outgoing webhooks are not on this list: they arrive with the service-app release ([Roadmap](https://nuxt-backend.dev/docs/start/roadmap)).

## What this means for you

- Choosing the package? [Choosing nuxt-backend](https://nuxt-backend.dev/docs/start/concepts/choosing) compares it with the alternatives, and the [Feature map](https://nuxt-backend.dev/docs/start/feature-map) lists what it does.
- Building on it: the [Customization ladder](https://nuxt-backend.dev/docs/build/ui/customize) for the UI, [Auth](https://nuxt-backend.dev/docs/build/auth) for the account model, and [Billing](https://nuxt-backend.dev/docs/build/billing) for what the provider does.
- Connecting services: the [Service map](https://nuxt-backend.dev/docs/services) says what each provider does natively and what the package adds.
- Need something on this page anyway? Build it beside the package with its composables and setup helpers, or [open a discussion](https://github.com/qruto/nuxt-backend/discussions) with the case.


## Sitemap

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