Why Clerk?
Clerk handles auth completely — UI components, session management, OAuth providers, MFA, organizations. You write zero auth code.
npm install @clerk/nextjs
Next.js Setup (3 Steps)
1. Wrap your app:
// app/layout.tsx
import { ClerkProvider, SignedIn, SignedOut, SignInButton, UserButton } from '@clerk/nextjs'
export default function Layout({ children }) {
return (
<ClerkProvider>
<SignedOut><SignInButton /></SignedOut>
<SignedIn><UserButton /></SignedIn>
{children}
</ClerkProvider>
)
}
2. Protect routes:
// middleware.ts
import { clerkMiddleware } from '@clerk/nextjs/server'
export default clerkMiddleware()
export const config = { matcher: ['/dashboard(.*)'] }
3. Use in components:
import { currentUser } from '@clerk/nextjs/server'
export default async function Dashboard() {
const user = await currentUser()
return <h1>Hello {user?.firstName}</h1>
}
That's it. Full auth with OAuth, email/password, MFA — no auth code written.
Pre-Built Components
import { SignIn, SignUp, UserProfile } from '@clerk/nextjs'
<SignIn /> // Full login form with OAuth buttons
<SignUp /> // Registration form
<UserProfile /> // Account settings page
Clerk vs Auth0 vs NextAuth
| Feature | Clerk | Auth0 | NextAuth |
|---|---|---|---|
| UI components | Yes | Hosted | No |
| Setup time | 5 min | 30 min | 1 hr |
| Free tier | 10K users | 7.5K users | Unlimited |
| Orgs/Teams | Yes | Enterprise | No |
Need to extract data from any website at scale? I build custom web scrapers — 77 production scrapers running on Apify Store. Email me at spinov001@gmail.com for a tailored solution.
Top comments (0)