Skip to main content
Auth0 Universal Components is currently in Early Access. By using it, you agree to the applicable Free Trial terms in Okta’s Master Subscription Agreement. To learn more, read Product Release Stages.
The Auth0ComponentProvider is the orchestration layer for Auth0 Universal Components. Auth0 SDKs manage sessions and tokens, and the Auth0ComponentProvider translates that identity state into a functional, branded UI context. Auth0ComponentProvider makes sure components, such as MFA enrollment, have the necessary permissions, cached data, and styling.

Benefits

Auth0ComponentProvider is the required root wrapper for all Auth0 Universal Components. Benefits to using the wrapper are:
  • Identity Alignment: Bridges the gap between Auth0 SDKs and the My Account API to ensure requests are signed with user-scoped tokens.
  • Performance Optimization: Implements a shared TanStack Query cache specifically tuned for identity workflows to prevent redundant API calls and layout shifts.
  • Design System Consistency: Propagates Tailwind CSS variables and Shadcn-compatible themes across the component tree.
  • Global Feedback: Manages a unified toast notification system for security alerts and workflow status.

Integration architecture

Nest Auth0ComponentProvider in your authentication provider (Auth0Provider). This configuration allows access to authentication state and token acquisition methods required to call Auth0 APIs.

Configure Auth0ComponentProvider

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

function App() {
  return (
    <Auth0Provider
      domain="your-tenant.auth0.com"
      clientId="YOUR_CLIENT_ID"
      authorizationParams={{ redirect_uri: window.location.origin }}
    >
      <Auth0ComponentProvider domain="your-tenant.auth0.com">
        {/* Your app with Auth0 Universal Components */}
      </Auth0ComponentProvider>
    </Auth0Provider>
  );
}

Properties

PropertyTypeRequiredDescription
domainstringYesAuth0 tenant domain (“YOUR_AUTH0_TENANT.auth0.com”).
previewModebooleanNoWhen true, skips API client initialization. Used for documentation previews and demos.
i18nI18nOptionsNoInternationalization settings including currentLanguage and fallbackLanguage.
themeSettingsThemeSettingsNoTheme configuration including mode (light/dark), theme variant (default/minimal/rounded), and CSS variables.
toastSettingsToastSettingsNoToast notification configuration including provider selection (sonner/custom), positioning, duration, and custom toast methods.
cacheConfigQueryCacheConfigNoControls TanStack Query caching (two min stale / five min GC by default). Set enabled: false to force fresh data.
loaderReact.ReactNodeNoCustom loading component to display during authentication initialization.

User experience

i18n

Use the following properties to align the Universal Components with your application’s design system and locale.
PropertyTypeRequiredDefaultDescription
currentLanguagestringYes-Current language code (e.g., “en”, “es”, “fr”)
fallbackLanguagestringNo”en”Fallback language code when translations are missing

themeSettings

PropertyTypeDefaultDescription
mode”light” | “dark""light”Theme color mode
theme”default” | “minimal” | “rounded""default”Theme variant with different styling approaches
variablesStylingVariablesCSS custom properties for common, light, and dark themes
Common (applies to all themes):Typography:
  • --font-size-page-header
  • --font-size-page-description
  • --font-size-heading
  • --font-size-title
  • --font-size-subtitle
  • --font-size-body
  • --font-size-paragraph
  • --font-size-label
Border Radius:
  • --radius-xs through --radius-9xl
Light & Dark (theme-specific colors and shadows):Colors:
  • --background, --foreground
  • --card, --card-foreground
  • --primary, --primary-foreground
  • --secondary, --secondary-foreground
  • --accent, --accent-foreground
  • --muted, --muted-foreground
  • --destructive, --destructive-foreground
  • --popover, --popover-foreground
  • --input, --border, --ring
  • --color-page
  • --color-info, --color-info-foreground
  • --color-success, --color-success-foreground
  • --color-warning, --color-warning-foreground
  • --color-destructive-border
  • --color-popover-border
  • --color-input-foreground
  • --color-input-muted
Shadows:
  • --shadow-bevel-* (xs, sm, md, lg, xl, 2xl)
  • --shadow-button-* (resting, hover, focus)
  • --shadow-button-destructive-*
  • --shadow-button-outlined-*
  • --shadow-input-* (resting, hover, focus)
  • --shadow-input-destructive-*
  • --shadow-checkbox-* (resting, hover)
  • --shadow-switch-* (resting, hover, focus, thumb, thumb-dark)
For detailed styling examples and customization patterns, read the Customize Style and Themes with Universal Components.

toastSettings

Toast settings support two provider types: Sonner (default) or custom. Each provider has its own configuration structure for better type safety.
PropertyTypeDefaultDescription
provider"sonner""sonner"Uses the built-in Sonner toast library
settings.positionToastPosition"top-right"Position where toasts appear: “top-left”, “top-right”, “bottom-left”, “bottom-right”, “top-center”, “bottom-center”
settings.durationnumber4000Duration in milliseconds before toast auto-dismisses (Sonner default)
settings.maxToastsnumber-Maximum number of toasts visible at once
settings.dismissiblebooleantrueWhether toasts can be manually dismissed by user interaction (Sonner default)
settings.closeButtonbooleantrueWhether to show an explicit close button on toasts
Sonner Provider Example
const toastSettings = {
  provider: 'sonner', // Optional, this is the default
  settings: {
    position: 'top-center',
    duration: 6000,
    maxToasts: 5,
    dismissible: true,
    closeButton: true
  }
};

State and performance

Fine-tune TanStack Query caching for every Auth0 component. Defaults keep data fresh for two minutes, garbage-collect after five minutes, and skip window-focus refetches.
PropertyTypeDefaultDescription
enabledbooleantrueToggle caching altogether. When set to false, stale data is disabled and cached entries are cleared quickly.
staleTimenumber120000Milliseconds before data becomes stale. Default is two minutes. Increase for dashboards, decrease for critical workflows.
gcTimenumber300000Milliseconds before inactive queries are garbage-collected. Default is five minutes.
refetchOnWindowFocusboolean | “always”falseControls whether queries refetch when the browser regains focus. Use “always” for strict freshness.
Disable caching: Pass { enabled: false }. This automatically sets staleTime to 0 and shortens the garbage-collection window to five seconds so every render fetches fresh data.Pro tip: Keep caching enabled but shorten staleTime when integrating with admin panels that require near-real-time updates.
<Auth0ComponentProvider
  domain="your-tenant.auth0.com"
  cacheConfig={{
    staleTime: 10 * 60 * 1000,
    gcTime: 15 * 60 * 1000,
    refetchOnWindowFocus: true,
  }}
>
  <App />
</Auth0ComponentProvider>