Skip to main content

Prerequisites

Before installing React Native FBSDK Next, ensure you have:
  • React Native version 0.63.3 or higher
  • A Facebook App ID (create one at Facebook Developers)
  • Xcode 12.0+ (for iOS development)
  • Android Studio (for Android development)
This guide assumes you have a React Native project already set up. If not, create one using:

Step 1: Install the Package

Choose your preferred package manager:

React Native 0.60+

The CLI autolink feature automatically links the native modules.

iOS: Install CocoaPods

For iOS, you need to install the native dependencies using CocoaPods:
If you encounter any issues during pod installation, try:

Android

No additional steps required. The module will be linked automatically.

React Native < 0.60

For React Native versions below 0.60, please refer to the original React Native FBSDK documentation.

Step 3: Configure Android

Follow these steps to configure the Facebook SDK for Android:

3.1 Update android/app/src/main/res/values/strings.xml

Add your Facebook App ID, Client Token, and App Name:
Replace YOUR_FACEBOOK_APP_ID and YOUR_CLIENT_TOKEN with your actual Facebook app credentials from the Facebook App Dashboard.

3.2 Update android/app/src/main/AndroidManifest.xml

Add the following inside the <application> tag:

3.3 Configure Key Hash

Generate your development key hash and add it to your Facebook App settings:
The default password for the debug keystore is android.
Add the generated hash to your Facebook App: Settings > Basic > Key Hashes

Step 4: Configure iOS

The configuration differs based on your React Native version.

React Native >= 0.77 (Swift)

1

Add Required Imports

At the top of your ios/YourApp/AppDelegate.swift file:
2

Initialize Facebook SDK

Inside the application(_:didFinishLaunchingWithOptions:) method:
3

Add openURL Method

This is critical for Facebook SSO to work when the Facebook app is installed:
If you’re using RCTLinkingManager for deep links, Facebook SDK must be checked before RCTLinkingManager to prevent SSO issues.

React Native 0.76 and below (Objective-C)

1

Add Required Imports

At the top of your ios/YourApp/AppDelegate.m file:
2

Initialize Facebook SDK

Inside the didFinishLaunchingWithOptions method:
3

Add openURL Method

4

Create Swift Bridging Header

If you encounter Undefined symbols for architecture errors, create an empty File.swift in your project. Xcode will prompt you to create a Bridging Header - click accept.

Configure Info.plist

Add the following to your ios/YourApp/Info.plist:
Replace YOUR_APP_ID, YOUR_CLIENT_TOKEN, and YOUR_APP_NAME with your actual Facebook app details.

Expo Configuration

This package cannot be used in the “Expo Go” app because it requires custom native code.
For Expo projects using the bare workflow or custom dev client:

Add Config Plugin

In your app.json or app.config.js:

Rebuild Native Code

After configuring the plugin, rebuild your app:

Verify Installation

Create a simple test file to verify the installation:
App.js

Common Issues

Solution: Create an empty File.swift in your iOS project root. When Xcode prompts you to create a Bridging Header, accept it.
Solution: Make sure you’ve implemented the openURL method correctly in your AppDelegate. Without it, the app cannot handle the callback from Facebook.
Solution: Verify that your key hash is correctly configured in the Facebook App Dashboard under Settings > Basic > Key Hashes.
Solution: Ensure you’ve added the FacebookAppID to your Info.plist and called [[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions]; in AppDelegate.

Next Steps

Quick Start Guide

Now that you’ve installed the SDK, learn how to implement Facebook Login in your app