Repository navigation
feat(useResponsive): take the server snapshot from a ServerViewportProvider - #29
Merged
Merged
Conversation
…ovider, so the server can render the layout the device will use The hook rendered every page against a constant 1280×900 on the server, so a phone got the desktop layout and re-laid the whole page out at hydration (CLS ≈ 1 on every server-rendered page at phone width), with React regenerating the tree because its shape changed. The provider lets the app choose the snapshot per request; React uses the same snapshot for the hydration render, so the first client render still matches the server. Default unchanged. useWindowDimensions shares the store and now shares the provider. Scaffald/SaaS#782 Co-Authored-By: Claude Fable 5.1 <[email protected]>
thinkclay
added a commit
to Scaffald/SaaS
that referenced
this pull request
Sep 17, 2026
…CLS 0.98 → 0.0 (#785) * fix(ssr): render each page for the device that asked for it, not a 1280px desktop for everyone Part of #782. Needs the @scaffald/ui pointer bump to Scaffald/ui#29. Co-Authored-By: Claude Fable 5.1 <[email protected]> * chore(ui): bump @scaffald/ui to Scaffald/ui#29 — ServerViewportProvider for useResponsive Part of #782. Co-Authored-By: Claude Fable 5.1 <[email protected]> * ci(lighthouse): budgets from measured reality, as a ratchet Part of #782 (carries #774's last acceptance box). Co-Authored-By: Claude Fable 5.1 <[email protected]> --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
Open
18 of 23 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
useResponsive(anduseWindowDimensions, which shares its store) rendered every page against a constant 1280×900 server snapshot. On a phone that means the desktop layout is server-rendered and then replaced at hydration: the whole page moves (CLS ≈ 1 on every SSR page at phone width) and, because the tree changed shape during hydration, React discards the server tree and regenerates it. Measured on scaffald.com's/jobs: Scaffald/SaaS#782.ServerViewportProvider viewport={{ width, height }}+useServerViewport()+DEFAULT_SERVER_VIEWPORT, exported from the package root.useResponsiveanduseWindowDimensionshand the provided snapshot touseSyncExternalStoreasgetServerSnapshot. React also uses that for the hydration render, so server and first client render agree; after hydration the measured width takes over as before.Verification
react-dom/server: default → 1280 desktop; provider 390×844 →isMobile, breakpointbase,useWindowDimensions390; provider withundefined→ default. The 16 existinguseResponsivetests still pass.tsc --noEmitand biome clean./jobsbefore/after in that PR.🤖 Generated with Claude Code