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:

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

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

Examples

There are some Apollo examples written in React Native that you may wish to refer to:

  1. The “Hello World” example used at dev.apollodata.com.
  2. A GitHub API Example built to work with GitHub’s new GraphQL API.

If you’ve got an example to post here, please hit the “Edit on GitHub” button above and let us know!

Edit on GitHub