What is @clerk/clerk-react?
@clerk/clerk-react is a React library that provides authentication and user management functionalities. It allows developers to easily integrate user sign-up, sign-in, and profile management into their React applications.
What are @clerk/clerk-react's main functionalities?
User Sign-Up
This feature allows users to sign up for an account. The SignUp component provides a pre-built sign-up form that can be easily integrated into your application.
import { SignUp } from '@clerk/clerk-react';
function App() {
return (
<div>
<SignUp />
</div>
);
}
User Sign-In
This feature allows users to sign in to their account. The SignIn component provides a pre-built sign-in form that can be easily integrated into your application.
import { SignIn } from '@clerk/clerk-react';
function App() {
return (
<div>
<SignIn />
</div>
);
}
User Profile Management
This feature allows users to manage their profile information. The UserProfile component provides a pre-built user profile management interface that can be easily integrated into your application.
import { UserProfile } from '@clerk/clerk-react';
function App() {
return (
<div>
<UserProfile />
</div>
);
}
Authentication Guard
This feature allows you to protect routes and components based on the user's authentication status. The SignedIn and SignedOut components can be used to conditionally render content, and RedirectToSignIn can be used to redirect unauthenticated users to the sign-in page.
import { RedirectToSignIn, SignedIn, SignedOut } from '@clerk/clerk-react';
function App() {
return (
<div>
<SignedIn>
<h1>Welcome, User!</h1>
</SignedIn>
<SignedOut>
<RedirectToSignIn />
</SignedOut>
</div>
);
}
Other packages similar to @clerk/clerk-react
auth0-react
Auth0 React SDK provides authentication and authorization functionalities similar to @clerk/clerk-react. It allows developers to integrate Auth0's authentication services into their React applications. Compared to @clerk/clerk-react, Auth0 offers a broader range of authentication methods and integrations.
firebase
Firebase provides a comprehensive suite of backend services, including authentication, database, and storage. Firebase Authentication can be used to manage user sign-up, sign-in, and profile management. Compared to @clerk/clerk-react, Firebase offers a more extensive set of backend services beyond just authentication.
next-auth
NextAuth.js is a complete open-source authentication solution for Next.js applications. It provides a flexible and extensible way to handle authentication in Next.js. Compared to @clerk/clerk-react, NextAuth.js is more tailored for Next.js and offers a wide range of authentication providers.
@clerk/clerk-react
Overview
Clerk is the easiest way to add authentication and user management to your React application. Add sign up, sign in, and profile management to your application in minutes.
Getting Started
Prerequisites
Installation
npm install @clerk/clerk-react
Build
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.
If using Create React App, set REACT_APP_CLERK_PUBLISHABLE_KEY
to your Publishable key in your .env.local
file to make the environment variable accessible on process.env
and pass it as the publishableKey
prop.
import { render } from 'react-dom';
import { ClerkProvider, SignedIn, SignedOut, SignInButton, UserButton } from '@clerk/clerk-react';
const publishableKey = process.env.REACT_APP_CLERK_PUBLISHABLE_KEY;
render(
<ClerkProvider publishableKey={publishableKey}>
<App />
</ClerkProvider>,
document.getElementById('root'),
);
function App() {
return (
<>
<h1>Hello Clerk!</h1>
<SignedIn>
<UserButton afterSignOutUrl={window.location.href} />
</SignedIn>
<SignedOut>
<SignInButton mode='modal' />
</SignedOut>
</>
);
}
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/clerk-react
follows good practices of security, but 100% security cannot be assured.
@clerk/clerk-react
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.