Behind the screen

Auth and identity

Auth covers two jobs. Authentication checks who someone is, with a password, a code, a passkey or a Google account. Authorisation then decides what that person may do, such as editing their own orders but not anyone else's. Almost every app with accounts needs both, and a mistake in either can expose other people's data.

The pieces stack up in layers. A sign-in method proves identity once; a session or token keeps the person signed in afterwards; roles and database rules decide what each request may touch. Protocols such as OAuth and OpenID Connect let one service vouch for a user to another, and providers such as Supabase Auth, Firebase Authentication, Clerk, Auth.js and Auth0 package it all, so few apps build it from scratch.

17 terms · 3 comparisons · prices checked September 2026

17 terms, click any to open

Basics

Authentication and authorization

Concept
Authentication checks who someone is, for example with a password or a passkey. Authorisation then decides what that person may see and do, such as editing their own posts but not anyone else's.

Authentication (AuthN for short) answers 'who are you?'. It happens at sign-in, using something the person knows (a password), has (a phone or security key) or is (a fingerprint), and ends with the app issuing a session or token that carries the answer to later requests. Authorisation (AuthZ) answers 'what may you do?' and runs on every request: may this user read this invoice, delete this project, open the admin page?

The two fail in different ways. Broken sign-in lets a stranger in; a missing authorisation check lets a real, signed-in user read other people's data, which is why broken access control sits at the top of the OWASP Top 10. Checks belong on the server or in the database, because anything enforced only by hiding it in the interface can be bypassed. HTTP status codes mirror the split: 401 means 'not signed in' and 403 means 'signed in, but not allowed'.

Also called: AuthN, AuthZ, authorisation, access control, login, sign-in

Open Authentication and authorization as a page

Roles and permissions (RBAC)

Pattern
A way to manage who can do what by giving each user one or more roles, such as admin, editor or viewer, and giving each role a fixed set of permissions.

Instead of granting abilities person by person, RBAC groups them: the 'editor' role may create and edit posts, the 'viewer' role may only read, and each user gets the roles that fit their job. Changing what editors can do then means changing one role rather than hundreds of accounts. Roles are often scoped to a team or workspace, so the same person can be an admin in one organisation and a viewer in another.

Enforcement belongs on the server. A backend checks the role before acting, reading it from a table or from custom claims in the user's token, and a database can enforce it directly: PostgreSQL row level security policies can compare the user's id and role with each row. Hiding a button in the app is only cosmetic. When rules depend on relationships or attributes (the owner of this document, members of this project), finer models take over: attribute-based (ABAC) and relationship-based (ReBAC) access control, with tools such as OpenFGA.

Also called: RBAC, role-based access control, permissions, user roles, admin roles

Open Roles and permissions (RBAC) as a page

Single sign-on (SSO)

Concept
One sign-in that works across many apps, so staff log in once with their company account and get into every tool their employer has connected.

With SSO, an app stops checking passwords itself and trusts an identity provider (IdP) such as Okta, Microsoft Entra ID or Google Workspace. The app sends the user to the IdP, the IdP signs them in with its own password rules, 2FA and device checks, and returns a signed statement of who they are. Two standards carry that statement: SAML 2.0, an older XML format still common in enterprises, and OpenID Connect, its modern JSON and JWT based counterpart.

For a company, SSO means one place to enforce security and one switch that removes a leaver's access everywhere, often paired with SCIM, which creates and deletes accounts in each app automatically. For a software vendor it is usually the feature that unlocks business customers, which is why many products reserve it for their top plan, a habit nicknamed the 'SSO tax'. 'Sign in with Google' on a consumer site is the same idea on a smaller scale.

Also called: SSO, SAML, SAML 2.0, enterprise SSO, identity provider, IdP

Open Single sign-on (SSO) as a page

Ways to sign in

One-time passwords (OTP)

PatternPay as you go
A short code, usually six digits, that works once and expires within minutes. It is sent by SMS or email, or generated by an authenticator app, to prove a person controls that phone, inbox or device.

There are two families. Sent codes are created by the server, delivered by SMS, email or WhatsApp, and checked against a stored copy; they prove the person can receive messages at that number or address. Generated codes come from an authenticator app such as Google Authenticator, Microsoft Authenticator or a password manager, using TOTP (time-based one-time passwords): the app and the server share a secret, set up once by scanning a QR code, and both work out the same code every 30 seconds without any message being sent.

