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.
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.
Nest Auth0ComponentProvider in your authentication provider (Auth0Provider). This configuration allows access to authentication state and token acquisition methods required to call Auth0 APIs.
toastSettingsToast settings support two provider types: Sonner (default) or custom. Each provider has its own configuration structure for better type safety.
Sonner Provider (Default)
Custom Provider
Property
Type
Default
Description
provider
"sonner"
"sonner"
Uses the built-in Sonner toast library
settings.position
ToastPosition
"top-right"
Position where toasts appear: “top-left”, “top-right”, “bottom-left”, “bottom-right”, “top-center”, “bottom-center”
settings.duration
number
4000
Duration in milliseconds before toast auto-dismisses (Sonner default)
settings.maxToasts
number
-
Maximum number of toasts visible at once
settings.dismissible
boolean
true
Whether toasts can be manually dismissed by user interaction (Sonner default)
settings.closeButton
boolean
true
Whether 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 }};
All custom methods are optional. Only implement the ones you need. Methods
receive the message text only - your implementation handles styling,
positioning, and timing.
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.
Property
Type
Default
Description
enabled
boolean
true
Toggle caching altogether. When set to false, stale data is
disabled and cached entries are cleared quickly.
staleTime
number
120000
Milliseconds before data becomes stale. Default is two minutes. Increase
for dashboards, decrease for critical workflows.
gcTime
number
300000
Milliseconds before inactive queries are garbage-collected. Default is five minutes.
refetchOnWindowFocus
boolean | “always”
false
Controls 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.
toastSettingsToast settings support two provider types: Sonner (default) or custom. Each provider has its own configuration structure for better type safety.
Sonner Provider (Default)
Property
Type
Default
Description
provider
"sonner"
"sonner"
Uses the built-in Sonner toast library
settings.position
ToastPosition
"top-right"
Position where toasts appear: “top-left”, “top-right”, “bottom-left”, “bottom-right”, “top-center”, “bottom-center”
settings.duration
number
4000
Duration in milliseconds before toast auto-dismisses (Sonner default)
settings.maxToasts
number
-
Maximum number of toasts visible at once
settings.dismissible
boolean
true
Whether toasts can be manually dismissed by user interaction (Sonner default)
settings.closeButton
boolean
true
Whether 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 }};
All custom methods are optional. Only implement the ones you need. Methods receive the message text only - your implementation handles styling, positioning, and timing.
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.
Property
Type
Default
Description
enabled
boolean
true
Toggle caching altogether. When set to false, stale data is
disabled and cached entries are cleared quickly.
staleTime
number
120000
Milliseconds before data becomes stale (two minutes by default). Increase
for dashboards, decrease for critical workflows.
gcTime
number
300000
Milliseconds before inactive queries are garbage-collected (five minutes by
default).
refetchOnWindowFocus
boolean | “always”
false
Controls 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 5 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.
toastSettingsToast settings support two provider types: Sonner (default) or custom. Each provider has its own configuration structure for better type safety.
Sonner Provider (Default)
Custom Provider
Property
Type
Default
Description
provider
"sonner"
"sonner"
Uses the built-in Sonner toast library
settings.position
ToastPosition
"top-right"
Position where toasts appear: “top-left”, “top-right”, “bottom-left”, “bottom-right”, “top-center”, “bottom-center”
settings.duration
number
4000
Duration in milliseconds before toast auto-dismisses (Sonner default)
settings.maxToasts
number
-
Maximum number of toasts visible at once
settings.dismissible
boolean
true
Whether toasts can be manually dismissed by user interaction (Sonner default)
settings.closeButton
boolean
true
Whether 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 }};
All custom methods are optional. Only implement the ones you need. Methods
receive the message text only - your implementation handles styling,
positioning, and timing.
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.
Property
Type
Default
Description
enabled
boolean
true
Toggle caching altogether. When set to false, stale data is
disabled and cached entries are cleared quickly.
staleTime
number
120000
Milliseconds before data becomes stale (two minutes by default). Increase
for dashboards, decrease for critical workflows.
gcTime
number
300000
Milliseconds before inactive queries are garbage-collected (5 minutes by
default).
refetchOnWindowFocus
boolean | “always”
false
Controls 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 5 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.