Skip to main content
Early Access: This feature is currently in Early Access. By using it, you agree to the applicable Free Trial terms in Okta’s Master Subscription Agreement. Learn about release stages →

Prerequisites

Auth0 Account: Sign up at auth0.com - React 16.11+: This package supports React 16.11.0 and above, including React 17, 18, and 19 - Tailwind CSS 3+: Follow the Tailwind CSS installation guide

Installation

npm install @auth0/universal-components-react react-hook-form @auth0/auth0-react
npm/pnpm: Installs the package with required peer dependencies (react-hook-form and @auth0/auth0-react).shadcn: Installs component source code and @auth0/universal-components-core dependency for shared utilities and Auth0 integration.

Quick Start

1. Wrap Your App with Auth0Provider and Auth0ComponentProvider

App.tsx
import { Auth0Provider } from "@auth0/auth0-react";
import { Auth0ComponentProvider } from "@auth0/universal-components-react/spa";
import "@auth0/universal-components-react/styles";

const authDetails = {
  domain: import.meta.env.VITE_AUTH0_DOMAIN,
};

function App() {
  return (
    <Auth0Provider
      domain={authDetails.domain}
      clientId={import.meta.env.VITE_AUTH0_CLIENT_ID}
      authorizationParams={{
        redirect_uri: window.location.origin,
      }}
    >
      <Auth0ComponentProvider authDetails={authDetails}>
        {/* Your app components */}
      </Auth0ComponentProvider>
    </Auth0Provider>
  );
}

2. Use an Auth0 Universal Component

Components require Auth0 tenant configuration. Check each component’s page for setup requirements.
OrganizationManagementPage.tsx
import { useAuth0 } from "@auth0/auth0-react";
import { OrganizationDetailsEdit } from "@auth0/universal-components-react/spa";

function OrganizationManagementPage() {
  const { isAuthenticated, isLoading } = useAuth0();

  if (isLoading) return <div>Loading...</div>;
  if (!isAuthenticated) return <div>Please log in</div>;

  return (
    <div>
      <OrganizationDetailsEdit />
    </div>
  );
}

Configuration

The Auth0ComponentProvider manages authentication, caching, internationalization, and toast notifications for all components.
<Auth0ComponentProvider
  authDetails={{ domain: "your-tenant.auth0.com" }}
  i18n={{ currentLanguage: "en" }}
  themeSettings={{ mode: "light", theme: "default" }}
>
  {/* Your app components */}
</Auth0ComponentProvider>

Auth0ComponentProvider

Configure authentication, theming, i18n, toast notifications, and TanStack Query caching options

Styling

The stylesheet import in the Quick Start (@auth0/universal-components-react/styles) enables all component styles.
Tailwind v4 users: Add @import "@auth0/universal-components-react/tailwind" to your CSS file.shadcn users: No import needed, styles are already in your Tailwind build.
Customize with CSS variables to match your brand:
:root {
  --primary: #4f46e5; /* your brand color */
  --primary-foreground: #ffffff; /* text on buttons */
}

Styling & Theming Guide

Learn how to customize component appearance to match your brand, including theme presets, dark mode support, CSS variables, and styling options

Example Implementations

See complete working examples in the sample applications.

Code Examples

React SPA (npm), React SPA (shadcn), and Next.js sample applications with full implementation patterns