Repository navigation
fix(home): render the developer count in the server HTML - #241
thzgajendra wants to merge 2 commits into
Conversation
Umang01-hash
left a comment
There was a problem hiding this comment.
Reviewed at head 4d86539. The fix does what it claims — I built the static export and the server HTML now contains the real count 21,500+ instead of 0+ (confirmed by reverting just the useState line, which brings 0+ back). Initial state = value on both server and client, so the common case hydrates cleanly.
One change before merge: the count renders via n.toLocaleString() with no fixed locale. Previously the server rendered 0 (locale-invariant) so hydration always matched; now the server bakes the locale-formatted number at build time (Node → 21,500), but a non-en-US browser hydrates and recomputes toLocaleString() → e.g. 21.500 (de-DE) → a React hydration text mismatch. It's cosmetic (React recovers on the client) but hits non-en-US visitors. One-line fix: pin the locale — (n) => `${n.toLocaleString('en-US')}+` (and the default x.toLocaleString('en-US') in CountUp). Happy to approve with that in.
FYI this repo has no ESLint config and CI runs only snyk (no build/lint/test), so none of this is caught automatically.
|
@Umang01-hash Fixed in 2a60e5e: pinned both Checked on a static export in fresh browser contexts:
#423 means React dropped hydration and client-rendered the page, so the mismatch was a bit more than cosmetic. The count-up animation still runs after the fix (de-DE mid-animation showed |
Description:
Fixes #235.
The problem (in plain words)
The homepage says "Trusted by 21,500+ Developers" in a browser, but the HTML the server sends says "Trusted by 0+ Developers". The number is a count-up animation that starts at 0, and the starting value was also what got written into the page. Search engines, AI tools and anything that does not run JavaScript read the raw HTML, so they see a project with no users.
How this fixes it
The count-up component now starts with the real number instead of 0, so the server-rendered HTML contains
21,500+. In the browser, when the number scrolls into view it still counts up from 0 to 21,500 as before. People who prefer reduced motion see the final number with no animation, as before. Onlysrc/components/CountUp.jsxchanges (the homepage trusted-by list is its only user).Diagram
flowchart LR subgraph Before A1[Server renders page] --> B1["HTML: 0+"] --> C1[Browser animates 0 to 21,500] end subgraph After A2[Server renders page] --> B2["HTML: 21,500+"] --> C2[Browser scrolls into view, animates 0 to 21,500] endBreaking Changes (if applicable):
None. The component's props are unchanged and the animation looks the same in a browser.
Additional Information:
How I tested it
Built the site (
yarn install --frozen-lockfile && yarn build) onmainand on this branch and readout/index.html(the same filecurlreturns for the deployed site):Served the built branch output and drove it in a real browser (Playwright): the heading is
21,500+on load, then after scrolling it into view the count goes10,231+,16,704+,20,056+,21,311+and ends at21,500+, so the animation still runs.Coverage
Not applicable: this repository has no unit test suite and the change is one component. Verified through the build output and browser run above.
Checklist:
goimportsandgolangci-lint. (No Go code in this repo.)