
Sign up to save your podcasts
Or


Our goal here was to explore server-side rendering (SSR) in Next.js using data from Apollo GraphQL, for faster client-rendering and SEO benefits.
There are a variety of approaches, but Shaw has set his sights on a very developer-ergonomic version here where you can leave queries on individual components and mark them as SSR-or-not.
There are two "official" approaches:
These are sorta-kinda-OK, except...
These limitations are workable in some situations, but we want to avoid duplicating code and also have server-side rendered queries that aren't top-level on the page.
A probably-better approach is to use the getDataFromTree method, which walks down the tree and executes the queries to fill up the ApolloClient cache. We got this from a two-year old Gist from Tylerian showing a way to integrate getDataFromTree into Next.js. Tylerian's gist had some extra complications that might've been due to older Next.js limitations, but the overall process was sound:
The benefits:
Here's a repo with Shaw's findings.
By CodePen Blog4.9
8686 ratings
Our goal here was to explore server-side rendering (SSR) in Next.js using data from Apollo GraphQL, for faster client-rendering and SEO benefits.
There are a variety of approaches, but Shaw has set his sights on a very developer-ergonomic version here where you can leave queries on individual components and mark them as SSR-or-not.
There are two "official" approaches:
These are sorta-kinda-OK, except...
These limitations are workable in some situations, but we want to avoid duplicating code and also have server-side rendered queries that aren't top-level on the page.
A probably-better approach is to use the getDataFromTree method, which walks down the tree and executes the queries to fill up the ApolloClient cache. We got this from a two-year old Gist from Tylerian showing a way to integrate getDataFromTree into Next.js. Tylerian's gist had some extra complications that might've been due to older Next.js limitations, but the overall process was sound:
The benefits:
Here's a repo with Shaw's findings.

383 Listeners

289 Listeners

703 Listeners

500 Listeners

625 Listeners

289 Listeners

988 Listeners

1,917 Listeners

961 Listeners

2,125 Listeners

142 Listeners

5,512 Listeners

60 Listeners

467 Listeners

297 Listeners