AuthProvider. Provides access to the current authentication state and functions to login, logout, and check auth status.
Signature
Returns
string | null
Error message if authentication failed, null otherwise
boolean
Whether the user is currently authenticated
boolean
Whether the initial authentication check has completed. Check this before rendering authenticated content to avoid flashing unauthenticated state.
() => Promise<void>
Initiates the login process. Redirects the user to the Tailor Platform authentication page.
() => Promise<void>
Logs out the current user. Clears authentication tokens and user session.
() => Promise<AuthState>
Checks the current authentication status. Makes a network request to verify auth status and attempts to refresh tokens internally if they are expired.
Usage
Basic Authentication Flow
Protected Content
Handling Authentication Errors
Manual Auth Status Check
Prerequisites
This hook must be used within anAuthProvider component:
Related
- Authentication - Complete authentication setup guide
AuthProvider- Authentication provider componentcreateAuthClient()- Create authentication clientuseAuthSuspense()- Suspense-compatible authentication hook