Skip to content

fix(web): suppress hydration warning on <body>#248

Merged
Siri-Ray merged 1 commit intomainfrom
fix/body-hydration-warning
May 2, 2026
Merged

fix(web): suppress hydration warning on <body>#248
Siri-Ray merged 1 commit intomainfrom
fix/body-hydration-warning

Conversation

@lefarcen
Copy link
Copy Markdown
Contributor

@lefarcen lefarcen commented May 2, 2026

Summary

Browser extensions like YouMind, Grammarly, and ColorZilla inject attributes onto <body> before React hydrates, producing a "server rendered HTML didn't match client" console error in development.

<html> already had suppressHydrationWarning; mirror it on <body> so any extension that mutates the body element no longer surfaces a false-positive hydration mismatch to end users.

Repro (from #243)

User had the YouMind extension installed, which injects youmind-sidebar-open and youmind-extension-version onto <body>. Next.js dev mode then logged:

A tree hydrated but some attributes of the server rendered HTML didn't match the client properties.
app/layout.tsx (24:7) @ RootLayout

Adding suppressHydrationWarning on <body> is the official Next.js-recommended fix for extension-induced mismatches (docs).

Test plan

  • pnpm -C apps/web dev with YouMind (or any extension that mutates body) installed β€” verify no hydration error in console
  • Verify SSR'd HTML and client render still match for our own attributes (we don't set any on body, so this is a no-op for us)

Closes #243

Browser extensions (e.g. YouMind, Grammarly, ColorZilla) inject
attributes onto <body> before React hydrates, producing a
"server rendered HTML didn't match client" console error in dev.

`<html>` already had suppressHydrationWarning; mirror it on `<body>`
so any extension that targets the body element no longer surfaces
a false-positive hydration mismatch to end users.

Closes #243
Copy link
Copy Markdown
Contributor Author

@lefarcen lefarcen left a comment

Choose a reason for hiding this comment

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

LGTM πŸŽ‰

Clean minimal fix that mirrors the existing suppressHydrationWarning on <html>. Verified:

  • βœ… No server-side <body> attribute mutations in codebase (all document.body usage is client-side-only)
  • βœ… Prop name correct (suppressHydrationWarning per React 18 API)
  • βœ… Matches Next.js official recommendation for extension-induced hydration mismatches

P3 nits (non-blocking):

  • Test plan checkboxes unchecked β€” unclear if actually tested with YouMind/Grammarly
  • Future-proofing: if we ever add <body className={...}> in SSR, a real mismatch would be silently suppressed. (Unlikely given current arch, but worth noting for future readers.)

Ready to ship. 🚒

@Siri-Ray Siri-Ray merged commit 27ef18b into main May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix Fixes an existing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

My Open Design keeps reporting an error that I don't know how to resolve. It's related to YouMind

2 participants