Migrating from expo-facebook
The expo-facebook module was deprecated in Expo SDK 45 and removed in Expo SDK 46. This guide will help you migrate toreact-native-fbsdk-next.
Why Migrate?
expo-facebookis no longer maintained or supportedreact-native-fbsdk-nextprovides more features and better performance- Access to the latest Facebook SDK features and security updates
- Better TypeScript support
- Active community and maintenance
Installation
First, uninstallexpo-facebook and install react-native-fbsdk-next:
For Expo Projects
If you’re using Expo, add the config plugin to yourapp.json or app.config.js:
Important: The
clientToken parameter is required in react-native-fbsdk-next, but was not required in expo-facebook. You can get this value from Facebook Developers > Your App > Settings > Advanced.API Migration Table
The following table shows theexpo-facebook API functions and their react-native-fbsdk-next equivalents:
Code Migration Examples
Initialization
Before (expo-facebook):Login
Before (expo-facebook):Logout
Before (expo-facebook):Getting Access Token
Before (expo-facebook):Logging Events
Before (expo-facebook):Logging Purchases
Before (expo-facebook):Setting User Data
Before (expo-facebook):React Native Version Compatibility
Make sure you’re using a compatible version of React Native:Native Configuration Changes
iOS Changes
You’ll need to update yourInfo.plist and AppDelegate:
Info.plist
Ensure these keys are present:AppDelegate.m (Objective-C)
Add the required imports and initialization:Android Changes
Update yourAndroidManifest.xml and strings.xml:
strings.xml
AndroidManifest.xml
Enabling Auto App Installs in Expo
To enable auto app installs tracking in Expo:Features Not Available
The followingexpo-facebook features are not available in react-native-fbsdk-next:
getAdvertiserIDAsync()
This method is not supported. UseAppEventsLogger.getAdvertiserID() as an alternative, though it may return different data.
getPermissionsAsync()
Not directly supported. After login, you can access granted permissions from theAccessToken:
requestPermissionsAsync()
Not supported. UseLoginManager.logInWithPermissions() to request additional permissions:
Testing Your Migration
After migrating, test these key flows:- Login flow - Ensure users can log in successfully
- Token retrieval - Verify access tokens are obtained correctly
- Event logging - Check that events appear in Facebook Analytics
- Logout - Confirm users can log out properly
- Permission handling - Test both granted and declined permissions
Common Migration Issues
Missing Client Token
If you see errors about a missing client token, make sure you’ve added it to your configuration. Get it from: Facebook Developers > Your App > Settings > Advanced > Client TokeniOS Build Errors
After migration, run:Android Build Errors
Clean your Android build:Need Help?
If you encounter issues during migration:- Check the Troubleshooting Guide
- Review GitHub Issues
- Consult the Facebook SDK Documentation