Overview
The authentication system uses@convex-dev/auth with support for multiple providers including Password, Anonymous, GitHub, and Google OAuth.
Configuration
Auth Config
Location:convex/auth.config.ts:14
Environment Variables
Your Convex deployment URL. Automatically set by Convex.
GitHub OAuth application client ID. Required for GitHub authentication.
GitHub OAuth application client secret. Required for GitHub authentication.
Google OAuth client ID. Required for Google authentication.
Google OAuth client secret. Required for Google authentication.
Auth Setup
Location:convex/auth.ts:23
Providers
The authentication system dynamically loads providers based on available environment variables:Built-in Providers
Email and password authentication provider from
@convex-dev/auth/providers/PasswordAnonymous authentication provider for demo/guest access from
@convex-dev/auth/providers/AnonymousGitHub OAuth provider from
@auth/core/providers/github. Enabled when GitHub credentials are configured.Google OAuth provider from
@auth/core/providers/google. Enabled when Google credentials are configured.Exported Functions
auth
Middleware function for protecting routes and queries.signIn
Function to initiate sign-in flow.signOut
Function to sign out the current user.store
Auth state storage helpers.isAuthenticated
Helper to check if user is authenticated.Callbacks
createOrUpdateUser
Location:convex/auth.ts:26
Callback invoked when a user signs in. Creates new users or updates existing ones.
Parameters
Convex mutation context with database access
Authentication arguments
ID of existing user if found
Authentication provider information
Provider identifier (e.g., “anonymous”, “password”, “github”)
Returns
The user ID (existing or newly created)
Behavior
- For anonymous users: Generates a random name like
User-1234 - For existing users: Returns the existing user ID
- For new users: Creates a user record with profile data and
isAnonymousflag - Automatically sets
isAnonymous: truefor anonymous provider logins