@clerk/nextjs
v5.0.3
Published
Clerk SDK for NextJS
Downloads
432,477
Readme
@clerk/nextjs
Changelog · Report a Bug · Request a Feature · Ask a Question
Overview
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.
Getting Started
Prerequisites
- Next.js 13.0.4 or later
- React 18 or later
- Node.js
>=18.17.0
or later
Installation
npm install @clerk/nextjs
Build
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
Usage
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.
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_(test|live)_xxxxxxx
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.
Support
You can get in touch with us in any of the following ways:
- Join our official community Discord server
- Create a GitHub Discussion
- Contact options listed on our Support page
Contributing
We're open to all community contributions! If you'd like to contribute in any way, please read our contribution guidelines) .
Security
@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.
License
This project is licensed under the MIT license.
See LICENSE for more information.