# Auth with a Hosted Provider (Clerk)

> Use a hosted identity service for sign-in UI, user management and MFA, and understand the trade-offs of outsourcing auth. Free notes, key concepts, resources...

Canonical: https://www.internhack.in/roadmaps/tracks/full-stack/clerk
Last updated: 2026-11-28

Use a hosted identity service for sign-in UI, user management and MFA, and understand the trade-offs of outsourcing auth.

Intermediate · about 4 hours · difficulty 2/5

Learn first: [OAuth 2.0, OpenID Connect and Social Login](https://www.internhack.in/roadmaps/tracks/full-stack/oauth-and-social-login), [Server Actions and Mutations](https://www.internhack.in/roadmaps/tracks/full-stack/server-actions)

Hosted providers like **Clerk** (also Auth0, Supabase Auth and Firebase Auth) handle sign-up, login, social providers, MFA and user management for you. You get polished UI components and fewer security responsibilities.

### Integration

- Wrap your Next.js app with the provider and add prebuilt SignIn, SignUp and UserButton components.
- Use middleware to protect routes and server helpers to read the current user id.
- Store your own app data (applications, profiles) in PostgreSQL keyed by the provider's user id.
- Use **webhooks** to sync user creation and deletion into your database.

### Trade-offs

- Faster to ship, with MFA, bot protection and session management included.
- Vendor lock-in and per-user pricing once you grow beyond the free tier.
- User data lives with a third party, which matters for data protection obligations such as India's DPDP Act.

### Pitfalls

- Not verifying webhook signatures.
- Duplicating user profile data in two places without a clear source of truth.
- Assuming the provider does authorization for you; deciding what a user may do is still your job.

You are ready to move on when your portal uses a hosted provider for login, syncs users into PostgreSQL through a verified webhook, and enforces roles in your own code.

## Key concepts

- **Prebuilt sign-in components**
- **Middleware and server helpers**
- **User sync webhooks**
- **Organisations and roles**
- **Pricing and lock-in**
- **Supabase Auth or Firebase Auth**

## Other options for this step

- [Auth with Auth.js (NextAuth)](https://www.internhack.in/roadmaps/tracks/full-stack/authjs): Add sessions, OAuth providers and credentials login to a Next.js app with the open-source Auth.js library and your own database.

## Mini project

Integrate Clerk into a copy of your portal, sync users into PostgreSQL via a signed webhook, and write a short comparison of setup time, cost at 10,000 users and data ownership versus Auth.js.

## Check yourself

Your app stores applications keyed by user id, but users are managed by a hosted provider. How do you keep your database in sync when a user deletes their account?

## Free resources

- [Clerk Documentation](https://clerk.com/docs) (Clerk)
- [Supabase Auth](https://supabase.com/docs/guides/auth) (Supabase)

Previous: [Auth with Auth.js (NextAuth)](https://www.internhack.in/roadmaps/tracks/full-stack/authjs) · Next: [Authorization and Access Control](https://www.internhack.in/roadmaps/tracks/full-stack/authorization-rbac)

## More in Authentication, Authorization and Security

- [Authentication Fundamentals and Password Storage](https://www.internhack.in/roadmaps/tracks/full-stack/auth-fundamentals)
- [Sessions, Cookies and JWTs](https://www.internhack.in/roadmaps/tracks/full-stack/sessions-vs-jwt)
- [OAuth 2.0, OpenID Connect and Social Login](https://www.internhack.in/roadmaps/tracks/full-stack/oauth-and-social-login)
- [Auth with Auth.js (NextAuth)](https://www.internhack.in/roadmaps/tracks/full-stack/authjs)
- [Auth with a Hosted Provider (Clerk)](https://www.internhack.in/roadmaps/tracks/full-stack/clerk)
- [Authorization and Access Control](https://www.internhack.in/roadmaps/tracks/full-stack/authorization-rbac)
- [Web Security Essentials](https://www.internhack.in/roadmaps/tracks/full-stack/web-security)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Full-Stack Developer Roadmap](https://www.internhack.in/roadmaps/tracks/full-stack)
