A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://redux-toolkit.js.org/rtk-query/usage/server-side-rendering below:

Server Side Rendering | Redux Toolkit

Server Side Rendering Server Side Rendering with Next.js

RTK Query supports Server Side Rendering (SSR) with Next.js via rehydration in combination with next-redux-wrapper.

The workflow is as follows:

An example repo using next.js is available here.

tip

While memory leaks are not anticipated, once a render is sent to the client and the store is being removed from memory, you may wish to also call store.dispatch(api.util.resetApiState()) to ensure that no rogue timers are left running.

tip

In order to avoid providing stale data with Static Site Generation (SSG), you may wish to set refetchOnMountOrArgChange to a reasonable value such as 900 (seconds) in order to allow data to be re-fetched when accessed if it has been that long since the page was generated.

Server Side Rendering elsewhere

If you are not using next.js, and the example above cannot be adapted to your SSR framework, an unstable__ marked approach is available to support SSR scenarios where you need to execute async code during render and not safely in an effect. This is a similar approach to using getDataFromTree with Apollo.

The workflow is as follows:


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4