Skip to content

frontend(fix): give Fumadocs the public pathname so docs pages hydrate - #585

Merged
Ducksss merged 1 commit into
mainfrom
claude/inspiring-visvesvaraya-617aee
Oct 1, 2026
Merged

Ducksss merged 1 commit into
mainfrom
claude/inspiring-visvesvaraya-617aee

Conversation

@Ducksss

@Ducksss Ducksss commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

Every Fumadocs docs page threw a React hydration error in production: Minified React error #418 … args[]=text, meaning the server-rendered text didn't match the client. / and the non-docs routes were unaffected.

Root cause

Docs pages are statically prerendered at their internal route, /en/docs/... (the [locale] segment). The proxy serves them at the public URL, /docs/.... fumadocs-ui/provider/next hands Fumadocs next/navigation's raw usePathname(), and that reads differently on each side:

Where usePathname() Initial RSC canonical URL
Static prerender (next build) /en/docs ["","en","docs"]
Browser /docs —
pnpm dev (rendered per request) /docs ["","docs"]

Fumadocs matches its chrome against that pathname: TreeContextProvider → searchPath(tree, pathname). In the static HTML nothing matched, so the mobile TOC trigger (PageTOCPopoverTrigger, path?.name ?? t('On this page')) rendered "On this page" while the client rendered the page title ("Introduction" on /docs). That is the mismatched text node. The same miss also left the prev/next footer and breadcrumb out of the static HTML. Dev renders at the public URL, so it never reproduced there.

I found the node by diffing the server HTML's text nodes (JS disabled) against the hydrated DOM on the live site.

Fix

  • publicPathname() in src/i18n/config.ts maps a route pathname to the URL the browser shows (/en/docs → /docs; /zh/docs is unchanged). It is built on the existing splitLocalePathname / localizeHref.
  • FumadocsRootProvider (src/components/site/FumadocsRootProvider.tsx) wires Fumadocs' RootProvider to Next.js the way fumadocs-ui/provider/next does, except that usePathname returns publicPathname(usePathname()). Client behavior is unchanged, because the browser pathname is already public. The static HTML now matches it.
  • The docs and blog layouts use the new provider. The blog renders no pathname-derived Fumadocs chrome, so it never threw, but it sat on the same stock provider.

No suppressHydrationWarning: nothing here is time-dependent.

Tests

  • e2e hydrates docs pages without React errors (tests/e2e/frontend.e2e.spec.ts) loads /docs, /docs/installation, /docs/components/hero-basic and /docs/design, then asserts no pageerror once the root has hydrated. Against a production build of the unfixed layouts it fails with the exact #418 … args[]=text error; with the fix it passes. It only bites in production mode, which is what CI's test:ci runs.
  • int (tests/int/site-i18n.int.spec.ts) covers the publicPathname cases, checks that nothing in src/ imports fumadocs-ui/provider/next, and checks that both Fumadocs layouts use the site provider. It also fails on the unfixed layouts.

Validation (local, macOS)

  • pnpm lint ✅ · pnpm exec tsc --noEmit ✅ · pnpm format:check ✅
  • pnpm run test:int ✅ 64 files, 795 tests passed (the env-gated pack spec skipped)
  • pnpm build:e2e && PLAYWRIGHT_SERVER_MODE=production pnpm test:e2e frontend ✅ 154 passed, 1 skipped (the Linux-only visual baseline)
  • A production probe in Chromium and WebKit found no pageerror on /docs, /docs/installation, /docs/components/hero-basic, /docs/design, /docs/changelog, /docs/architecture, a blog post, or /. On the live site, /docs, /docs/installation, /docs/components/hero-basic, /docs/design and /docs/changelog all throw #418 today.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved localized URL handling across the documentation and blog, including removal of the English locale prefix from public paths.
    • Prevented uncaught page errors on the tested documentation routes.
  • Tests
    • Added checks for localized paths, provider usage, and error-free documentation pages.