Codes serve either as the whole sign-in (phone-number login is common in mobile-first markets such as India) or as a second step after a password. Good implementations keep codes short-lived, allow only a few attempts, limit how often codes can be sent and store them hashed. SMS has known weaknesses: numbers can be hijacked through SIM swapping, messages can arrive late or not at all, and attackers run 'SMS pumping' fraud, triggering thousands of paid messages to numbers they profit from.

Pros

  • Familiar to almost everyone, with nothing to install for SMS or email
  • Phone numbers work as an identity where email is less used
  • Authenticator app codes are free and work offline
  • Easy to add as a second step after a password

Cons

  • SMS codes cost money per message and can be delayed or lost
  • SIM swapping lets attackers take over a phone number
  • Codes can be typed into a convincing fake site
  • Open SMS endpoints attract costly pumping fraud

Pick it when

  • Phone-number sign-in for mobile apps where that is the norm
  • A second factor after a password, ideally from an authenticator app
  • Confirming that an email address or phone number is real

Skip it when

  • High-value accounts, where passkeys or security keys resist phishing
  • SMS costs and fraud controls would not pay off at your volume

What it costs · Pay as you go

Email and authenticator app codes cost nothing extra. SMS is billed per message, from about a cent in the US to tens of cents elsewhere; Twilio Verify adds $0.05 per successful check.

One-time passwords (OTP) pricing (opens in a new tab)Approximate, checked September 2026.

Also called: OTP, verification code, TOTP, SMS code, email code, authenticator app

Open One-time passwords (OTP) as a pageOfficial site (opens in a new tab)

Two-factor authentication (2FA)

PatternFree
Asking for a second proof after the password, such as a code from an app or a tap on a security key, so a stolen password alone is not enough to get in.

Factors come in three kinds: something you know (a password or PIN), something you have (a phone, an authenticator app, a security key) and something you are (a fingerprint or face). 2FA combines two different kinds; multi-factor authentication (MFA) is the general term. After the password, the app asks for the second factor, often with a 'remember this device' option so it is not asked for every time.

The options differ in strength. SMS codes are better than no second factor but are exposed to SIM swapping and phishing. Authenticator apps (TOTP) are free and stronger. Push approvals are convenient but invite 'MFA fatigue' attacks, where someone sends prompts until the user taps approve. Hardware security keys and passkeys resist phishing, because they only respond to the genuine website. Every setup also needs a recovery path, usually one-time backup codes, or lost phones turn into support tickets.

Pros

  • Blocks attacks that rely only on a leaked or reused password
  • Authenticator apps and passkeys cost nothing to run
  • Expected by users, and often required by business customers
  • Offered by most auth providers as a setting, not custom code

Cons

  • Adds a step to sign-in, which some users resent
  • Lost phones and keys need a recovery process and support time
  • SMS as the second factor stays open to SIM swapping and phishing

Pick it when

  • Accounts that hold money, personal data or admin powers
  • Business software whose customers' security teams ask for it
  • Password sign-in is allowed, since reused passwords leak often

Skip it when

  • Sign-in already uses passkeys, which pair possession and a biometric in one step
  • Low-risk accounts where the extra step costs more than it protects

What it costs · Free

Authenticator apps, backup codes and passkeys cost nothing to run. SMS codes are billed per message, and some auth providers keep MFA for paid plans.

Approximate, checked September 2026.

Also called: 2FA, MFA, multi-factor authentication, two-step verification, second factor

Open Two-factor authentication (2FA) as a pageOfficial site (opens in a new tab)

Passkeys

ProtocolFree
A replacement for passwords: the device creates a unique key for each website and signs in with a fingerprint, face scan or screen lock PIN, with nothing to type or remember.

A passkey is a WebAuthn (FIDO2) credential. When someone creates one, their device makes a private key that stays on the device or in their password manager and gives the website only the matching public key. At sign-in the site sends a random challenge, the device asks for a fingerprint, face or PIN to unlock the key, and signs the challenge; the server checks that signature with the public key. No shared secret exists, so a leaked database holds nothing an attacker can sign in with.

Each passkey is bound to the website's domain, so a look-alike phishing site simply gets no answer, which is what sets passkeys apart from passwords and codes. Apple, Google and Microsoft support them across their platforms, and they sync between a person's devices through iCloud Keychain, Google Password Manager or password managers such as 1Password and Bitwarden. On a borrowed computer, a phone can approve the sign-in by scanning a QR code.

