User Types
LogtoUser
Represents an authenticated user in the application.string
required
Unique identifier for the user
string
Display name of the user
string
Email address of the user
string
URL to the user’s avatar/profile picture
any
Additional custom properties from the identity provider
Authentication Types
AuthMiddleware
Defines the authentication requirement level for a page or route.'auth'- Requires authenticated user'guest'- Allows unauthenticated access (guest mode)undefined- No middleware applied
NavigationOptions
Options for controlling navigation behavior.boolean
default:false
Use
replaceState instead of pushState to avoid adding to browser historyboolean
default:false
Force navigation even if already on the same page
AuthOptions
Configuration options for authentication behavior and redirects.AuthMiddleware
Authentication middleware type to apply
string
URL to redirect to after authentication
string
URL to redirect to if user is already authenticated
Options for controlling navigation behavior
Context Types
AuthContextType
The authentication context type provided byuseAuth() hook.
LogtoUser | null
required
The currently authenticated user, or
null if not authenticatedboolean
required
Indicates if user data is currently being loaded
(callbackUrl?: string, usePopup?: boolean) => Promise<void>
required
Function to initiate sign-in flow
callbackUrl- URL to redirect to after successful sign-inusePopup- Whether to use popup sign-in instead of redirect
(options?: { callbackUrl?: string; global?: boolean }) => Promise<void>
required
Function to sign out the current user
callbackUrl- URL to redirect to after sign-outglobal- Whether to perform global sign-out across all sessions
() => Promise<void>
required
Function to refresh authentication state and user data
boolean
Whether popup sign-in is enabled
Component Props
AuthProviderProps
Props for theAuthProvider component.
React.ReactNode
required
Child components to render within the auth context
LogtoConfig
required
Logto configuration object containing
endpoint, appId, and resourcesstring
Default callback URL for authentication redirects
Custom navigation function (e.g., for React Router integration)
boolean
Enable popup-based sign-in flow
CallbackPageProps
Props for theCallbackPage component.
string
CSS class name for styling the callback page
React.ReactNode
Custom component to display during authentication callback processing
React.ReactNode
Custom component to display on successful authentication
() => void
Callback function executed on successful authentication
(error: Error) => void
Callback function executed on authentication error
AdditionalPage
Defines additional pages/links for UI components.string
required
URL or path for the page
string
required
Display text for the link
React.ReactNode
Optional icon element to display with the link