Integrating with React Native


You can use Apollo with React Native exactly as you would with React Web.

To introduce Apollo to your app, install React Apollo from npm and use them in your app as outlined in the setup article:

Bash
1npm install @apollo/react-hooks apollo-client graphql --save
JavaScript
1import React from 'react';
2import { AppRegistry } from 'react-native';
3import { ApolloClient } from 'apollo-client';
4import { ApolloProvider } from '@apollo/react-hooks';
5
6// Create the client as outlined in the setup guide
7const client = new ApolloClient();
8
9const App = () => (
10  <ApolloProvider client={client}>
11    <MyRootComponent />
12  </ApolloProvider>
13);
14
15AppRegistry.registerComponent('MyApplication', () => App);

If you are new to using Apollo with React, you should probably read the React guide.

Apollo Dev Tools

React Native Debugger supports the Apollo Client Devtools:

  1. Install React Native Debugger and open it.

  2. Enable "Debug JS Remotely" in your app.

  3. (Optional) If you do not see the Developer Tools panel or the Apollo tab is missing in them, toggle the Developer Tools by right clicking anywhere and selecting "Toggle Developer Tools".

Feedback

Edit on GitHub

Forums