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.
id
string
required
Unique identifier for the user
name
string
Display name of the user
email
string
Email address of the user
avatar
string
URL to the user’s avatar/profile picture
[key: string]
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.
replace
boolean
default:false
Use replaceState instead of pushState to avoid adding to browser history
force
boolean
default:false
Force navigation even if already on the same page

AuthOptions

Configuration options for authentication behavior and redirects.
middleware
AuthMiddleware
Authentication middleware type to apply
redirectTo
string
URL to redirect to after authentication
redirectIfAuthenticated
string
URL to redirect to if user is already authenticated
navigationOptions
NavigationOptions
Options for controlling navigation behavior

Context Types

AuthContextType

The authentication context type provided by useAuth() hook.
user
LogtoUser | null
required
The currently authenticated user, or null if not authenticated
isLoadingUser
boolean
required
Indicates if user data is currently being loaded
signIn
(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
signOut
(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
refreshAuth
() => Promise<void>
required
Function to refresh authentication state and user data
enablePopupSignIn
boolean
Whether popup sign-in is enabled

Component Props

AuthProviderProps

Props for the AuthProvider component.
children
React.ReactNode
required
Child components to render within the auth context
config
LogtoConfig
required
Logto configuration object containing endpoint, appId, and resources
callbackUrl
string
Default callback URL for authentication redirects
customNavigate
(url: string, options?: NavigationOptions) => void
Custom navigation function (e.g., for React Router integration)
enablePopupSignIn
boolean
Enable popup-based sign-in flow

CallbackPageProps

Props for the CallbackPage component.
className
string
CSS class name for styling the callback page
loadingComponent
React.ReactNode
Custom component to display during authentication callback processing
successComponent
React.ReactNode
Custom component to display on successful authentication
onSuccess
() => void
Callback function executed on successful authentication
onError
(error: Error) => void
Callback function executed on authentication error

AdditionalPage

Defines additional pages/links for UI components.
URL or path for the page
text
string
required
Display text for the link
icon
React.ReactNode
Optional icon element to display with the link

Usage Example