Skip to main content
Frontend TypeScript types used in logto-authkit React components and hooks.

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
Options for controlling navigation behavior.
boolean
default:false
Use replaceState instead of pushState to avoid adding to browser history
boolean
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
NavigationOptions
Options for controlling navigation behavior

Context Types

AuthContextType

The authentication context type provided by useAuth() hook.
LogtoUser | null
required
The currently authenticated user, or null if not authenticated
boolean
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-in
  • usePopup - 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-out
  • global - 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 the AuthProvider component.
React.ReactNode
required
Child components to render within the auth context
LogtoConfig
required
Logto configuration object containing endpoint, appId, and resources
string
Default callback URL for authentication redirects
(url: string, options?: NavigationOptions) => void
Custom navigation function (e.g., for React Router integration)
boolean
Enable popup-based sign-in flow

CallbackPageProps

Props for the CallbackPage 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.
URL or path for the page
string
required
Display text for the link
React.ReactNode
Optional icon element to display with the link

Usage Example