๐ Authentication
ExpoBase uses a centralized AuthContext
to manage all authentication logic for your app.
๐ง Email Authentication
1. Disable Email Confirmation in Supabase
- Go to your Supabase Dashboard
- Select your project
- Go to Authentication โ Settings
- Under User Signups, disable "Enable email confirmations"
- 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 logicapp/(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:
-
Go to Google Cloud Console:
- Visit Google Cloud Console
- Select your project or create a new one
-
Enable Google Sign-In API:
- Go to APIs & Services โ Library
- Search for "Google Sign-In API"
- Click Enable
-
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
-
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
)
-
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 logicapp/(auth)
folder - Google login buttons
๐ง How It Works
ExpoBase authentication system:
- Centralized Logic: All auth logic is in
AuthContext
- Multiple Providers: Email, Google, Apple (if configured)
- Secure Backend: Powered by Supabase authentication
- Auto Session: Remembers users between app launches
- 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!