Skip to main content
Auth

Features

Email/Password

Users can sign in with their email and password.

Social OAuth

We have Google and Apple OAuth support.

Magic Link

Sending a magic link to the user’s email address

Forgot Password

If your users forget their password, they can reset it.

Verify Email

Users can verify their email address in the app.

How to use?

Currently implemented and fully supported.
import { useAuth } from '@/context/SupabaseProvider';

const {
  user,
  session,
  initialized,
  signOut,
  signIn,
  signUp,
  sendMagicLink,
  signInWithGoogle,
  signInWithApple,
  createSessionFromUrl,
  handleShowPassword,
  isLoading,
  error,
  isAuthenticated,
  showPassword,
  handleError,
  sendNewPasswordLink,
  setNewPassword,
} = useAuth();

Auth Functions

To sign in with email/password, use the signIn function.
signIn('email@example.com', 'password');
To sign up with email/password, use the signUp function.
signUp('email@example.com', 'password');
To sign in with Google, use the signInWithGoogle function.
signInWithGoogle();
To sign in with Apple, use the signInWithApple function.
signInWithApple();
To create a session from a URL, use the createSessionFromUrl function.
Magic happens here. Don’t change this.
To handle show password on the password input, use the handleShowPassword function.
handleShowPassword();
To handle errors, use the handleError function.
handleError(error);
To set a new password, use the setNewPassword function.
setNewPassword('newPassword');
To sign out, use the signOut function.
signOut();

Props

ValueTypeDescription
userUserMetaData | nullContains current authenticated user information
sessionSession | nullContains active session information
initializedbooleanIndicates if auth state has been initialized
signOut() => Promise<void>Signs out the current user
signIn(email: string, password: string) => Promise<void>Signs in user with email/password
signUp(email: string, password: string) => Promise<void>Creates a new user account
sendMagicLink(email: string) => Promise<void>Sends a magic link to user’s email
signInWithGoogle() => Promise<void>Initiates Google OAuth sign in
signInWithApple() => Promise<void>Initiates Apple OAuth sign in
createSessionFromUrl(url: string) => Promise<void>Creates session from URL
handleShowPassword() => voidToggles password visibility
isLoadingbooleanIndicates if auth operation is in progress
errorError | nullContains error information if any
isAuthenticatedbooleanIndicates if user is authenticated
showPasswordbooleanControls password visibility state
handleError`(error: AuthErrorError) => void`Handles auth-related errors
sendNewPasswordLink(email: string) => Promise<void>Sends password reset link
setNewPassword(password: string) => Promise<void>Sets new password