Back to Apollo Client

ApolloProvider

docs/source/api/react/ApolloProvider.mdx

3.14.1871 B
Original Source

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.

js
import { ApolloProvider } from "@apollo/client/react";

Props

OptionTypeDescription
clientApolloClientAn ApolloClient instance.

Example

jsx
const client = new ApolloClient({
  cache: new InMemoryCache(),
  link: new HttpLink({
    uri: "http://localhost:4000/graphql",
  }),
});

ReactDOM.render(
  <ApolloProvider client={client}>
    <MyRootComponent />
  </ApolloProvider>,
  document.getElementById("root")
);