Next.js Authentication

Seamless authentication for Next.js apps

Server & Client Components

Works seamlessly with Next.js 14+ App Router. Full support for both server and client components with automatic session handling.

API Route Protection

Secure your API routes with middleware. Protect endpoints and validate tokens server-side for maximum security.

Edge Runtime Compatible

Deploy to the edge with confidence. Our SDK is optimized for Next.js Edge Runtime and Vercel deployment.

Zero Config Setup

Get started in minutes with sensible defaults. Our Next.js SDK handles routing, session management, and more automatically.

Protect Routes in Next.js

// middleware.ts
import { authMiddleware } from '@authdog/nextjs'

export default authMiddleware({
  publicRoutes: ['/']
})

export const config = {
  matcher: ['/((?!.+\\.[\\w]+$|_next).*)', '/', '/(api|trpc)(.*)'],
}

Build secure Next.js apps faster

Add enterprise-grade authentication to your Next.js application in minutes.

Start Building