Build your own Clerk/Auth0
✓ Good to VibeAuthentication is a solved problem with excellent open source foundations. Auth.js (NextAuth) handles the complexity of OAuth flows, session management, and token refresh. What you're really building is the UX layer and any custom requirements like organization management or specific MFA flows.
OAuth flows, PKCE, token refresh, session management—all handled. You focus on UX.
Clerk charges $0.02/MAU after 10k. At 100k users, that's $1,800/month vs ~$0.
Your login pages, your email templates, your verification flows. No "Powered by" badges.
User data stays in your database. No syncing, no vendor migration complexity.
SOC2, HIPAA, GDPR audits are easier when auth isn't a third-party black box.
Direct database access means complex authorization logic stays simple.
| Layer | Tools | Why |
|---|---|---|
| Auth Framework | Auth.js v5 (NextAuth) | Handles OAuth complexity, session management, CSRF protection. 50+ providers supported. |
| Database | PostgreSQL + Prisma | Relational integrity for users, sessions, accounts. Prisma adapter works out of box. |
| Resend or AWS SES | Transactional email for verification, password reset. Resend has great DX. | |
| OAuth Providers | Arctic library | Lightweight OAuth client. Better than hand-rolling provider integrations. |
| Password Hashing | bcrypt or Argon2 | bcrypt is battle-tested. Argon2 is newer, more resistant to GPU attacks. |
| MFA | otplib + QRCode | TOTP generation and verification. Standard protocol, works with any authenticator app. |
Copy this into Cursor, Claude, or ChatGPT to generate a working implementation:
The foundation. Handles OAuth, sessions, CSRF. Study the source.
Lighter alternative to Auth.js. Good for learning auth internals.
Newer framework with good DX. Worth comparing approaches.
Lightweight OAuth client. Use for custom provider integrations.