Auth starter
Its files are in ext/pages/starters/auth. See every starter kit.


Multi-page app (MPA) auth with the built-in auth plugin: register, password, anonymous, OTP and OAuth2 login, logout, email verification (with a resend page), password reset by email, email change with confirmation, and a protected /account section (account/+middleware.ts). Sessions are a pb_auth cookie managed through ctx.session.*; the logged-in user is ctx.auth. The included migrations point PocketBase's mail at a local maildev and its email templates at this app's /auth/confirm/{TOKEN}/... pages.
Templates are .ets (EJS whose tags hold TypeScript) and code files (+config, +middleware, and the .ts beside a page or serving an endpoint) are .ts; Pages strips the types when it loads them, so there is still no build step.
pocketone pages create myapp --starter auth
cd myapp
pocketone superuser upsert [email protected] <password> --dir ./pb_data
pocketone serve --dir ./pb_data
Then open http://127.0.0.1:8090.
In another terminal, run a local mail catcher for verification, OTP, password reset and email change emails (the migrations send mail to localhost:1025; maildev's web UI is at http://localhost:1080):
npx maildev
Notes:
- Anonymous login needs password login enabled (PocketBase's default).
- OTP login is enabled by the migrations. OAuth2 is enabled with no providers: add one in the dashboard under Collections > users > Options > OAuth2.
Files
pb_migrations/ the users collection's auth settings and email templates
pb_pages/
+config.ts turns on the auth plugin
+layout.ets
auth/login/ index.ts signs in; _private/ holds one form per method (password, otp, oauth2, ...)
auth/forgot/ asks for a password reset email
auth/confirm/[token]/ the pages the emails link to: verification, password reset, email change
account/+middleware.ts sends anyone not signed in to the login page
account/ the signed-in user's page, and change-email
Live demo: pocketpages-auth.pockethost.io.
Questions and comments
Comments are a GitHub Discussions thread; sign in with GitHub to post.