Skip to main content

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 to react-native-fbsdk-next.

Why Migrate?

  • expo-facebook is no longer maintained or supported
  • react-native-fbsdk-next provides more features and better performance
  • Access to the latest Facebook SDK features and security updates
  • Better TypeScript support
  • Active community and maintenance

Installation

First, uninstall expo-facebook and install react-native-fbsdk-next:
or with yarn:

For Expo Projects

If you’re using Expo, add the config plugin to your app.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 the expo-facebook API functions and their react-native-fbsdk-next equivalents:

Code Migration Examples

Initialization

Before (expo-facebook):
After (react-native-fbsdk-next):

Login

Before (expo-facebook):
After (react-native-fbsdk-next):

Logout

Before (expo-facebook):
After (react-native-fbsdk-next):

Getting Access Token

Before (expo-facebook):
After (react-native-fbsdk-next):

Logging Events

Before (expo-facebook):
After (react-native-fbsdk-next):

Logging Purchases

Before (expo-facebook):
After (react-native-fbsdk-next):

Setting User Data

Before (expo-facebook):
After (react-native-fbsdk-next):

React Native Version Compatibility

Make sure you’re using a compatible version of React Native:
Attention: Versions after 4.2.0 only support React Native versions above 0.63.3, as it’s the oldest version that supports the latest Xcode version. While it may work on older versions, they are not officially supported.

Native Configuration Changes

iOS Changes

You’ll need to update your Info.plist and AppDelegate:

Info.plist

Ensure these keys are present:

AppDelegate.m (Objective-C)

Add the required imports and initialization:

Android Changes

Update your AndroidManifest.xml and strings.xml:

strings.xml

AndroidManifest.xml

Enabling Auto App Installs in Expo

To enable auto app installs tracking in Expo:
Then in your app code (iOS only):

Features Not Available

The following expo-facebook features are not available in react-native-fbsdk-next:

getAdvertiserIDAsync()

This method is not supported. Use AppEventsLogger.getAdvertiserID() as an alternative, though it may return different data.

getPermissionsAsync()

Not directly supported. After login, you can access granted permissions from the AccessToken:

requestPermissionsAsync()

Not supported. Use LoginManager.logInWithPermissions() to request additional permissions:

Testing Your Migration

After migrating, test these key flows:
  1. Login flow - Ensure users can log in successfully
  2. Token retrieval - Verify access tokens are obtained correctly
  3. Event logging - Check that events appear in Facebook Analytics
  4. Logout - Confirm users can log out properly
  5. 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 Token

iOS Build Errors

After migration, run:
If you still have issues, try:

Android Build Errors

Clean your Android build:

Need Help?

If you encounter issues during migration:
  1. Check the Troubleshooting Guide
  2. Review GitHub Issues
  3. Consult the Facebook SDK Documentation

See Also