Skip to content

๐Ÿ” Authentication

ExpoBase uses a centralized AuthContext to manage all authentication logic for your app.

๐Ÿ“ง Email Authentication

1. Disable Email Confirmation in Supabase

  1. Go to your Supabase Dashboard
  2. Select your project
  3. Go to Authentication โ†’ Settings
  4. Under User Signups, disable "Enable email confirmations"
  5. Click Save

Now users can create accounts directly without email confirmation.

2. Ready to Use

Email authentication is already implemented! Users can:

  • โœ… Sign up with email/password
  • โœ… Sign in with email/password
  • โœ… Reset password
  • โœ… Auto login on app restart

Check the implementation in:

  • AuthContext - Authentication logic
  • app/(auth) folder - Login/signup screens

๐Ÿ”‘ Google Authentication

1. Add Google Plugin

Add this plugin to your app.json:

export default {
  expo: {
    plugins: [
      // ... other plugins
      [
        "@react-native-google-signin/google-signin",
        {
          "iosUrlScheme": "com.googleusercontent.apps.692909867915-8g06vk3jlvf3tv395irdj1vmjmhquu66"
        }
      ]
    ],
  },
};

2. Create Google API Keys

For iOS:

  1. Go to Google Cloud Console:
  2. Enable Google Sign-In API:
    • Go to APIs & Services โ†’ Library
    • Search for "Google Sign-In API"
    • Click Enable
  3. Create iOS API Key:
    • Go to APIs & Services โ†’ Credentials
    • Click Create Credentials โ†’ API Key
    • Click Restrict Key
    • Under Application restrictions, select iOS apps
    • Add your bundle identifier: com.yourcompany.yourapp
    • Under API restrictions, select Google Sign-In API
    • Click Save
  4. Create OAuth 2.0 Client:
    • Click Create Credentials โ†’ OAuth 2.0 Client ID
    • Select iOS as application type
    • Enter your app name
    • Enter your bundle identifier: com.yourcompany.yourapp
    • Click Create
    • Copy the Client ID (looks like: 692909867915-8g06vk3jlvf3tv395irdj1vmjmhquu66.apps.googleusercontent.com)
  5. Add to Environment:
    EXPO_PUBLIC_GOOGLE_CLIENT_ID=692909867915-8g06vk3jlvf3tv395irdj1vmjmhquu66.apps.googleusercontent.com
    

3. Ready to Use

Google authentication is already implemented! Users can:

  • โœ… Sign in with Google account
  • โœ… Auto-create account on first login
  • โœ… Link existing accounts

Check the implementation in:

  • AuthContext - Google Sign-In logic
  • app/(auth) folder - Google login buttons

๐Ÿ”ง How It Works

ExpoBase authentication system:

  1. Centralized Logic: All auth logic is in AuthContext
  2. Multiple Providers: Email, Google, Apple (if configured)
  3. Secure Backend: Powered by Supabase authentication
  4. Auto Session: Remembers users between app launches
  5. Protected Routes: Automatic redirect to login if not authenticated

Available Hooks

import { useAuth } from '@/context/AuthContext';
 
const { user, signIn, signUp, signOut, loading } = useAuth();

File Structure

app/(auth)/
โ”œโ”€โ”€ login.tsx          # Login screen
โ”œโ”€โ”€ register.tsx       # Registration screen
โ””โ”€โ”€ forgot-password.tsx # Password reset
 
context/
โ””โ”€โ”€ AuthContext.tsx    # Authentication logic

๐Ÿ” Authentication Ready โœ…

Email and Google Sign-In configured!