Authentication Context
Understanding the shared authentication system
Launchtoday provides a centralized authentication system through a React Context provider which you can find here. This context manages all authentication flows, user sessions, and authentication state throughout your application. You can find an example of consuming the auth context in the login screen implementation here.
Auth Context Provider
The authentication context is implemented using React’s Context API and provides a comprehensive set of methods and state for handling user authentication. The provider is already configured in your application’s root component, making authentication services available throughout your app.
Available Methods
The context exposes several authentication methods:
Authentication Flows
Apple Sign In
The signInWithApple
method handles the complete Apple authentication flow:
- Requests user consent through Apple’s native UI
- Manages identity tokens and nonce validation
- Creates or updates the user profile in Supabase
- Establishes the authenticated session
Google Sign In
The signInWithGoogle
method manages OAuth authentication:
- Initiates the OAuth flow through a browser
- Handles redirect and token management
- Processes the authentication response
- Creates or updates the user profile
Magic Link Authentication
The signInWithEmail
method implements passwordless authentication:
- Sends a magic link to the provided email
- Handles email redirect
- Establishes the authenticated session
Session Management
The Auth Context automatically manages user sessions:
- Persists authentication state
- Handles token refresh
- Manages session expiration
- Synchronizes state across the app
Error Handling
The authentication methods include comprehensive error handling:
- User cancellation handling
- Network error management
- Invalid token handling
- Session expiration handling
Next Steps
With the authentication context in place, you can implement specific authentication providers: