How to use Apollo Client with Remix
Blog post from Apollo
The post explains how to set up Apollo Client with Remix, a newer JavaScript web framework that focuses on using native web APIs to improve the user experience. To do this, two key files are modified: `entry.server.tsx` and `entry.client.tsx`. In `entry.server.tsx`, an instance of `ApolloClient` is created with `ssrMode` set to true, a cache with `InMemoryCache`, and a link that uses `createHttpLink` instead of `uri`. The client is then wrapped in an `ApolloProvider` and passed to the `RemixServer` component. After the promise resolves, the cache value is extracted and set as the global object `__APOLLO_STATE__`. In `entry.client.tsx`, a new instance of `ApolloClient` is created with a URI and `InMemoryCache` that uses the `restore` function to rehydrate the browser's cache. The client is then wrapped in an `ApolloProvider` and passed to the `RemixBrowser` component. With these modifications, GraphQL requests can be made using Apollo Client's hooks, such as `useQuery`, in Remix pages and components.
| Trend | Post Mentions | Total Month Mentions | Posts | Companies | MoM |
|---|---|---|---|---|---|
| Developer Experience | 1 | 239 | 109 | 61 | +10% |
Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.