@clerk/nextjs
TypeScript icon, indicating that this package has built-in type declarations

5.0.2 • Public • Published


@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 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:

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.

Package Sidebar

Install

npm i @clerk/nextjs

Homepage

clerk.com/

Weekly Downloads

106,902

Version

5.0.2

License

MIT

Unpacked Size

550 kB

Total Files

323

Last publish

Collaborators

  • jescalan
  • giannis-clerk
  • chanioxaris
  • colinclerk
  • bradenclerk
  • sokratis
  • yourtallness
  • nikosdouvlis