Authentication
Optare provides secure authentication for your users with email/password, social providers, and enterprise SSO.
Sign Up
Create a new user account with email and password.
import { authClient } from '@optare/client'
await authClient.signUp.email({
email: 'user@example.com',
password: 'secure-password',
name: 'John Doe'
})Sign In
Authenticate existing users.
await authClient.signIn.email({
email: 'user@example.com',
password: 'secure-password'
})Session Management
Check if a user is authenticated.
const session = await authClient.getSession()
if (session) {
console.log('User:', session.user)
}Sign Out
End the user's session.
await authClient.signOut()Password Reset
Allow users to reset their password.
// Request reset email
await authClient.forgetPassword({
email: 'user@example.com'
})
// Reset with token
await authClient.resetPassword({
token: 'reset-token',
password: 'new-password'
})Email Verification
Verify user email addresses.
// Send verification email
await authClient.sendVerificationEmail({
email: 'user@example.com'
})
// Verify with token
await authClient.verifyEmail({
token: 'verification-token'
})Two-Factor Authentication
Enable 2FA for enhanced security.
// Enable 2FA
const { secret, qrCode } = await authClient.twoFactor.enable()
// Verify 2FA code
await authClient.twoFactor.verify({
code: '123456'
})
// Disable 2FA
await authClient.twoFactor.disable({
password: 'user-password'
})Social Authentication
Sign in with social providers.
// Redirect to provider
authClient.signIn.social({
provider: 'google',
callbackURL: '/auth/callback'
})Supported providers:
- GitHub
- Microsoft
- Apple
Next Steps
- Organizations - Multi-tenant access control
- API Reference - Complete API documentation
- Security - Best practices