Adoption is still uneven: older devices, shared computers and people without a synced account can struggle, so apps usually offer passkeys alongside another method and invite users to add one after they sign in. On Android, Credential Manager handles creating and using them.

Pros

  • Resistant to phishing, because each passkey only works on its own website
  • Nothing to remember or type; sign-in takes a tap or a glance
  • A server breach exposes only public keys, which are useless to attackers
  • Syncs across devices through Apple, Google and password managers
  • No messages to send and no per-use fees

Cons

  • Still unfamiliar to many users, so it needs clear prompts and a fallback
  • Older devices, shared computers and some browsers make it awkward
  • Account recovery still depends on another method
  • More work to build than a password form without a library or provider

Pick it when

  • Returning users on phones and laptops from the last few years
  • Accounts worth protecting from phishing, such as money or admin access
  • You want to phase out passwords or SMS codes over time

Skip it when

  • It would be the only way in and many users have older or shared devices
  • Your auth provider lacks support and building it yourself is not an option

What it costs · Free

Free: an open standard built into operating systems, browsers and password managers. Some auth providers include passkeys only on paid plans.

Approximate, checked September 2026.

Also called: WebAuthn, FIDO2, FIDO passkeys, passwordless sign-in, security keys

Open Passkeys as a pageOfficial site (opens in a new tab)

OAuth 2.0 and social login

ProtocolFree
The standard that lets a person give an app limited access to another service without sharing their password, and the basis of 'Sign in with Google', 'Sign in with Apple' and similar buttons.

In the usual authorisation code flow, the app sends the user to the provider (Google, GitHub, Microsoft) with a list of scopes, the permissions it wants. The user signs in there and approves a consent screen, and the provider redirects back with a short-lived code. The app's server swaps that code for an access token, which it presents to the provider's APIs, and often a refresh token for getting new access tokens later. The app never sees the user's password.

OAuth was designed for delegated access (let this app read my calendar), not for proving identity, so social login normally adds OpenID Connect on top, which returns an ID token saying who the user is. GitHub is a notable exception that uses plain OAuth plus a profile API call. Mobile apps and single-page apps cannot keep a client secret, so they use PKCE. OAuth 2.1 gathers these lessons into one specification, requiring PKCE and dropping older flows such as the implicit flow.

For users, social login means no new password and a sign-up that takes seconds. For the app, it means following each provider's rules: a registered developer app, exact redirect URLs, reviews for sensitive scopes, and on iOS the App Store rule that apps offering third-party login must usually also offer Sign in with Apple or a similar privacy-focused option.

Pros

  • Sign-up in a couple of clicks, with no new password
  • The provider handles password resets, 2FA and suspicious sign-ins
  • Usually comes with an email address the provider has verified
  • Access tokens let an app use a person's Google, GitHub or Microsoft data with consent

Cons

  • Each provider needs its own developer app, keys and redirect URLs
  • People without those accounts, or wary of linking them, need another option
  • A provider outage, ban or policy change can block sign-ins
  • Easy to get subtly wrong by hand (state, PKCE, token checks)

Pick it when

  • Consumer apps where a quick sign-up matters
  • Users already live in Google Workspace, Microsoft 365 or GitHub
  • The app needs to act on the user's data in another service

Skip it when

  • Your audience rarely has, or wants to link, a big-tech account
  • You would write the protocol by hand instead of using a tested library or provider

What it costs · Free

Free: Google, GitHub and Microsoft charge nothing for sign-in. Sign in with Apple needs a paid Apple Developer Program membership.

Approximate, checked September 2026.

Also called: OAuth, OAuth 2.1, social login, Sign in with Google, Sign in with Apple, access token

Open OAuth 2.0 and social login as a pageOfficial site (opens in a new tab)

Tokens and sessions

Sessions

Concept
How an app remembers that someone is signed in: the server keeps a record of the sign-in and gives the browser a random ID in a cookie, which comes back with every request.

After a successful sign-in, the server creates a session record (user id, expiry, perhaps the device) in a database table or a fast store such as Redis, and sends back a long random session ID in a cookie. On each request the browser returns the cookie and the server looks the ID up to learn who is asking. The ID means nothing by itself, so reading it reveals nothing, but whoever holds it is treated as that user until it expires.

Because the truth lives on the server, control is simple: signing out, 'sign out of all devices', banning a user or changing their role takes effect on the very next request. The costs are a lookup on every request and a store that every server must share. Good practice is to mark the cookie HttpOnly (hidden from JavaScript), Secure (sent only over HTTPS) and SameSite (not sent from other sites, which blunts CSRF), to issue a fresh ID at sign-in, and to expire idle sessions.

