Clerk Next.js SDK
The Clerk Next.js SDK is the recommended method for integrating Clerk into your Next.js application.
Client-side helpers
Because the Next.js SDK is built on top of the Clerk React SDK, you can use the hooks that the React SDK provides. These hooks give you access to the Clerk
object and a set of useful helper methods for signing in and signing up. Learn more in the React SDK reference.
Server-side helpers
App router
Clerk provides first-class support for the Next.js App Router. The following references show how to integrate Clerk features into apps using the latest App Router and React Server Components features.
Pages router
Clerk continues to provide drop-in support for the Next.js Pages Router. In addition to the main Clerk integration, the following references are available for apps using Pages Router.
Auth
object
Both auth()
(App Router) and getAuth()
(Pages Router) return an Auth
object. This JavaScript object contains important information like the current user's session ID, user ID, and organization ID. Learn more about the Auth
object.
clerkMiddleware()
The clerkMiddleware()
helper integrates Clerk authentication into your Next.js application through middleware. It allows you to integrate authorization into both the client and server of your application. You can learn more here.
Demo repositories
For examples of Clerk's features, such as user and organization management, integrated into a single application, see the Next.js demo repositories:
Feedback
Last updated on