Every docs page threw minified React #418 (server-rendered text did not
match the client) in production. Docs pages are prerendered at their
internal route (/en/docs/...) and served at the public URL (/docs/...).
fumadocs-ui/provider/next hands Fumadocs next/navigation's pathname, which
reads /en/docs while prerendering and /docs in the browser. Fumadocs
matches its chrome against that pathname, so the static HTML missed the
page tree: the mobile TOC trigger said "On this page" where the client
rendered the page title, and the prev/next footer and breadcrumb were
missing. pnpm dev renders on request at the public URL, so it never
reproduced.

publicPathname() maps a route pathname to the URL the browser shows, and
FumadocsRootProvider wires Fumadocs to Next.js like the stock provider
except for that pathname. The docs and blog layouts use it. The blog had
no pathname-derived chrome, but it sat on the same stock provider.

The new frontend e2e check fails on the unfixed production build with the
#418 error and passes with the fix. The int spec covers publicPathname and
rejects stock-provider imports.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vercel

vercel Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
payload-components Ready Ready Preview Oct 1, 2026 2:09am UTC
payload-components-97bf Ready Ready Preview Oct 1, 2026 2:09am UTC

Copilot AI balanced review requested due to automatic review settings October 1, 2026 02:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Repository guideline files applied to this review (1)
AGENTS.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: Ducksss/payload-components/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: fbeafabe-ab5f-4ac5-8728-74020669a0cf

📥 Commits

Reviewing files that changed from the base of the PR and between ac916f5 and 766320e.

📒 Files selected for processing (6)
  • src/app/[locale]/blog/layout.tsx
  • src/app/[locale]/docs/layout.tsx
  • src/components/site/FumadocsRootProvider.tsx
  • src/i18n/config.ts
  • tests/e2e/frontend.e2e.spec.ts
  • tests/int/site-i18n.int.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The docs and blog layouts now use a local Fumadocs provider. It integrates Next.js components and navigation, and supplies Fumadocs with a public localized pathname. Tests cover pathname handling, provider wiring, and docs-route page errors.

Changes

Fumadocs provider integration

Layer / File(s) Summary
Pathname adaptation and provider
src/i18n/config.ts, src/components/site/FumadocsRootProvider.tsx
publicPathname derives a public localized path from the current pathname. FumadocsRootProvider supplies this path and Next.js integrations to FrameworkProvider, then renders RootProvider.
Layout wiring and validation
src/app/[locale]/docs/layout.tsx, src/app/[locale]/blog/layout.tsx, tests/int/site-i18n.int.spec.ts, tests/e2e/frontend.e2e.spec.ts
The docs and blog layouts use FumadocsRootProvider. Tests check pathname normalization, provider wiring, and uncaught page errors on four docs routes.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~15 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 76632

This change fixes the reported docs hydration mismatch by giving Fumadocs the public pathname. No concrete merge-blocking risk was found in the supplied changes.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 76632

The inspected change is limited to how documentation and blog UI interpret localized URLs. No new privileged action or access-control bypass was identified. Risk remains low rather than minimal because the third-party provider’s internal behavior could not be independently verified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • observed — The supplied dependency scope identifies the docs and blog layouts as the adapter’s two direct dependents. Both receive the substituted pathname hook through their provider wrapper.

Trust Boundaries and Controls

  • inferred — For the inspected local code, URL-derived pathname normalization does not introduce a new navigation capability or authorization decision: Next router and params bindings remain in place, and the adapter contains no privileged operation or route dispatch. This conclusion does not establish parity with unavailable dependency internals.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary fix: providing Fumadocs with the public pathname to resolve docs hydration errors.
Description check ✅ Passed The description thoroughly explains the production issue, root cause, implementation, tests, and validation results. It does not reproduce every template heading or checklist item, but the missing sec…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Ducksss
Ducksss merged commit 0fbb889 into main Oct 1, 2026
17 checks passed
@Ducksss
Ducksss deleted the claude/inspiring-visvesvaraya-617aee branch October 1, 2026 11:37

This branch was successfully deployed

2 active deployments
Preview – payload-components-97bf — 766320e2 Deployed Oct 1, 2026 by vercel[bot]
Preview – payload-components — 766320e2 Deployed Oct 1, 2026 by vercel[bot]
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