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

CS: Implement SSR compatible dapper context #744

Merged
merged 2 commits into from
Jul 14, 2023
Merged

Conversation

MythicManiac
Copy link
Member

@MythicManiac MythicManiac commented Jul 14, 2023

Implement a workaround for the lack of React Context support on the NextJS serverside rendering process. Context isn't supported as it's often used for state management, but in our case we just need a way to provide the dapper implementation into some global scope which can later be consumed by the components without direct references to the implementation.

The implemented workaround relies on globalThis if it's available (server, newer browsers) or window if it isn't (older browsers). globalThis might persist throughout multiple requests served by the NextJS server, meaning instance-wide serverside caching should be possible to implement in dapper.

Implement a workaround for the lack of React Context support on the
NextJS serverside rendering process. Context isn't supported as it's
often used for state management, but in our case we just need a way to
provide the dapper implementation into some global scope which can later
be consumed by the components without direct references to the
implementation.

The implemented workaround relies on globalThis if it's available
(server, newer browsers) or window if it isn't (older browsers).
globalThis might persist throughout multiple requests served by the
NextJS server, meaning instance-wide serverside caching should be
possible to implement in dapper.
@MythicManiac MythicManiac enabled auto-merge July 14, 2023 01:23
@MythicManiac MythicManiac merged commit 921cecc into master Jul 14, 2023
@MythicManiac MythicManiac deleted the ssr-context branch July 14, 2023 01:24
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.

1 participant