⚠️
The vite-plugin-ssr project has been renamed Vike.
  • If you are already using vite-plugin-ssr then migrate to Vike.
  • For new projects, don't use vite-plugin-ssr but use Vike instead.

Relay (GraphQL)

With vite-plugin-ssr we keep control over our app architecture; we can integrate Relay simply by following its SSR docs.

Reading Recommendation.

On a high-level, the SSR integration works like this:
  1. We fetch the initial data on the server-side. (We do it on the server-side so that the initial data is rendered to HTML.)
  2. We make the initial data available as pageContext.initialData.
  3. We make pageContext.initialData available on the browser-side by adding 'initialData' to passToClient.
  4. We initialize Relay on the browser-side using pageContext.initialData.

React Streaming

For using Relay with React Streaming, see:

Example

Example of a deep Relay integration with React 18's new SSR Suspense Render-as-you-Fetch architecture: