Integrate Firebase Auth
Learn how to obtain a JSON Web Token (JWT) from Firebase using Firebase's email provider and integrate it with In-App Wallet.
Info
This article covers the steps of integrating Firebase Auth for a React Native app. Firebase steps and the In-App Wallet code may be replicated for React.
- Firebase project
- React App
- Create a react native app with the tool of your choice and install the required packages: - Note that we assume this is a simple app with a single screen App.tsx.
 
- Note that we assume this is a simple app with a single screen 
- Set up a React Native Firebase project by following the prerequisites in the React Native Firebase documentation. 2. Navigate to the Firebase Console and create a new project. 3. Navigate to Authentication > Sign-in method, to enable the Email/Password provider
 
- 
Navigate to your Team > Project > Connect > In-App Wallets in thirdweb dashboard 
- 
To use in-app wallets, choose an existing Project or create a new one.  
- 
In the configuration view, enable Custom JSON Web Token.  
- 
Set the JWKS URI from here 
- 
Set the AUD Value as the Firebase projectId. (Example,custom-auth-53169) 
- 
Select Save changes. 
 
- 
- Firebase auth depends on the - firebase/appand- firebase/authpackages.- To add the packages, run the following command in the project: 
- Add the code snippet below to handle email authentication with Firebase. Note that you need to add UI to allow users to input the email and password fields in your - App.tsxfile:- To handle email authentication with Firebase - Note: You may add a UI to allow users to input email and password fields. 
- Once the user is authenticated, you can listen to - AuthStateChangedevents to get the signed in user. You can then get the JWT from the User object:- To receive the signed in user, listen to the - AuthStateChangedevent. You can add this code in your App.tsx file as well:
- Pass the JWT to the In-App Wallet config in your - App.tsxfile:- After the connectInApp function returns, the ThirdwebProvider will have connected a wallet thereby granting access to all hooks and functionalities. 
- To access the connected account, use the - useActiveAccount()hook: