---
title: "Auth, accounts and workspaces"
description: "Who a person is and what they may do: sign-in with sign-in codes and passkeys, launch phases with a waitlist and invites, protected pages and functions, roles, accounts with export, deletion and consents, workspaces with members and invitations, and an admin console."
canonical_url: "https://nuxt-backend.dev/docs/build/auth"
---
# Auth, accounts and workspaces

> Who a person is and what they may do: sign-in with sign-in codes and passkeys, launch phases with a waitlist and invites, protected pages and functions, roles, accounts with export, deletion and consents, workspaces with members and invitations, and an admin console.

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

- [Try it live in the playground](https://nuxt-backend.dev/login)
- [API reference](https://nuxt-backend.dev/docs/reference/api/auth)
- [Source](https://github.com/qruto/nuxt-backend/blob/main/src/convex/client/index.ts)

The `auth` capability answers two questions for every request: who is this, and what may they do. People sign in with a code sent to their email, or with a passkey, and nothing else: no passwords, no social sign-in and no magic links ([Email codes and passkeys only](https://nuxt-backend.dev/docs/start/concepts/principles#email-codes-and-passkeys-only)). Your pages and Convex functions each declare who may use them, in one line. People manage and erase their own accounts, and share workspaces. You run it all from an admin console at `/admin`.

It is the `auth` [capability](https://nuxt-backend.dev/docs/start/concepts/capabilities): the part of the package every app runs, always on.

## Your first protected page

The scaffold already mounts `/login`, `/profile`, `/security`, `/settings` and `/admin`. In development, the sign-in code prints in your `convex dev` console. Guard a page with one line:

```vue [app/pages/studio.vue]
<script setup lang="ts">
definePageMeta({ auth: true })

const { user } = useAuth()
</script>

<template>
  <p>Welcome back, {{ user?.name }}.</p>
</template>
```

And a function with one builder, the `authed` tier, which refuses anyone signed out before your handler runs:

```ts [backend/strips.ts]
import { authed } from './functions'

export const mine = authed.query({
  args: {},
  handler: async ctx => ctx.db.query('strips')
    .withIndex('authorId', q => q.eq('authorId', ctx.user.id))
    .take(50),
})
```

A **tier** is one of these builders: `authed`, `workspace`, `admin` and two more, each a drop-in for Convex's `query`, `mutation` and `action` ([Protect backend functions](https://nuxt-backend.dev/docs/build/auth/access/functions)).

## What powers it

[Better Auth](https://www.better-auth.com) runs inside your Convex deployment, in the package's `backend` component. Accounts, sessions and workspaces live next to your data, with no auth service in between. The package composes Better Auth's own plugins, and adds what a client app needs on top:

<table>
<thead>
  <tr>
    <th>
      Native to Better Auth
    </th>
    
    <th>
      Added by the package
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      Email codes, passkeys and sessions
    </td>
    
    <td>
      <code>
        setupAuth
      </code>
      
      , which the scaffold calls for you, <code>
        useLoginFlow
      </code>
      
      , <code>
        <AuthForm>
      </code>
      
       at <code>
        /login
      </code>
      
      , passkey autofill, codes bound to the browser that asked, the passkey offer, the WebAuthn Signal API and passkey-only accounts with a recovery code
    </td>
  </tr>
  
  <tr>
    <td>
      Sign-in and sign-up hooks
    </td>
    
    <td>
      <code>
        canSignIn
      </code>
      
       and the lifecycle hooks, launch phases, invite codes, access links and a verified waitlist
    </td>
  </tr>
  
  <tr>
    <td>
      Roles, bans and impersonation (the admin plugin)
    </td>
    
    <td>
      Roles on the session token, page rules, function tiers, a recent sign-in for sensitive actions, the admin console with tabs of your own and a reports queue
    </td>
  </tr>
  
  <tr>
    <td>
      Workspaces, members and invitations (the organization plugin)
    </td>
    
    <td>
      A personal workspace for everyone, the active workspace carried on the session token, <code>
        useWorkspace
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      Account and session tables
    </td>
    
    <td>
      Export, deletion after a grace period with an erasure that reaches every provider, the activity trail, new-device alerts, consents, a consent manager for optional storage, a minimum age
    </td>
  </tr>
</tbody>
</table>

The **active workspace** is the one a person works in right now. Every account has at least one, its personal workspace.

## How it fits together

1. **Wire.** The scaffold's `backend/auth.ts` calls `setupAuth`, which connects email, rate limits, the activity trail, erasure and your hooks ([Auth setup](https://nuxt-backend.dev/docs/build/auth/setup)).
2. **Open the doors.** Launch in phases, a waitlist, then invites, then everyone ([Launch in phases](https://nuxt-backend.dev/docs/build/growth/launch)).
3. **Sign in.** `/login` renders `<AuthForm>` on `useLoginFlow()`: a code, then a passkey for next time. The first sign-in creates the account and a personal workspace ([Sign users in](https://nuxt-backend.dev/docs/build/auth/sign-in)).
4. **Protect.** `definePageMeta({ auth })` guards pages, and the tiers guard every function you build with them ([Access](https://nuxt-backend.dev/docs/build/auth/access)).
5. **Manage.** People edit their profile at `/profile`, their passkeys, devices and data at `/security`, and their workspaces at `/settings` ([Accounts](https://nuxt-backend.dev/docs/build/auth/accounts), [Workspaces](https://nuxt-backend.dev/docs/build/auth/workspaces)).
6. **Run it.** Administrators use `/admin`: every account and workspace, the activity trail, the launch phase and the waitlist ([Run the admin console](https://nuxt-backend.dev/docs/build/auth/admin)).

## In development and in production

- **On your machine.** The code prints in the `convex dev` console, and Resend's test addresses receive real emails you read in the [dev inbox](https://nuxt-backend.dev/docs/develop/dev-inbox). The bot check lets every request through, as Vercel's BotID does in development ([Develop with real sandboxes](https://nuxt-backend.dev/docs/develop/sandboxes)).
- **In production.** `AUTH_SECRET` and `SITE_URL` are required on the deployment, `EMAIL_*` delivers the codes ([Resend](https://nuxt-backend.dev/docs/services/resend)), and a bot check guards each code request ([Bot protection](https://nuxt-backend.dev/docs/services/bot-protection)). Make the first administrator with `npx nuxt-backend doctor --fix`.
- **Its state.** `npx nuxt-backend status` and DevTools show the capability's state, and `npx nuxt-backend doctor --only auth` names what is missing ([the `auth` findings](https://nuxt-backend.dev/docs/reference/cli/diagnostics#auth)).

## Start here

<card-group>
<card icon="i-lucide-log-in" title="Sign users in" to="https://nuxt-backend.dev/docs/build/auth/sign-in">

Codes and passkeys with `useLoginFlow`, passkey autofill, and the session in your pages.

</card>

<card icon="i-lucide-door-open" title="Launch in phases" to="https://nuxt-backend.dev/docs/build/growth/launch">

Early access with a waitlist, then invite only, then public.

</card>

<card icon="i-lucide-lock-keyhole" title="Protect pages and routes" to="https://nuxt-backend.dev/docs/build/auth/access/pages">

`definePageMeta({ auth })` with roles, workspaces and plan features.

</card>

<card icon="i-lucide-users" title="Create and switch workspaces" to="https://nuxt-backend.dev/docs/build/auth/workspaces">

The personal workspace, the active one on the token, and `useWorkspace`.

</card>
</card-group>

## Every page

**Set up**

- [Auth setup](https://nuxt-backend.dev/docs/build/auth/setup): the scaffolded files, everything `setupAuth` takes and returns, and the auth route.

**Sign-in**

- [Sign users in](https://nuxt-backend.dev/docs/build/auth/sign-in): `useLoginFlow`, `<AuthForm>`, passkey autofill and `useAuth`, plus browser-bound codes, the passkey offer and passkey-only accounts.
- [Build a custom sign-in page](https://nuxt-backend.dev/docs/build/auth/sign-in/custom-page): your own `/login`, with `?redirect=` and autofill kept.
- [Stop bots](https://nuxt-backend.dev/docs/build/auth/sign-in/bots): BotID on Vercel, a challenge elsewhere, `verifyHuman` for your own calls.
- [Launch in phases](https://nuxt-backend.dev/docs/build/growth/launch): early access, invite only and public, and the tickets that admit a new address.
- [Hook into sign-in and sign-up](https://nuxt-backend.dev/docs/build/auth/sign-in/hooks): `canSignIn`, `onUserCreated`, `onUserDeleted` and Better Auth hooks of your own.

**Access**

- [Protect pages and routes](https://nuxt-backend.dev/docs/build/auth/access/pages): page rules, the 403 and the 404, when a session ends, and server routes.
- [Protect backend functions](https://nuxt-backend.dev/docs/build/auth/access/functions): the `authed`, `workspace`, `admin`, `withRole` and `withFeature` tiers.
- [Give people roles](https://nuxt-backend.dev/docs/build/auth/access/roles): app-wide roles and workspace roles, and where each is checked.
- [Require a recent sign-in](https://nuxt-backend.dev/docs/build/auth/access/step-up): "Confirm it's you" before sensitive actions.

**Accounts**

- [Let users edit their profile](https://nuxt-backend.dev/docs/build/auth/accounts/profile): name, avatar, language and a new email address.
- [Manage passkeys and sessions](https://nuxt-backend.dev/docs/build/auth/accounts/security): `/security`, its devices, its recent activity, and passkey-only.
- [Export and delete an account](https://nuxt-backend.dev/docs/build/auth/accounts/data): one export of everything, and a deletion with a grace period that erases the person at every provider.
- [Record consents](https://nuxt-backend.dev/docs/build/auth/accounts/consents): terms, privacy and opt-ins by version, the consent manager for optional storage, and a minimum age.
- [Alert people to new sign-ins](https://nuxt-backend.dev/docs/build/auth/accounts/alerts): a notice when a new device signs in.

**Workspaces**

- [Create and switch workspaces](https://nuxt-backend.dev/docs/build/auth/workspaces): the personal workspace, `useWorkspace` and `/settings`.
- [Invite people to a workspace](https://nuxt-backend.dev/docs/build/auth/workspaces/invitations): the invitation flow end to end.
- [Manage members](https://nuxt-backend.dev/docs/build/auth/workspaces/members): the members list, built-in roles and removal.

**Admin**

- [Run the admin console](https://nuxt-backend.dev/docs/build/auth/admin): the first administrator, then `/admin`.
- [Impersonation](https://nuxt-backend.dev/docs/build/auth/admin/impersonation): why administrators act only through a short, recorded visit.
- [Record and review activity](https://nuxt-backend.dev/docs/build/auth/admin/audit-log): the activity trail, and events of your own on it.
- [Add your own admin tabs](https://nuxt-backend.dev/docs/build/auth/admin/custom-tabs): your team's tools inside the console.

The launch, waitlist, revenue and growth tabs of the console are covered under [Grow your app](https://nuxt-backend.dev/docs/build/growth).

The emails sign-in sends, from the code to the invitation, are covered under [Templates](https://nuxt-backend.dev/docs/build/email/templates). Content people report is reviewed in the console's [Reports tab](https://nuxt-backend.dev/docs/build/auth/admin#review-reports), set up in [Keep content safe](https://nuxt-backend.dev/docs/build/ai/content-safety#review-reports).

## What you get

What the package ships for this part of the app today, generated from the code. Each name links to its reference entry.

- Pages: [`/accept-invitation`](https://nuxt-backend.dev/docs/reference/backend/http-routes#in-the-nuxt-app), [`/admin`](https://nuxt-backend.dev/docs/reference/backend/http-routes#in-the-nuxt-app), [`/invite`](https://nuxt-backend.dev/docs/reference/backend/http-routes#in-the-nuxt-app), [`/account/keep`](https://nuxt-backend.dev/docs/reference/backend/http-routes#in-the-nuxt-app), [`/login`](https://nuxt-backend.dev/docs/reference/backend/http-routes#in-the-nuxt-app), [`/profile`](https://nuxt-backend.dev/docs/reference/backend/http-routes#in-the-nuxt-app), [`/security`](https://nuxt-backend.dev/docs/reference/backend/http-routes#in-the-nuxt-app), [`/settings`](https://nuxt-backend.dev/docs/reference/backend/http-routes#in-the-nuxt-app), [`/waitlist`](https://nuxt-backend.dev/docs/reference/backend/http-routes#in-the-nuxt-app), [`/welcome`](https://nuxt-backend.dev/docs/reference/backend/http-routes#in-the-nuxt-app)
- Components: [`<AuthForm>`](https://nuxt-backend.dev/docs/reference/components/account#authform), [`<WaitlistForm>`](https://nuxt-backend.dev/docs/reference/components/account#waitlistform), [`<ReauthenticateDialog>`](https://nuxt-backend.dev/docs/reference/components/account#reauthenticatedialog), [`<ProfileSettings>`](https://nuxt-backend.dev/docs/reference/components/account#profilesettings), [`<SecuritySettings>`](https://nuxt-backend.dev/docs/reference/components/account#securitysettings), [`<ConsentPrompt>`](https://nuxt-backend.dev/docs/reference/components/account#consentprompt), [`<OnboardingFlow>`](https://nuxt-backend.dev/docs/reference/components/account#onboardingflow), [`<ActivationChecklist>`](https://nuxt-backend.dev/docs/reference/components/account#activationchecklist), [`<HowDidYouHear>`](https://nuxt-backend.dev/docs/reference/components/account#howdidyouhear), [`<AccountData>`](https://nuxt-backend.dev/docs/reference/components/account#accountdata), [`<WorkspaceSettings>`](https://nuxt-backend.dev/docs/reference/components/workspaces#workspacesettings), [`<AcceptInvitation>`](https://nuxt-backend.dev/docs/reference/components/workspaces#acceptinvitation), [`<AuditLog>`](https://nuxt-backend.dev/docs/reference/components/workspaces#auditlog), [`<AdminUsers>`](https://nuxt-backend.dev/docs/reference/components/workspaces#adminusers), [`<AdminWorkspaces>`](https://nuxt-backend.dev/docs/reference/components/workspaces#adminworkspaces), [`<AccessDenied>`](https://nuxt-backend.dev/docs/reference/components/shell#accessdenied)
- Composables: [`useAuth`](https://nuxt-backend.dev/docs/reference/api/use-auth), [`useLoginFlow`](https://nuxt-backend.dev/docs/reference/api/use-login-flow), [`useEmailChange`](https://nuxt-backend.dev/docs/reference/api/use-email-change), [`useWorkspace`](https://nuxt-backend.dev/docs/reference/api/use-workspace), [`useReferralAdmin`](https://nuxt-backend.dev/docs/reference/nuxt/composables#at-a-glance), [`usePasskeys`](https://nuxt-backend.dev/docs/reference/api/use-passkeys), [`useTwoFactor`](https://nuxt-backend.dev/docs/reference/nuxt/composables#at-a-glance), [`useSessions`](https://nuxt-backend.dev/docs/reference/api/use-sessions), [`useSignInAlerts`](https://nuxt-backend.dev/docs/reference/nuxt/composables#at-a-glance), [`useReauthentication`](https://nuxt-backend.dev/docs/reference/api/use-reauthentication), [`useAuditLog`](https://nuxt-backend.dev/docs/reference/api/use-audit-log), [`useAccount`](https://nuxt-backend.dev/docs/reference/api/use-account), [`useConsents`](https://nuxt-backend.dev/docs/reference/nuxt/composables#at-a-glance), [`useAdmin`](https://nuxt-backend.dev/docs/reference/api/use-admin), [`useAccessPhase`](https://nuxt-backend.dev/docs/reference/api/use-access), [`useInvite`](https://nuxt-backend.dev/docs/reference/api/use-access), [`useMemberTicket`](https://nuxt-backend.dev/docs/reference/api/use-access), [`useAccessAdmin`](https://nuxt-backend.dev/docs/reference/api/use-access), [`useWaitlist`](https://nuxt-backend.dev/docs/reference/api/use-waitlist), [`useWaitlistAdmin`](https://nuxt-backend.dev/docs/reference/api/use-waitlist-admin), [`useOnboarding`](https://nuxt-backend.dev/docs/reference/nuxt/composables#at-a-glance), [`useActivation`](https://nuxt-backend.dev/docs/reference/nuxt/composables#at-a-glance), [`useReturnPath`](https://nuxt-backend.dev/docs/reference/nuxt/composables#at-a-glance), [`useHumanCheck`](https://nuxt-backend.dev/docs/reference/api/use-human-check)
- Nitro auto-imports: [`backendAuth`](https://nuxt-backend.dev/docs/reference/nuxt/server-utilities)
- Routes: [`/api/auth`](https://nuxt-backend.dev/docs/reference/backend/http-routes), [`/api/human-proof`](https://nuxt-backend.dev/docs/reference/backend/http-routes)
- Setup helpers: [`setupAuth`](https://nuxt-backend.dev/docs/reference/api/auth), [`createFunctions`](https://nuxt-backend.dev/docs/reference/api/functions), [`defineActivation`](https://nuxt-backend.dev/docs/reference/api/audit), [`setupAudit`](https://nuxt-backend.dev/docs/reference/api/audit), [`setupAccess`](https://nuxt-backend.dev/docs/reference/api/access), [`setupWaitlist`](https://nuxt-backend.dev/docs/reference/api/access), [`setupAccount`](https://nuxt-backend.dev/docs/reference/api/account), [`setupAdmin`](https://nuxt-backend.dev/docs/reference/api/admin), [`defineBackendAuthConfig`](https://nuxt-backend.dev/docs/reference/api/auth-config)
- Environment variables: [`AUTH_SECRET`](https://nuxt-backend.dev/docs/reference/configuration/environment-variables#every-variable), [`SITE_URL`](https://nuxt-backend.dev/docs/reference/configuration/environment-variables#every-variable), [`PROTECTION_PROOF_SECRET`](https://nuxt-backend.dev/docs/reference/configuration/environment-variables#every-variable), [`PROTECTION_CHALLENGE_SECRET_KEY`](https://nuxt-backend.dev/docs/reference/configuration/environment-variables#every-variable), [`NUXT_PUBLIC_BACKEND_CHALLENGE_SITE_KEY`](https://nuxt-backend.dev/docs/reference/configuration/environment-variables#every-variable)
- Findings: [`auth-secret`](https://nuxt-backend.dev/docs/reference/cli/diagnostics#auth-secret), [`site-url`](https://nuxt-backend.dev/docs/reference/cli/diagnostics#site-url), [`deployment-auth-secret`](https://nuxt-backend.dev/docs/reference/cli/diagnostics#deployment-auth-secret), [`deployment-site-url`](https://nuxt-backend.dev/docs/reference/cli/diagnostics#deployment-site-url), [`site-url-origin`](https://nuxt-backend.dev/docs/reference/cli/diagnostics#site-url-origin), [`site-gated-page`](https://nuxt-backend.dev/docs/reference/cli/diagnostics#site-gated-page), [`site-auth-proxy`](https://nuxt-backend.dev/docs/reference/cli/diagnostics#site-auth-proxy), [`consent-urls`](https://nuxt-backend.dev/docs/reference/cli/diagnostics#consent-urls), [`admin-bootstrap`](https://nuxt-backend.dev/docs/reference/cli/diagnostics#admin-bootstrap), [`page-paths`](https://nuxt-backend.dev/docs/reference/cli/diagnostics#page-paths), [`auth-provider`](https://nuxt-backend.dev/docs/reference/cli/diagnostics#auth-provider), [`bot-protection`](https://nuxt-backend.dev/docs/reference/cli/diagnostics#bot-protection), [`protection-proof`](https://nuxt-backend.dev/docs/reference/cli/diagnostics#protection-proof), [`protection-challenge-keys`](https://nuxt-backend.dev/docs/reference/cli/diagnostics#protection-challenge-keys), [`waitlist-bot-check`](https://nuxt-backend.dev/docs/reference/cli/diagnostics#waitlist-bot-check), [`contact-bot-check`](https://nuxt-backend.dev/docs/reference/cli/diagnostics#contact-bot-check), [`protection-guest-jobs`](https://nuxt-backend.dev/docs/reference/cli/diagnostics#protection-guest-jobs), [`deployment-protection-proof-secret`](https://nuxt-backend.dev/docs/reference/cli/diagnostics#deployment-protection-proof-secret), [`deployment-protection-challenge-secret-key`](https://nuxt-backend.dev/docs/reference/cli/diagnostics#deployment-protection-challenge-secret-key)

## Not built yet

These wait for a later release ([Roadmap](https://nuxt-backend.dev/docs/start/roadmap)):

- roles a workspace owner defines, and billing as a permission inside them;
- moving a workspace to another owner;
- shareable links into a workspace;
- API keys, and an MCP endpoint for your users' agents, on OAuth with the device grant;
- sessions bound to the device (Device Bound Session Credentials), which only Chrome on Windows ships so far.


## Sitemap

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