Auth for your app
Use Foir as the authentication layer for your app — hosted sign-in, user accounts, sessions, and roles — without touching the CMS. You get a login screen your users can sign in to today, EdDSA access tokens your backend can verify, and user data that is isolated per project at the database layer.
This track is for teams who want an auth provider (the way you’d reach for Clerk, Auth0, or Better Auth), not a content platform. Everything here works whether or not you ever define a single content model.
What you get
- Hosted sign-in on your own
login.your-domain.com, or Foir’s: Foir renders the page, and your app gets the tokens back. See Hosted sign-in. - Password, OTP, and OAuth/OIDC sign-in, plus user accounts with per-user profile and metadata.
- An account page for your users. Their name, picture and language; where they are signed in, and signing out of one session or of all of them; the providers they sign in with; the apps they have authorised; personal access tokens; their second factors and recovery codes; and closing the account. Each is the user’s own and asks no permission. See Your users’ account page.
- Short-lived EdDSA access tokens (15 minutes) and rotating refresh tokens (30 days), verifiable from your backend against a public JWKS — see User Authentication.
- Database-level isolation. User-owned rows are protected by row-level security keyed to the signed-in user, not by application checks you have to remember to write. See Authorization.
- Lifecycle webhooks —
USER_CREATED,USER_UPDATED,USER_DELETEDand the session events. A hook carries no URL of its own: you define an operation with the endpoint, and attach a hook that names it. See Webhooks and Hook Events. - Usage-based billing you can see — monthly active users, team seats, and auth email sends, metered and surfaced in the dashboard. See How auth is billed.
Four ways to integrate
Pick the shape that fits your app. All four return the same user tokens.
| Approach | You build | Best for |
|---|---|---|
| Hosted sign-in | A redirect and a callback route | Most apps: no sign-in page to build or maintain |
| Token API | Your own sign-in form calling signIn / register / OTP | Apps that want a fully custom sign-in UI |
| First-party sessions | The server that renders your pages keeps the user’s tokens and sets its own HttpOnly cookie | Apps with a server that want cookie sessions, not bearer tokens |
| Foir-hosted sessions | Nothing — Foir sets the cookie on your domain | Backend-less SPAs that still want no tokens in JavaScript |
The hosted flow is the recommended default: you register your app once, add a redirect and a callback, and Foir hosts everything in between. Start with the Quickstart.
The last two give the strongest posture: no access or refresh token is ever reachable from JavaScript. Use Foir-hosted sessions if you have no server (it needs a custom login domain); hold the session on your own server if you have one.
Where to go next
- Quickstart — add login to your app in about ten minutes.
- SPA (no backend) — cookie sessions for a Vite/CRA app with no server.
- React & Next.js — drop-in components, hooks, and the Next.js server adapter.
- How auth is billed — what an MAU, a seat, and an email send cost against your plan.
- Migrating to Foir — bring users over from Clerk or Better Auth.
- Hosted sign-in: the full reference.
- First-Party Sessions: the cookie-session patterns, with or without a server.