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.
ApolloProvider
Apollo Client API reference
The ApolloProvider component
The ApolloProvider component uses React's Context API to make a configured Apollo Client instance available throughout a React component tree. This component can be imported directly from the @apollo/client/react package.
JavaScript
1import { ApolloProvider } from "@apollo/client/react";Props
| Option | Type | Description |
|---|---|---|
client | ApolloClient | An ApolloClient instance. |
Example
JavaScript
1const client = new ApolloClient({
2 cache: new InMemoryCache(),
3 link: new HttpLink({
4 uri: "http://localhost:4000/graphql",
5 }),
6});
7
8ReactDOM.render(
9 <ApolloProvider client={client}>
10 <MyRootComponent />
11 </ApolloProvider>,
12 document.getElementById("root")
13);