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.

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:

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:

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).

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 AuthAdded by the package
Email codes, passkeys and sessionssetupAuth, 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 hookscanSignIn 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 tablesExport, 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

  1. Wire. The scaffold's backend/auth.ts calls setupAuth, which connects email, rate limits, the activity trail, erasure and your hooks (Auth setup).
  2. Open the doors. Launch in phases, a waitlist, then invites, then everyone (Launch in phases).
  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).
  4. Protect. definePageMeta({ auth }) guards pages, and the tiers guard every function you build with them (Access).
  5. Manage. People edit their profile at /profile, their passkeys, devices and data at /security, and their workspaces at /settings (Accounts, Workspaces).
  6. 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 dev console, 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_SECRET and SITE_URL are required on the deployment, EMAIL_* delivers the codes (Resend), and a bot check guards each code request (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).

Start here

Sign users in

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

Launch in phases

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

Protect pages and routes

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

Create and switch workspaces

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

Every page

Set up

  • Auth setup: the scaffolded files, everything setupAuth takes and returns, and the auth route.

Sign-in

  • Sign users in: useLoginFlow, <AuthForm>, passkey autofill and useAuth, 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, verifyHuman for 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, onUserDeleted and Better Auth hooks of your own.

Access

Accounts

Workspaces

Admin

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.