Pros

  • Instant sign-out and revocation, because the server owns the record
  • The cookie holds only a random ID, so nothing sensitive sits in the browser
  • HttpOnly cookies are out of reach of injected scripts
  • A simple, long-proven model built into most web frameworks

Cons

  • A lookup on every request, in a store all servers must share
  • Cookies need CSRF protection and do not cross domains easily
  • Awkward for mobile apps and third-party APIs that do not use cookies

Pick it when

  • Websites and apps with their own backend on one domain
  • You need to sign people out, ban them or change roles immediately
  • Server-rendered frameworks such as Django, Laravel, Rails or Next.js

Skip it when

  • Many independent services must verify users without a shared session store

Also called: session cookie, server-side sessions, session ID, session store, stateful sessions

Open Sessions as a pageOfficial site (opens in a new tab)

JWT

Format
A compact, signed token that carries facts about a user, such as their id and role, so a server can trust it by checking the signature instead of looking anything up.

A JWT (pronounced 'jot') is three base64url-encoded parts joined by dots: a header naming the signing algorithm, a payload of claims (sub for the user id, exp for the expiry time, iss for the issuer, plus custom ones such as role) and a signature. It is signed either with a shared secret (HS256, an HMAC) or with a private key (RS256, ES256), in which case anyone can verify it with the public key, usually published at a JWKS URL.

The payload is encoded, not encrypted, so anyone holding the token can read it and it must never contain secrets. The central trade-off is revocation: a valid JWT keeps working until it expires, even after the user signs out or is banned. Systems therefore issue short-lived access tokens (minutes to an hour) with a refresh token that gets new ones, or keep a deny list, which brings back the lookup JWTs were meant to avoid.

Supabase, Firebase and Clerk all give apps JWTs, and OpenID Connect ID tokens are JWTs. Verifying code must check the algorithm, signature, expiry and audience; libraries that once accepted the 'none' algorithm or confused key types led to real vulnerabilities. Tokens kept in localStorage are exposed to any cross-site scripting (XSS) bug, so HttpOnly cookies are often the safer place for them in a browser.

Pros

  • Any server with the key can verify it without a database lookup
  • Works across domains, mobile apps and separate services
  • A standard format (RFC 7519) with libraries for every language
  • Carries roles and other claims that database rules can read directly

Cons

  • Hard to revoke before it expires
  • Readable by anyone who holds it, so no secrets in the payload
  • Grows with every claim and travels with every request
  • Easy to misconfigure: algorithm, audience and expiry checks all matter

Pick it when

  • APIs called by mobile apps or other services
  • Several services must trust one sign-in without a shared session store
  • Your auth provider issues JWTs and your database rules read them, as with Supabase

Skip it when

  • A single web app with its own server, where a session cookie is simpler
  • You need instant sign-out and do not want short lifetimes and refresh logic

Also called: JSON Web Token, jot, bearer token, JWS, JWKS, token-based auth

Open JWT as a pageOfficial site (opens in a new tab)

OpenID Connect

Protocol
An identity layer on top of OAuth 2.0 that tells an app who the user is, in a standard signed token. It is how 'Sign in with Google' and 'Sign in with Microsoft' work.

OAuth on its own hands out access tokens that say what an app may do, not who the user is. OpenID Connect, finalised by the OpenID Foundation in 2014, adds the missing piece: when the app asks for the 'openid' scope, the provider also returns an ID token, a JWT with claims such as sub (a stable user id), email, name, iss (who issued it) and aud (which app it is for). The app verifies the signature and those claims, then starts its own session.

It also standardises the plumbing. A discovery document at /.well-known/openid-configuration lists a provider's endpoints and signing keys, so a library can connect to Google, Microsoft Entra ID, Okta, Auth0 or Keycloak with little more than a URL, a client id and a secret. That makes it the modern alternative to SAML for single sign-on, and it suits mobile apps, which SAML was never designed for.

Also called: OIDC, ID token, OpenID

Open OpenID Connect as a pageOfficial site (opens in a new tab)

PKCE

Protocol
An extra check in the OAuth sign-in flow that stops an intercepted authorisation code being used by anyone except the app that started the sign-in. Mobile and single-page apps depend on it.

