Auth
Clerk
A managed authentication service with ready React components for sign-in, profile and organizations.
What it is
Clerk provides ready UI components (<SignIn />, <UserButton />) and SDKs for Next.js, React, Expo and others. Sign-in, sign-up, MFA, passkeys and session management work out of the box.
It has built-in organizations and roles, handy for B2B SaaS. User data lives in Clerk, and you sync it to your database with webhooks.
The main advantage is integration speed and a polished developer experience. The tradeoff is dependency on the service and per-active-user pricing.
Use it when
- You need polished ready sign-in in Next.js or React within an hour.
- B2B SaaS that needs organizations and roles.
- The team wants minimal authentication code.
Avoid it when
- Identity data must stay on your own infrastructure: Keycloak.
- Very price-sensitive projects with many free users.
Key concepts
- Components
- Ready
SignIn,SignUp,UserButton,UserProfile. - Middleware
- Protects routes at request level.
- Organizations
- Teams, roles and invitations for B2B.
- Webhooks
- Events for syncing users into your database.
Example
Interview questions
1. Where are users stored with Clerk?
In Clerk. To link with your data model you store the
userIdand sync needed fields with webhooks.2. How do you protect a route?
With middleware that calls
auth.protect()for private paths, and anauth()check in server components or APIs.3. When is a self-hosted solution better?
When you need control over data, no per-user fee or specific sign-in behavior the service does not allow.
Related technologies
- Next.jsA full-stack React framework: routing, SSR, static generation, API routes and server components.
- ReactA library for building interfaces from components: UI as a function of state.
- Auth0A managed authentication and authorization service: sign-in, SSO, MFA and API access with no identity server of your own.
- Auth.jsAn open source authentication library for web apps (formerly NextAuth.js), with OAuth providers and sessions.
- PasskeysPasswordless sign-in on public keys: the private key stays on the device and biometrics or a PIN confirm it.
- OAuth 2.0A delegated authorization standard: an app gets limited access to a user's resources without their password.
Logos belong to their owners and are used for identification only. Icons: Simple Icons (CC0), Devicon (MIT).