Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(next) - allow subsequent statically generated pages to hydrate the ssr-cache #1602

Merged
merged 2 commits into from
May 3, 2021

Conversation

JoviDeCroock
Copy link
Collaborator

Resolves #1567

Summary

Next will inject data available for a route as JSON, similar to how it does so for the first-page-serve, this is why we have to add a special else branch to account for this scenario.

Set of changes

  • Add check for when a client-side transition introduces new data to hydrate into the SSG page.

@changeset-bot
Copy link

changeset-bot bot commented May 3, 2021

🦋 Changeset detected

Latest commit: 07c1858

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
next-urql Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@JoviDeCroock JoviDeCroock requested a review from kitten May 3, 2021 08:08
@@ -0,0 +1,54 @@
import { initUrqlClient } from "next-urql";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove this page, mainly meant to illustrate/give a testing point for reviewers 😅

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea probably worth removing once you're done 😅

@@ -55,6 +55,8 @@ export function withUrqlClient(
if (!ssr || typeof window === 'undefined') {
// We want to force the cache to hydrate, we do this by setting the isClient flag to true
ssr = ssrExchange({ initialState: urqlServerState, isClient: true });
} else if (ssr && typeof window !== 'undefined') {
ssr.restoreData(urqlServerState);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's really a pleasant surprise!

@JoviDeCroock JoviDeCroock merged commit b501be8 into main May 3, 2021
@JoviDeCroock JoviDeCroock deleted the next-subsequent-ssg-pages branch May 3, 2021 10:34
@github-actions github-actions bot mentioned this pull request May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFC: Support next/link prefetched data in next-urql
2 participants