Server-side rendering
There's a good chance you're using React with Server-side rendering (SSR), as many applications require this to be successful. If you happen to be using Next.js, it's really easy to integrate React Async. The crux is in setting a initialValue
, which is fetched server-side for initial page loads and passed along through rehydration.
If React Async is provided an initialValue
, it will not invoke the promiseFn
on mount. Instead it will use the initialValue
to immediately set data
or error
, and render accordingly.
Last updated