React authentication libraries

Updated Nov 2026

React authentication libraries sign users in and give components access to the current session. Most connect the app to a hosted identity provider or a server-side auth framework through hooks, providers, and prebuilt sign-in components. These libraries let apps protect pages and API calls for signed-in users.

Popularity

Better Auth has the most monthly downloads in this comparison, at 72.7M.

LibraryMonthly downloadsStarsLast releaseLicense
Better Auth
72.7M
30.8KNov 2026MIT
NextAuth.js
36.3M
28.4KJul 2026ISC
Clerk
16.8M
1.8KNov 2026MIT
Auth0 React
8.9M
992Oct 2026MIT
MSAL React
7.1M
4.2KNov 2026MIT
@react-oauth/google
6.5M
1.3KApr 2026MIT
react-oidc-context
4.2M
1.0KMar 2026MIT
@workos-inc/authkit-react
2.3M
48Sep 2026MIT
Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Libraries and code examples

Provides an authentication framework for TypeScript.

Downloads / mo
72.7M
Stars
30.8K
Last release
1.7.26
License
MIT

Quickstart

From client.mdx
$ npm i better-auth
import { createAuthClient } from "better-auth/react";
const authClient = createAuthClient({ baseURL: "http://localhost:3000" });
const { data: session, error } = await authClient.getSession();

Better Auth examples

From open-source projects on GitHub

Connects React session controls to authentication configured in a Next.js application.

Downloads / mo
36.3M
Stars
28.4K
Last release
4.24.15
License
ISC

Strengths

  • Configures sign-in providers in Next.js. Configure the providers in the application's own Next.js authentication route.
  • Controls the client session payload. Choose which extra session fields reach the browser.

Limitations

  • Credentials users are not persisted. Store account records through the application's existing authentication system.
  • Provider tokens need explicit exposure. Add provider access tokens through JWT and session callbacks.

Quickstart

From example.md
$ npm install next-auth
import { SessionProvider, useSession } from "next-auth/react";
function Session() {
  const { data: session, status } = useSession();
  return <pre>{status}</pre>;
}
export default function App() {
  return <SessionProvider><Session /></SessionProvider>;
}

NextAuth.js examples

From open-source projects on GitHub

Provides authentication components and user-management hooks for React applications.

Downloads / mo
16.8M
Stars
1.8K
Last release
6.19.0
License
MIT

Strengths

  • Provides ready-made sign-in controls. Use prebuilt sign-in and sign-up components for the application.
  • Retrieves session or custom tokens. Use getToken for the current session or a custom JWT template.

Limitations

  • Requires a Clerk application. Create a Clerk application and configure its publishable key.
  • Authentication state can reload. Check isLoaded before depending on the current authentication state.

Quickstart

From index.tsx
$ npm install @clerk/react
import { ClerkProvider, SignInButton } from "@clerk/react";
export default function App() {
  return <ClerkProvider><SignInButton /></ClerkProvider>;
}

Connects React single-page applications to Auth0 authentication and authorization.

Downloads / mo
8.9M
Stars
992
Last release
2.30.0
License
MIT

Strengths

  • Handles protocol and token renewal. Delegate grant details, token renewal, storage, and caching to the SDK.
  • Exposes authentication through React hooks. Read user state and invoke login or logout through useAuth0.

Limitations

  • Redirect URLs must be registered. Register callback, logout, and web origins for the deployed app.
  • Custom routers need redirect handling. Supply onRedirectCallback when using a custom client router.

Quickstart

From README.md
$ npm install @auth0/auth0-react
import { Auth0Provider, useAuth0 } from "@auth0/auth0-react";
function Login() {
  const { loginWithRedirect } = useAuth0();
  return <button onClick={() => loginWithRedirect()}>Log in</button>;
}
export default function App() {
  return <Auth0Provider domain="YOUR_AUTH0_DOMAIN" clientId="YOUR_AUTH0_CLIENT_ID"
    authorizationParams={{ redirect_uri: window.location.origin }}><Login /></Auth0Provider>;
}

Auth0 React examples

From open-source projects on GitHub

Integrates Microsoft authentication and token acquisition into React single-page applications.

Downloads / mo
7.1M
Stars
4.2K
Last release
5.8.2
License
MIT

Strengths

  • Supports Microsoft account sign-in. Authenticate work, school, or personal Microsoft accounts.
  • Acquires tokens for Microsoft APIs. Request tokens to call services such as Microsoft Graph.

Limitations

  • Needs a registered Microsoft app. Register a client ID and the app’s redirect routes.
  • Hook attempts authentication once. Call its login or acquireToken method for subsequent attempts.

Quickstart

From getting-started.md
$ npm install @azure/msal-react @azure/msal-browser
import { PublicClientApplication } from "@azure/msal-browser";
import { MsalProvider, useMsal } from "@azure/msal-react";
const pca = new PublicClientApplication({ auth: { clientId: "client-id" } });
function Login() {
  const { instance } = useMsal();
  return <button onClick={() => instance.loginPopup()}>Login</button>;
}
export default function App() { return <MsalProvider instance={pca}><Login /></MsalProvider>; }

MSAL React examples

From open-source projects on GitHub

@react-oauth/google

Adds Google OAuth sign-in to React through Google Identity Services.

Downloads / mo
6.5M
Stars
1.3K
Last release
0.13.5
License
MIT

Quickstart

From README.md
$ npm install @react-oauth/google
import { GoogleOAuthProvider, GoogleLogin } from '@react-oauth/google';

function App() {
  return (
    <GoogleOAuthProvider clientId="<your_client_id>">
      <GoogleLogin
        onSuccess={credentialResponse => {
          console.log(credentialResponse);
        }}
        onError={() => {
          console.log('Login Failed');
        }}
      />
    </GoogleOAuthProvider>
  );
}

react-oidc-context

Provides OpenID Connect and OAuth authentication with React context for state management.

Downloads / mo
4.2M
Stars
1.0K
Last release
3.3.1
License
MIT

Quickstart

From README.md
$ npm install oidc-client-ts react-oidc-context --save
import { AuthProvider, useAuth } from "react-oidc-context";
function Login() {
  const auth = useAuth();
  return <button onClick={() => void auth.signinRedirect()}>Log in</button>;
}
export default function App() {
  return <AuthProvider authority="https://issuer.example.com" client_id="client-id"
    redirect_uri={window.location.origin}><Login /></AuthProvider>;
}

@workos-inc/authkit-react

Provides the AuthKit React SDK.

Downloads / mo
2.3M
Stars
48
Last release
0.16.3
License
MIT

Quickstart

From README.md
$ npm install @workos-inc/authkit-react
import { AuthKitProvider, useAuth } from "@workos-inc/authkit-react";
function Login() {
  const { signIn } = useAuth();
  return <button onClick={() => signIn()}>Sign in</button>;
}
export default function App() {
  return <AuthKitProvider clientId="client_01ABC123DEF456"><Login /></AuthKitProvider>;
}

FAQ

NextAuth.js suits Next.js apps that configure sign-in providers in their own authentication route. Clerk suits apps that want prebuilt sign-in components on a hosted Clerk application. MSAL React suits apps that sign in Microsoft work, school, or personal accounts.

Better Auth is an authentication framework for TypeScript.

NextAuth.js connects React session controls to authentication configured in a Next.js application. Its callbacks choose which extra session fields reach the browser.

Auth0 React exposes user state, login, and logout through a React hook. The app's callback, logout, and web origin URLs must be registered with the identity provider.

Clerk provides authentication components and user-management hooks for React. It requires a Clerk application with a publishable key.

For coding agents

Found your authentication library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official