Clerk is the easiest way to add authentication and user management to your Next.js application. Add sign up, sign in, and profile management to your application in minutes.
- Next.js v10+
- Node.js v14+
npm install @clerk/nextjs
To build the package locally with the TypeScript compiler, run:
npm run build
To build the package in watch mode, run the following:
npm run dev
Clerk requires your application to be wrapped in the <ClerkProvider/>
context.
Set NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
to your Publishable Key in your .env.local
file to make the environment
variable accessible to the Provider.
If you are using the previous version of Clerk keys, set NEXT_PUBLIC_CLERK_FRONTEND_API
to your Frontend API in
your .env.local
file.
NEXT_PUBLIC_CLERK_FRONTEND_API=clerk.[your-domain].[tld]
An implementation of <ClerkProvider />
with our flexible Control Components to build an authentication flow
in pages/_app.js
:
import { ClerkProvider, RedirectToSignIn, SignedIn, SignedOut, UserButton } from '@clerk/nextjs';
function MyApp({ Component, pageProps }) {
return (
<ClerkProvider>
<>
<SignedIn>
<>
<header style={{ padding: 20 }}>
<UserButton />
</header>
<Component {...pageProps} />
</>
</SignedIn>
<SignedOut>
<RedirectToSignIn />
</SignedOut>
</>
</ClerkProvider>
);
}
export default MyApp;
For further details and examples, please refer to our Documentation.
You can get in touch with us in any of the following ways:
- Join our official community Discord server
- Open a GitHub support issue
- Contact options listed on our Support page
We're open to all community contributions! If you'd like to contribute in any way, please read our contribution guidelines) .
@clerk/nextjs
follows good practices of security, but 100% security cannot be assured.
@clerk/nextjs
is provided "as is" without any warranty. Use at your own risk.
For more information and to report security issues, please refer to our security documentation.
This project is licensed under the MIT license.
See LICENSE for more information.