Upgrade to @clerk/nextjs v6
To upgrade to @clerk/nextjs
v6, use the upgrade CLI:
The CLI will walk you through the upgrade and apply necessary changes to your application automatically.
auth()
is now async
To support Next.js's change to async dynamic APIs, auth()
is now asynchronous. The codemod will migrate this for you.
In clerkMiddleware
Now that auth()
is asynchronous, custom middleware handlers that rely on auth()
must also now be converted to be asynchronous. The codemod will migrate this for you.
clerkClient()
is now async
Previously the clerkClient()
method from @clerk/nextjs/server
was synchronous, it is now asynchronous.
auth().protect()
is now auth.protect()
To ease calling of protect()
, it is now accessible on the auth
export, instead of from the return value.
Static rendering by default
Starting with v6, <ClerkProvider>
will no longer opt your entire application into dynamic rendering by default. If this behavior is still desired, pass the dynamic
prop to your root <ClerkProvider>
:
Note that this isn't recommended, and in most cases you should use auth()
to access auth data at request time instead. For more information, see the guide on Next.js rendering modes and Clerk.
Removed deprecated APIs
The following deprecated APIs have been removed.
authMiddleware()
- Migrate toclerkMiddleware()
redirectToSignIn()
- Migrate toconst { redirectToSignIn } = await auth()
redirectToSignUp()
- Migrate toconst { redirectToSignUp } = await auth()
clerkClient
- Migrate toawait clerkClient()
Feedback
Last updated on