Facebook Graph API for React Native

This guide provides examples for using the Facebook Graph API in your React Native applications. The Graph API is the primary way to read from and write to the Facebook social graph.

To read more about the Graph API concepts and features, see Graph API Overview.

Graph Requests

Graph API requests are made using the GraphRequest and GraphRequestManager classes which are loaded from the react-native-fbsdk module.

const FBSDK = require('react-native-fbsdk');
const {
} = FBSDK;

Create a response callback function to handle messages from the API.

_responseInfoCallback(error: ?Object, result: ?Object) {
  if (error) {
    alert('Error fetching data: ' + error.toString());
  } else {
    alert('Success fetching data: ' + result.toString());

Create the graph request and specify the callback function to handle the response. This request queries user information for the currently logged in user.

const infoRequest = new GraphRequest(
new GraphRequestManager().addRequest(infoRequest).start();