apollo-client
The industry-leading GraphQL client for TypeScript, JavaScript, React, Vue, Angular, and more. Apollo Client delivers powerful caching, intuitive APIs, and comprehensive developer tools to accelerate your app development.
A JavaScript library that connects your web app to a GraphQL API, it fetches data, caches it intelligently, and automatically updates your UI when the underlying data changes.
Apollo Client is a JavaScript library for connecting a web application to a GraphQL API. GraphQL is an alternative to REST APIs that lets a client describe exactly what data it needs in a single request, rather than calling multiple endpoints and receiving fixed response shapes. Apollo Client handles all of the mechanics of sending those queries, managing the responses, and keeping your UI in sync with the data.
The central feature is its intelligent cache. When your app fetches data — say, a list of users — Apollo Client stores that data locally. The next time your app needs the same data, or data that overlaps with something already cached, it can serve it instantly from the local cache without a network request. The cache is normalized, meaning that if the same user appears in multiple query responses, it is stored once and both responses point to the same record. When data changes (via a mutation — a write operation), the cache updates automatically and any component that was showing the old data re-renders.
Apollo Client integrates with React, Vue, Angular, Svelte, and plain JavaScript. It is TypeScript-first with full type inference. A developer building a web app that uses a GraphQL backend would use Apollo Client to fetch and display data, handle loading and error states, run mutations to update data, and manage all of the application's remote data through a consistent, cached local store. It is installed via npm as @apollo/client and is maintained by Apollo GraphQL.
Where it fits
- Fetch data from a GraphQL API and display it in a React component with automatic loading and error state handling.
- Run a GraphQL mutation to update server data and have Apollo automatically refresh all UI components showing the affected records.
- Cache GraphQL query results locally so your app serves repeated data requests instantly without extra network calls.
- Build a Vue or Angular app that uses GraphQL and shares normalized cached data across all components.