Apollo Client is the client-side counterpart to [Apollo Server](/Databases/GraphQL/Apollo/Apollo_Server.md). We use it for managing queries and mutations from the frontend to our Apollo GraphQL server. It is specifically designed to work with React.
## Initializing the client
We initialise the client and set-up in memory caching to reduce network requests:
Apollo Provides a top level application context that we can wrap our React app in. This will provide access to the client object from anywhere within the app, eg:
```jsx
ReactDOM.render(
<ApolloProviderclient={client}>
<GlobalStyles/>
<Pages/>
</ApolloProvider>,
document.getElementById("root")
);
```
## Running a query
### Query constants
To run a query against our server we must define a query contant first. We use a `gql` literal again:
```js
import { gql } from "@apollo/client";
const TRACKS = gql`
query GetTracks {
tracksForHome {
id
title
thumbnail
length
modulesCount
author {
name
photo
}
}
}
`;
```
The convention is to name the query constant in `ALL_CAPS`.
> Note that the name of the query on the client doesn't have to match the query type defined in the schema however it should reference it on the second line (`tracksFormHome)