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

fix: fix broken website CSS by refactoring styled-components SSR logic #257

Merged
merged 1 commit into from
Sep 27, 2024

Conversation

skylarmb
Copy link
Contributor

@skylarmb skylarmb commented Sep 27, 2024

A number of mistakes in the code resulted in the page not being properly server-side rendered in the Next.JS static export. This means all DOM hydration and stylesheet injection was being performed client-side, which defeats the purpose of a static export / SSR with NextJS. This also seemed to be non-deterministic in terms of the order stylesheets were injected into the <head> client-side, which resulted in buggy / unstyled rendering for some users.

The following changes seems to have fixed the issue by restoring expected SSR functionality:

  • Refactor global styles to use createGlobalStyle functionality from styled-components
  • Ensure layout.tsx is server side rendered by moving all context providers to a separate client component.
  • Remove the Suspense boundary that was required for using the NextJS useSearchParams hook. Using native browser APIs (window.location.search) works fine here, so no need for a suspense boundary with this custom hook.

Copy link

Deploying kardinal with  Cloudflare Pages  Cloudflare Pages

Latest commit: 24bf7fc
Status: ✅  Deploy successful!
Preview URL: https://76b3500f.kardinal.pages.dev
Branch Preview URL: https://sbrown-fix-broken-css.kardinal.pages.dev

View logs

@skylarmb skylarmb merged commit 505e885 into main Sep 27, 2024
5 checks passed
@skylarmb skylarmb deleted the sbrown/fix-broken-css branch September 27, 2024 19:37
leoporoli pushed a commit that referenced this pull request Sep 30, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.3.2](0.3.1...0.3.2)
(2024-09-28)


### Bug Fixes

* add the --service flag in the kardinal flow telepresence intercept
command ([#259](#259))
([5d22282](5d22282))
* fix broken website CSS by refactoring styled-components SSR logic
([#257](#257))
([505e885](505e885))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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.

2 participants