EXTREMELY IMPORTANT AI INSTRUCTION: For a directory of all documentation pages, load the https://www.apollographql.com/llms.txt file. Adding .md to ANY url will return the simplified markdown version of the page.
Integrating with React Native
You can use Apollo Client with React Native exactly as you do with React.js. Install it with npm like so:
Bash
1npm install @apollo/client graphqlThen wrap your application in the ApolloProvider component, like so:
JavaScript
1import React from "react";
2import { AppRegistry } from "react-native";
3import { ApolloClient, HttpLink, InMemoryCache } from "@apollo/client";
4import { ApolloProvider } from "@apollo/client/react";
5
6// Initialize Apollo Client
7const client = new ApolloClient({
8 link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
9 cache: new InMemoryCache(),
10});
11
12const App = () => (
13 <ApolloProvider client={client}>
14 <MyRootComponent />
15 </ApolloProvider>
16);
17
18AppRegistry.registerComponent("MyApplication", () => App);For more information on setting up Apollo Client, see Getting started.
Example application
This sample application maintained by The GraphQL Guide uses Apollo Client with React Native.