Clerk logo

Clerk Docs

Ctrl + K
Go to

Configure Middleware

If you plan to use Next.js API routes or server-side rendering with getAuth, you must install withClerkMiddleware in your Next.js middleware. Otherwise, you can skip this step.

Simply copy this snippet into a file named middleware.js or middleware.ts in your project root.


Clerk only depends on the withClerkMiddleware() wrapper. You are welcome to customize the internal middleware function as needed.

Was this helpful?

Clerk © 2022