Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Latest commit

 

History

History
13 lines (7 loc) · 1.09 KB

README.md

File metadata and controls

13 lines (7 loc) · 1.09 KB

react-query + next.js & SSG Example

This example uses react-query and next.js.

What's special?

This example uses SSG, meaning that basically every page is statically generated and could be served straight from the CDN. It also uses react-query's latest CacheProvider API's to be able to render the data statically at build time.

Some caveats

The SSR caching of react-query is not completely done yet. The progress to enable this is being tracked here. We can however already accomplish something similar by hydrating the cache manually trough the queryCache.setQueryData API.

We can use next.js's getStaticProps to get the props for the page. The caveat here is that we need to identify the props by supplying the same query key that we use for useQuery to hydrate the cache.