Guide
Clerk vs NextAuth in 2026: Managed vs Self-Hosted Auth



Choose between managed Clerk and self-hosted NextAuth for Next.js. Compare sign-in UI, session storage, organization access and operating costs.
Contents
Contents
TL;DR
Choose Clerk if you want hosted identity and prebuilt sign-in or organization UI. Choose NextAuth for a Next.js app that needs to run the auth handler on its own infrastructure and can own the sign-in experience and application permissions. Start by deciding where sessions and account data should live. Then test a protected route and one organization-scoped action before adopting either approach.
Key Takeaways
- Clerk manages identity and sessions. Your application still decides which records a signed-in user can read or change.
- NextAuth can use JWT or database sessions. The deployment and database costs depend on the session strategy and the features you run.
- Check the installed
next-authrelease before copying an example. The App Router setup here uses the Auth.js v5 beta API.
At-a-glance decision matrix
| Requirement | Clerk | NextAuth |
|---|---|---|
| Sign-in UI | Prebuilt components and hosted pages | Built-in sign-in page with the option to provide your own |
| Identity infrastructure | Clerk service and dashboard | Auth handler and configuration run in your app |
| Session storage | Managed by Clerk | JWT or database sessions |
| Organization access | Organization components and membership context | App manages tenants, roles and membership checks |
| Cost model | Service plan and usage | Software license permits self-hosting. The team pays to run the system. |
Setup comparison
For Clerk on the Next.js App Router, add ClerkProvider in the layout and configure the publishable and server keys. Set up clerkMiddleware() with Clerk's documented matcher. Use proxy.ts on Next.js 16. Protect the page or handler that accesses each resource.
// app/api/me/route.ts — after configuring Clerk's proxy
import { auth } from '@clerk/nextjs/server';
export async function GET() {
const { userId } = await auth();
if (!userId) return new Response(null, { status: 401 });
return Response.json({ userId });
}
The handler checks for a signed-in user. An API handler that reads or updates private data should then check the verified user or organization against the record it will access. Clerk has deprecated createRouteMatcher() for authorization checks and recommends moving them to the resources they protect.
NextAuth's v5 beta setup defines the handler and a helper for reading the session. The example uses GitHub OAuth and JWT sessions. Configure your provider credentials and AUTH_SECRET on the server. Create the provider's callback entry for the URL your deployed application uses. The npm latest tag is still on v4, which uses a different setup.
// auth.ts
import NextAuth from 'next-auth';
import GitHub from 'next-auth/providers/github';
export const { auth, handlers, signIn, signOut } = NextAuth({
providers: [GitHub],
session: { strategy: 'jwt' },
});
// app/api/auth/[...nextauth]/route.ts
import { handlers } from '@/auth';
export const { GET, POST } = handlers;
Use await auth() in server code where you need a session. If you need immediate revocation from stored sessions, evaluate a database adapter and exercise revocation across two browser sessions. JWT sessions can be useful when you want to avoid a database session lookup. Verify what happens to an issued session when a user signs out or loses access.
Sign-in UI and organizations
Clerk provides sign-in and sign-up components for in-app use, plus hosted pages. Configure the sign-in methods and test their redirects on your deployed domain. Check the paths needed for recovery and email verification as well as sign-in. NextAuth has a built-in sign-in route and a custom page option for teams that want to integrate the provider selection into their own UI.
Clerk's organization features provide membership context and a workspace switcher. If you use them, map the active organization to the tenant ID your application stores. Require an active organization for tenant-specific actions and use that ID in the database query. Check that changing the active organization changes the scope of the returned records.
With NextAuth, add organization and membership data in your application and authorize each request from that data. Whether the session comes from a token or a database, check membership before reading a tenant record. In either implementation, test a user who belongs to multiple workspaces and a user whose membership has been removed.
Pricing and operating costs
Clerk's public pricing measures monthly retained users. A user qualifies when they return in a given month at least 24 hours after signup. The service includes 50,000 monthly retained users per app, and organization usage has its own billing rules. Compare your feature requirements with the Clerk pricing page before budgeting. If you need enterprise identity or larger organizations, check those plan items directly.
The @clerk/nextjs SDK is MIT-licensed. The hosted service has its own pricing and limits. The next-auth example package is ISC-licensed and can run in your application. Budget for hosting, maintenance, sign-in support, outbound email if you use it and a database if you use an adapter. Compare what each system needs to meet the same requirements.
Methodology
The fixture checks that the v5 beta handler can serve a session request without a signed-in user. The Clerk example illustrates a resource-level check and needs a configured Clerk application. Run a deployed provider callback, a protected read and an organization access check against your own configuration before release.
Related guides
- Clerk vs NextAuth package comparison
- Auth0 vs Clerk package comparison
- Auth0 vs Clerk comparison guide
- NextAuth package releases and download trends
Source notes
- Auth.js session strategies
- Clerk Next.js middleware API
- Clerk resource-based authorization guide
- Next.js proxy file convention
- Auth.js Next.js installation
- NextAuth npm distribution tags
- Clerk Next.js SDK and components
- Auth.js custom sign-in pages
- Clerk Organizations concepts
- Auth.js protecting resources
- Clerk service plans and billing units
- @clerk/nextjs 7.11.0 npm manifest
- next-auth 5.0.0-beta.32 npm manifest