When moving a frontend app onto Next.js and GraphQL, it is tempting to pull in a big data library like Apollo Client or Redux Toolkit (RTK Query) right from the start.

Before picking one, we read through the Next.js docs and compared Apollo Client, RTK Query, and the native Fetch API. Next.js already changes how server rendering and caching work, so adding a heavy client-side cache up front mostly adds complexity before you even know where the real pain is.

Stay "stock" until pain proves otherwise

We decided to shed old tech preferences, keep Next.js as stock as possible, and only bring in extra libraries after a real need shows up a few times. To keep common GraphQL and REST calls simple, we wrapped native fetch in three tiny helpers (doFetch, useFetch, and prepFetch):

  • Server or blocking reads (doFetch): Used in getServerSideProps or Server Components to run a query and return { data, errors }.
  • Mount-time client reads (useFetch): A thin useEffect wrapper that runs when a component mounts and returns { data, errors, loading }.
  • Event-driven client calls (prepFetch): Returns { data, errors, fetchQuery, loading } so UI event handlers can trigger a fetch without repeating loading and error state.

Example usage:

// Server Component or SSR
const { data, errors } = await doFetch({ query, uri, variables });

// Client event handler
const { data, errors, fetchQuery, loading } = prepFetch({ uri });
const onSubmit = () => {
  if (!loading) fetchQuery(query, variables, headers);
};

Simple Jest mocking

Keeping the fetch layer thin also makes Jest testing straightforward. In server tests you can mock doFetch directly, and in component tests you can mock the underlying client fetch helper to return fixture data and assert the exact variables and headers sent, with no Redux provider or Apollo cache setup required.