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). 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: 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:
<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:
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).
What powers it
Better Auth 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:
| Native to Better Auth | Added by the package |
|---|---|
| Email codes, passkeys and sessions | setupAuth, which the scaffold calls for you, useLoginFlow, <AuthForm> at /login, passkey autofill, codes bound to the browser that asked, the passkey offer, the WebAuthn Signal API and passkey-only accounts with a recovery code |
| Sign-in and sign-up hooks | canSignIn and the lifecycle hooks, launch phases, invite codes, access links and a verified waitlist |
| Roles, bans and impersonation (the admin plugin) | 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 |
| Workspaces, members and invitations (the organization plugin) | A personal workspace for everyone, the active workspace carried on the session token, useWorkspace |
| Account and session tables | 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 |
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
- Wire. The scaffold's
backend/auth.tscallssetupAuth, which connects email, rate limits, the activity trail, erasure and your hooks (Auth setup). - Open the doors. Launch in phases, a waitlist, then invites, then everyone (Launch in phases).
- Sign in.
/loginrenders<AuthForm>onuseLoginFlow(): a code, then a passkey for next time. The first sign-in creates the account and a personal workspace (Sign users in). - Protect.
definePageMeta({ auth })guards pages, and the tiers guard every function you build with them (Access). - Manage. People edit their profile at
/profile, their passkeys, devices and data at/security, and their workspaces at/settings(Accounts, Workspaces). - Run it. Administrators use
/admin: every account and workspace, the activity trail, the launch phase and the waitlist (Run the admin console).
In development and in production
- On your machine. The code prints in the
convex devconsole, and Resend's test addresses receive real emails you read in the dev inbox. The bot check lets every request through, as Vercel's BotID does in development (Develop with real sandboxes). - In production.
AUTH_SECRETandSITE_URLare required on the deployment,EMAIL_*delivers the codes (Resend), and a bot check guards each code request (Bot protection). Make the first administrator withnpx nuxt-backend doctor --fix. - Its state.
npx nuxt-backend statusand DevTools show the capability's state, andnpx nuxt-backend doctor --only authnames what is missing (theauthfindings).
Start here
Every page
Set up
- Auth setup: the scaffolded files, everything
setupAuthtakes and returns, and the auth route.
Sign-in
- Sign users in:
useLoginFlow,<AuthForm>, passkey autofill anduseAuth, plus browser-bound codes, the passkey offer and passkey-only accounts. - Build a custom sign-in page: your own
/login, with?redirect=and autofill kept. - Stop bots: BotID on Vercel, a challenge elsewhere,
verifyHumanfor your own calls. - Launch in phases: early access, invite only and public, and the tickets that admit a new address.
- Hook into sign-in and sign-up:
canSignIn,onUserCreated,onUserDeletedand Better Auth hooks of your own.
Access
- Protect pages and routes: page rules, the 403 and the 404, when a session ends, and server routes.
- Protect backend functions: the
authed,workspace,admin,withRoleandwithFeaturetiers. - Give people roles: app-wide roles and workspace roles, and where each is checked.
- Require a recent sign-in: "Confirm it's you" before sensitive actions.
Accounts
- Let users edit their profile: name, avatar, language and a new email address.
- Manage passkeys and sessions:
/security, its devices, its recent activity, and passkey-only. - Export and delete an account: one export of everything, and a deletion with a grace period that erases the person at every provider.
- Record consents: terms, privacy and opt-ins by version, the consent manager for optional storage, and a minimum age.
- Alert people to new sign-ins: a notice when a new device signs in.
Workspaces
- Create and switch workspaces: the personal workspace,
useWorkspaceand/settings. - Invite people to a workspace: the invitation flow end to end.
- Manage members: the members list, built-in roles and removal.
Admin
- Run the admin console: the first administrator, then
/admin. - Impersonation: why administrators act only through a short, recorded visit.
- Record and review activity: the activity trail, and events of your own on it.
- Add your own admin tabs: your team's tools inside the console.
The launch, waitlist, revenue and growth tabs of the console are covered under Grow your app.
The emails sign-in sends, from the code to the invitation, are covered under Templates. Content people report is reviewed in the console's Reports tab, set up in Keep content safe.
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/admin/invite/account/keep/login/profile/security/settings/waitlist/welcome
- Components
- <AuthForm><WaitlistForm><ReauthenticateDialog><ProfileSettings><SecuritySettings><ConsentPrompt><OnboardingFlow><ActivationChecklist><HowDidYouHear><AccountData><WorkspaceSettings><AcceptInvitation><AuditLog><AdminUsers><AdminWorkspaces><AccessDenied>
- Composables
- useAuthuseLoginFlowuseEmailChangeuseWorkspaceuseReferralAdminusePasskeysuseTwoFactoruseSessionsuseSignInAlertsuseReauthenticationuseAuditLoguseAccountuseConsentsuseAdminuseAccessPhaseuseInviteuseMemberTicketuseAccessAdminuseWaitlistuseWaitlistAdminuseOnboardinguseActivationuseReturnPathuseHumanCheck
- Nitro auto-imports
- backendAuth
- Routes
- /api/auth/api/human-proof
- Setup helpers
- setupAuthcreateFunctionsdefineActivationsetupAuditsetupAccesssetupWaitlistsetupAccountsetupAdmindefineBackendAuthConfig
- Environment variables
- AUTH_SECRETSITE_URLPROTECTION_PROOF_SECRETPROTECTION_CHALLENGE_SECRET_KEYNUXT_PUBLIC_BACKEND_CHALLENGE_SITE_KEY
- Findings
- auth-secretsite-urldeployment-auth-secretdeployment-site-urlsite-url-originsite-gated-pagesite-auth-proxyconsent-urlsadmin-bootstrappage-pathsauth-providerbot-protectionprotection-proofprotection-challenge-keyswaitlist-bot-checkcontact-bot-checkprotection-guest-jobsdeployment-protection-proof-secretdeployment-protection-challenge-secret-key
Not built yet
These wait for a later release (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.
Overview
The seven groups you build a client app from, auth and accounts, billing, email and notifications, AI, data and files, growth, and the UI, and the capabilities each one covers.
Auth setup
The scaffolded backend/auth.ts and http.ts, everything setupAuth takes and returns, how it connects email, rate limits, the activity trail, erasure and launch phases, and the auth route.