Firebase Auth
Authenticate your app with Firebase.
This guide explains how to implement Firebase Authentication in your React Native application using our authentication wrapper.
Features
- Email/Password Authentication
- Apple Sign-In
- Google Sign-In (configurable)
- Anonymous Authentication
- Password Reset
- Token Management
- Error Handling
Setup
First, wrap your application with the AuthProvider
:
Usage
Use the useAuth
hook to access authentication functions and state:
Authentication Methods
Email/Password Authentication
Social Authentication
Apple Sign-In
To enable Apple Sign-In:
- Actually, you can follow the Apple Sign-In guide.
- Apple configuration parts are same as in Supabase but when you add your callback url to Apple Developer Console, this time you need to add Firebase callback url.
- You can check: React Native Firebase Social Auth
Google Sign-In
To enable Google Sign-In:
- Uncomment the Google Sign-In configuration in the auth provider
- Configure your Google credentials (eas credentials sha-1 key)
- Use the signInWithGoogle method:
How to get eas credentials sha-1 key?
- Open your Expo project codebase and run:
eas credentials
- Select Platform:
Android
- Using build profile:
development
- Pick the
Keystore: Manage everything needed to build your project
- Set up a new Keystore
- Get your SHA-1 key
When you get your SHA-1 key, you need to add it to Firebase Console.
- Go to Firebase Console
- Open project settings,
- Go to
Your apps
section. - Add SHA-1 key to your app and download google-services.json file.
- Save it to the Expo project codebase.
- You need to rebuild your app with eas or npx prebuild
(prebuild is not going to work because we created this key with eas).
You need to do that for Production build too. You need to integrate with your Play Console.
And I must say again. If you do that steps, you need to create eas development build for testing Google Sign-In.
It is not going to work with npx prebuild.
Anonymous Authentication
Password Reset
Auth State
The useAuth
hook provides several state variables:
Error Handling
The authentication wrapper includes built-in error handling:
- Token expiration management
- Firebase auth error parsing
- Toast notifications for errors
- Automatic token refresh
Sign Out
TypeScript Support
The authentication context is fully typed with TypeScript. The main types include:
Security Considerations
- Automatic token management
- Secure storage of credentials
- Email verification for new accounts
- Proper error handling and user feedback
- Token refresh mechanism
This documentation provides a comprehensive guide for developers implementing Firebase authentication in their applications. It covers all the main features, usage patterns, and important considerations for secure implementation.
Was this page helpful?