Clerk Next.js Middleware
clerk/nextjs-middlewareFreeUtility
The clerkMiddleware() helper integrates Clerk authentication into your Next.js application through Middleware. clerkMiddleware() is compatible with both the App and Pages routers.
Install it
npx shadcn@latest add https://clerk.com/r/nextjs-middleware.jsonSource
1import { clerkMiddleware } from '@clerk/nextjs/server';23export default clerkMiddleware();45export const config = {6 matcher: [7 // Skip Next.js internals and all static files, unless found in search params8 '/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)',9 // Always run for API routes10 '/(api|trpc)(.*)',11 ],12};
What it pulls in
npm packages
