Repository navigation
fix(ssr): render each page for the device that asked for it — mobile CLS 0.98 → 0.0 - #785
Merged
Merged
Conversation
…80px 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]>
…er for useResponsive Part of #782. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Part of #782 (carries #774's last acceptance box). Co-Authored-By: Claude Fable 5.1 <[email protected]>
This was referenced Sep 17, 2026
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
The server now renders each page for the device that asked for it. Fixes #782, and carries #774's last acceptance box (the budget ratchet).
@scaffald/ui(feat(useResponsive): take the server snapshot from a ServerViewportProvider ui#29, merged, pointer bumped here):useResponsiveanduseWindowDimensionstake their server snapshot from a newServerViewportProviderinstead of a constant 1280×900. React uses the same snapshot for the hydration render, so the first client render still matches the server; after hydration the measured width takes over as before. Default unchanged.apps/scaffald/utils/server-viewport.ts):Sec-CH-UA-Mobile: ?1→ phone, else a coarse UA sniff → phone / tablet / desktop, mapped to a snapshot inside each breakpoint band (390 / 820 / 1280). The three loaders that existed spread it into their data;/,/terms,/privacy,/support,/contactand/authgain a loader whose only job is the hint.useServerViewportHintand mounts the provider above everything. Loaders are the only server-side code that sees the request anduseLoaderData()only answers for its own route, so the hook reads the same two placesuseLoaderDatadoes — expo-router'sServerDataLoaderContexton the server,__EXPO_ROUTER_LOADER_DATA__on the client's first render — once, in a state initialiser. Theexpo-router/build/...import is not a public path; its shape is typed and pinned by SDK 56, so an upgrade that moves it fails the typecheck rather than silently rendering desktop for everyone..lighthouserc.jsonbudgets set from measured medians plus ~15% headroom, stillwarn; the ratchet rule (lower when a PR beats a number, never raise) is in the workflow comment.Numbers
Production export,
expo serve, Lighthouse 12.8 mobile preset, median of 3. Same rig as #783./jobs, mobile presetmainbefore #783Server HTML for a phone UA now carries the phone layout (hamburger, no search input); a desktop UA gets the desktop one. Both carry the 11 job cards from #783.
Hydration
Three loads per page per device on the production build (
/jobs,/jobs/<slug>,/users/<slug>,/,/terms× phone 390 with an iPhone UA, tablet 800 with an iPad UA, desktop 1440): zero "Hydration failed" errors. Onmain's build the same probe at phone width re-laid out every page.One thing the probe did surface that is not this PR:
/jobs/<slug>and/users/<slug>throw React #418 (the hydration-failed error, minified) once per load onmain's production build too, at every width, anonymous./jobs,/and/termsdo not. Filed as #786 with the evidence.Limits, stated
viewportLoaderas they come up.Verification
@scaffald/ui: 3 new server-render tests (default → desktop; 390 provided →isMobile,useWindowDimensions390;undefined→ default) plus the existing 16.tsc, biome clean.Request).scaffald-apptypecheck green, biome clean,pnpm prepushgreen.🤖 Generated with Claude Code