Before redirecting to the provider, the app makes a random secret (the code verifier) and sends only its SHA-256 hash (the code challenge). When it later swaps the authorisation code for tokens, it must present the original verifier, and the provider checks that it hashes to the challenge. A malicious app or script that grabs the code on its way back cannot use it, because the verifier never left the real app.

PKCE (pronounced 'pixy', defined in RFC 7636) was created for apps that cannot keep a client secret, since anything shipped inside a mobile app or a JavaScript bundle can be extracted. It replaced the old implicit flow for single-page apps, current security guidance recommends it for server-side apps too, and OAuth 2.1 makes it mandatory. Good OAuth libraries and auth SDKs handle it automatically.

Also called: Proof Key for Code Exchange, pixy, RFC 7636, code verifier, code challenge

Open PKCE as a pageOfficial site (opens in a new tab)

Providers

Supabase Auth

ServiceFree tier
The sign-in service built into every Supabase project, which keeps users in your own PostgreSQL database and issues tokens that row level security policies can check.

Supabase Auth is an open-source Go server (it began as a fork of Netlify's GoTrue) that runs beside each project's database and stores users in the auth.users table. It supports email and password, magic links, one-time codes by email or SMS, anonymous sign-ins, OAuth providers such as Google, Apple and GitHub, SAML single sign-on, TOTP two-factor and, more recently, passkeys. Client libraries for JavaScript, Flutter, Swift, Kotlin and Python handle sign-in and token refresh.

Each sign-in returns a short-lived JWT access token and a refresh token. Because the database understands those tokens, row level security policies can call auth.uid() to limit every query to the signed-in user's rows, and a custom access token hook can add claims such as a role. Projects can also accept tokens from Clerk, Firebase Auth or Auth0 when another provider handles sign-in.

Two settings matter before launch. The built-in email sender only reaches the project team's own addresses and allows a couple of messages an hour, so production apps connect their own SMTP service such as Resend, Amazon SES or Postmark. SMS codes likewise need an account with an SMS provider such as Twilio.

Pros

  • Users live in your own Postgres database, next to their data
  • Tokens plug straight into row level security policies
  • Free plan covers 50,000 monthly active users
  • Open source and self-hostable, so leaving is realistic
  • Many sign-in methods, including SAML and anonymous users

Cons

  • Few ready-made screens compared with Clerk; most apps build their own forms
  • Production email and SMS need your own providers
  • SAML users and phone-based MFA cost extra
  • Less compelling when the rest of the app does not run on Supabase

Pick it when

  • Your app already uses Supabase for its database
  • You want sign-in and data permissions enforced in one place
  • A tight budget with many users on the free allowance

Skip it when

  • You want complete, polished sign-in and profile screens out of the box
  • The rest of your backend lives elsewhere and does not use Postgres

What it costs · Free tier

Free plan includes 50,000 monthly active users. Pro ($25 a month) includes 100,000, then about $0.00325 per extra user; SAML users and phone MFA cost extra.

Supabase Auth pricing (opens in a new tab)Approximate, checked September 2026.

Also called: GoTrue, supabase.auth, Supabase authentication

Open Supabase Auth as a pageOfficial site (opens in a new tab)

Firebase Authentication

ServiceFree tier
Google's hosted sign-in service for Firebase apps, with SDKs for Android, iOS, the web, Flutter and Unity that cover email, phone numbers and social accounts.

Firebase Authentication keeps users in your Firebase project and supports email and password, email link sign-in, phone numbers with SMS codes, anonymous accounts, and providers such as Google, Apple, Facebook, GitHub, Microsoft and X. Custom tokens let an existing login system hand its users over. FirebaseUI offers ready-made sign-in screens, and the SDKs keep people signed in and refresh their tokens automatically.

Each signed-in user has an ID token, a JWT valid for an hour, which Firestore and Cloud Storage security rules read as request.auth and which your own server can verify with the Admin SDK. Upgrading to Firebase Authentication with Identity Platform adds multi-factor authentication, SAML and OpenID Connect providers, blocking functions that run your code during sign-up and sign-in, audit logs, multi-tenancy and an SLA, and switches billing to monthly active users.

Phone sign-in needs the pay-as-you-go Blaze plan and is billed per SMS, so projects should limit which countries may receive codes to keep SMS fraud down. Passkeys are not a built-in sign-in method. Users can be exported with the Firebase CLI, but passwords are hashed with a modified scrypt, so moving elsewhere takes planning.

Pros

  • Mature mobile SDKs that handle sign-in state for you
  • Email, social and anonymous sign-in are free on the standard product
  • Works directly with Firestore and Cloud Storage security rules
  • Anonymous accounts can be upgraded later without losing data

Cons

  • Tied to Firebase and Google Cloud, which makes leaving harder
  • MFA and SAML need the Identity Platform upgrade, which changes billing
  • Phone sign-in bills per SMS and attracts fraud without country limits
  • No built-in passkey sign-in

Pick it when

  • Mobile apps already built on Firebase and Firestore
  • Phone-number sign-in with SDKs that handle the whole SMS flow
  • Prototypes that need sign-in working in an afternoon

Skip it when

  • Your data lives in a SQL database outside Firebase
  • You need passkeys or enterprise SSO without add-ons or upgrades

What it costs · Free tier

Email, social and anonymous sign-in are free. Phone sign-in needs the Blaze plan and bills per SMS (about $0.01 in the US). The Identity Platform upgrade gives 50,000 monthly active users free, then about $0.0025 to $0.0055 each.

Firebase Authentication pricing (opens in a new tab)Approximate, checked September 2026.

Also called: Firebase Auth, Identity Platform, FirebaseUI, Google Identity Platform

Open Firebase Authentication as a pageOfficial site (opens in a new tab)

Clerk

ServiceFree tier
A hosted sign-in and user management service with ready-made components, so a React or Next.js app gets sign-up, sign-in, profile and team screens in a few lines of code.

Clerk supplies drop-in components such as SignIn, SignUp, UserButton and UserProfile, plus hooks and server helpers for Next.js, React, React Router, Astro, Expo and native iOS and Android. Behind them sit passwords, magic links, email and SMS codes, social providers, passkeys, MFA, and organisations with roles and invitations for B2B apps. A dashboard lists every user and session, and bot protection, leaked-password checks and device management come built in.

Sessions pair a long-lived cookie held by Clerk's sign-in API with a short-lived JWT, lasting about a minute, that the SDK refreshes in the background, so revoking a session takes effect almost at once. User records live on Clerk's servers; apps that need users in their own database copy them over with webhooks. Clerk tokens can also be accepted by Supabase and other backends.

Billing counts monthly retained users: a person counts only once they come back at least a day after signing up, so sign-ups that never return cost nothing. Passkeys, MFA and removing Clerk branding need the Pro plan.

Pros

  • Polished sign-in, profile and organisation screens in minutes
  • Close Next.js integration, including middleware and server components
  • Passkeys, MFA, social login and B2B organisations in one service
  • Free plan covers 50,000 monthly retained users per app

Cons

  • User data lives with Clerk, so your own database needs webhook syncing
  • Passkeys, MFA and removing branding need a paid plan
  • Costs grow per user past the free allowance
  • Centred on JavaScript frameworks; other stacks get less support

Pick it when

  • React or Next.js apps that want finished auth screens quickly
  • B2B products that need organisations, roles and invitations
  • Small teams that would rather not build account management

Skip it when

  • Users must stay in your own database for legal or design reasons
  • A backend platform such as Supabase or Firebase already covers sign-in

What it costs · Free tier

Free for up to 50,000 monthly retained users per app. Pro from $25 a month ($20 billed yearly), then about $0.02 per extra user; SMS codes cost about $0.01 each in the US and Canada.

Clerk pricing (opens in a new tab)Approximate, checked September 2026.

Also called: Clerk.com, Clerk auth, @clerk/nextjs

Open Clerk as a pageOfficial site (opens in a new tab)

Auth.js

LibraryOpen source
An open-source sign-in library for JavaScript apps, formerly NextAuth.js, that adds social login, email links and sessions to Next.js and other frameworks while keeping users in your own database.

Auth.js runs inside your app rather than as a separate service. You list providers (dozens of OAuth services such as Google, GitHub and Microsoft Entra ID, email magic links, or a credentials form for usernames and passwords) and it handles the redirects, callbacks, CSRF protection and cookies. It began as NextAuth.js for Next.js; the core was later split out so SvelteKit, Express, Qwik and SolidStart apps could use it too.

Sessions are either stateless, as an encrypted JWT in a cookie, or stored in your database through adapters for Prisma, Drizzle, Supabase, MongoDB and many more. User records stay in your own infrastructure and there is no per-user fee. It does not include user management screens or built-in two-factor authentication, and its WebAuthn (passkey) provider is marked experimental.

In September 2025 the project passed to the Better Auth team, which joined Vercel in 2026. Auth.js still receives security patches and urgent fixes, but its maintainers recommend Better Auth, a separate open-source library, for new projects and publish a migration guide.

Pros

  • Free and open source (ISC licence), with no per-user fees
  • Users and sessions stay in your own database
  • Many OAuth providers ready to configure
  • Long track record in Next.js apps, with plenty of examples

Cons

  • Mostly maintenance now: security patches rather than new features
  • No built-in 2FA, user dashboard or production-ready passkeys
  • Password sign-in leaves hashing, resets and rate limits to you

Pick it when

  • An existing app that already runs on it and works well
  • Social login with users in your own database at no licence cost

Skip it when

  • Starting a new project, where its own maintainers point to Better Auth
  • You need MFA, passkeys or enterprise SSO without building them yourself

What it costs · Open source

Free (ISC licence). You pay only for your own hosting and database.

Approximate, checked September 2026.

Also called: NextAuth.js, NextAuth, next-auth, @auth/core

Open Auth.js as a pageOfficial site (opens in a new tab)

Auth0

ServiceFree tier
A hosted identity platform, owned by Okta, that runs sign-in for consumer and business apps, with enterprise features such as SAML single sign-on, fine-grained permissions and compliance certifications.

Auth0 usually shows a hosted Universal Login page on its own domain or yours, so passwords never touch your app. It supports passwords, passwordless email and SMS, passkeys, social providers, MFA, and enterprise connections to SAML, Microsoft Entra ID, Google Workspace and LDAP directories. Apps connect through OpenID Connect and OAuth 2.0 with SDKs for most languages, and Actions (small Node.js functions) customise what happens during sign-up and sign-in.

Its strength is the business end: organisations for B2B customers, each with its own SSO connection and branding, role-based access control, protection against bots and credential stuffing, audit log streaming, and the certifications enterprise security reviews ask for. Okta bought the company in 2021, and it also sells Fine-Grained Authorization, based on Google's Zanzibar model, and identity tools for AI agents.

The trade-offs are cost and complexity. The free plan is generous, but paid plans start with a few hundred included users and rise with each step up in monthly active users, and features such as enterprise MFA or connecting your own user database sit on higher tiers. Configuration spans many dashboard screens, and leaving later means rebuilding rules and connections elsewhere.

Pros

  • Broad feature set: social, passwordless, passkeys, MFA and enterprise SSO
  • Hosted login page keeps passwords out of your app
  • Strong B2B tools: organisations, per-customer SSO and SCIM
  • Compliance certifications that help pass enterprise security reviews
  • Free plan covers up to 25,000 monthly active users

Cons

  • Paid plans get expensive as monthly active users grow
  • Many settings and concepts to learn
  • Advanced features are spread across higher, pricier tiers
  • Actions, rules and connections take effort to move elsewhere

Pick it when

  • B2B software whose customers ask for SAML SSO and directory sync
  • Regulated or enterprise settings that need certifications and SLAs
  • Many apps and APIs that share one identity system

Skip it when

  • A small consumer app where per-user costs could outgrow revenue
  • You already use Supabase or Firebase, whose built-in auth covers the basics

What it costs · Free tier

Free for up to 25,000 monthly active users. Paid plans start with Essentials from about $35 a month for 500 users, and Professional from about $240 a month; prices rise with user count.

Auth0 pricing (opens in a new tab)Approximate, checked September 2026.

Also called: Auth0 by Okta, Okta Customer Identity Cloud, Universal Login, Auth0 Actions

Open Auth0 as a pageOfficial site (opens in a new tab)

Side by side

Differences

How the options in this area compare on the questions that usually decide the choice.

Both keep a person signed in after they log in. A session keeps the facts on the server and gives the browser a random key; a JWT packs the facts into a signed token that the client carries around.

CompareSessionsJWT
What the client holdsA random session ID in a cookieA signed token with the user's details
Where the truth livesA server-side store (database or Redis)Inside the token itself
Checking a requestLook the ID up in the storeVerify the signature; no lookup needed
Signing someone outDelete the record; works at onceHard before expiry; needs short lifetimes or a deny list
Many serversAll must reach the same storeAny server with the key can verify
Size on each requestA short IDHundreds of bytes or more, growing with claims
Mobile apps and APIsPossible, but cookies are awkwardA natural fit, sent as a bearer token
Watch out forCSRF: use SameSite cookies and CSRF tokensTheft through XSS if kept in localStorage

How to choose

  • Pick sessions for a website or app with its own backend, where instant sign-out and simple revocation matter.
  • Pick JWTs when several services or mobile clients must verify users without sharing a session store, and keep them short-lived.
  • Many auth providers combine the two: a short-lived JWT for each request and a long-lived refresh token or session that issues new ones.

Magic link vs OTP vs passkeys vs social login

Open as a page: Magic link vs OTP vs passkeys vs social login

Four ways to let people in without asking them to invent a password. They differ in how many steps they take, what they cost to run and how well they stand up to phishing.

CompareMagic linkOTPPasskeysSocial login
How it worksClick a link sent by emailType a short code from SMS, email or an appUnlock with a fingerprint, face or PINApprove on Google, Apple, GitHub or similar
Steps for the userSwitch to the inbox and clickWait for the code and type itOne tap or glanceA couple of clicks
Phishing resistanceMedium: links can be forwarded or interceptedLow: codes can be typed into fake sitesHigh: only works on the real domainMedium: as strong as the provider account
Running costOne email per sign-inFree by app or email; SMS costs per messageFreeFree
Setup effortEmail sender, tokens and expiryCode storage, expiry and rate limitsA WebAuthn library or a provider that supports itA developer app with each provider
On a new deviceWorks wherever the inbox is openWorks anywhere the code arrivesSynced passkey, or a QR scan with a phoneWorks after signing in to the provider
Depends onEmail arriving quicklyThe phone network or inboxA recent device or password managerEach provider's rules and uptime
Best forOccasional sign-ins and B2B toolsPhone-first apps and second factorsReturning users on recent devicesConsumer apps that want quick sign-up

How to choose

  • Pick social login for quick sign-up in consumer apps, with one other method for people who do not use those accounts.
  • Pick passkeys when phishing resistance matters, and offer them after the first sign-in rather than as the only way in.
  • Pick magic links or email codes for occasional sign-ins, and SMS codes where the phone number is the main identity.

Supabase Auth vs Firebase Auth vs Clerk vs Auth.js vs Auth0

Open as a page: Supabase Auth vs Firebase Auth vs Clerk vs Auth.js vs Auth0

Five common ways to add sign-in without building it from scratch. Two come bundled with a backend platform, two are dedicated hosted services, and one is a library that runs inside your own app. MAU means monthly active users.

CompareSupabase AuthFirebase AuthClerkAuth.jsAuth0
What it isAuth built into each Supabase projectGoogle's sign-in service for FirebaseHosted auth with ready-made UIOpen-source library inside your appHosted identity platform from Okta
Where users liveA table in your own PostgresFirebase's user storeClerk's servers, synced by webhooksYour database, through an adapterAuth0's servers
Ready-made screensA few UI blocks; mostly your own formsFirebaseUI drop-in screensFull sign-in, profile and team componentsBasic default pages onlyHosted Universal Login page
PasskeysYes, recently addedNot built inYes, on paid plansExperimental provider onlyYes
Enterprise SSO (SAML)Pro plan and up, billed per SSO userWith the Identity Platform upgradeOne connection on Pro, more at extra costOIDC providers; SAML needs extra toolsYes; one connection even on Free
Free allowance50,000 MAUUnlimited email and social; 50,000 MAU with Identity Platform50,000 retained users per appNo limit; you host it25,000 MAU
First paid stepPro, $25 a monthBlaze, pay as you goPro, $25 a monthNone; you pay only for hostingEssentials, from $35 a month
Lock-inLow: standard Postgres you can exportHigh: tied to Firebase APIsMedium: data exports, but UI to rebuildLow: your code and your dataMedium: standard protocols, custom setup
Best forApps built on SupabaseMobile apps built on FirebaseReact and Next.js apps wanting finished UIExisting apps that own their user dataB2B and enterprise requirements

How to choose

  • Pick Supabase Auth or Firebase Authentication when you already use that platform, since sign-in plugs straight into its data rules.
  • Pick Clerk for finished sign-in, profile and team screens in React or Next.js with little code.
  • Pick Auth.js for an existing app that keeps users in its own database; for new projects its maintainers point to Better Auth.
  • Pick Auth0 when business customers need SAML single sign-on, directory sync and compliance paperwork.

Crafted in the dark. Shipped to the world.

Tell us what you are building. You get a private project space with a proposal and a line-by-line quote within a day.