Package Exports
- @clerk/nextjs
- @clerk/nextjs/api
- @clerk/nextjs/app-beta
- @clerk/nextjs/app-beta/client
- @clerk/nextjs/edge-middlewarefiles
- @clerk/nextjs/server
- @clerk/nextjs/ssr
Readme
@clerk/nextjs
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 v10+
- Node.js v14+
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.
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_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.