Fix: Warning: Extra attributes from the server: class, style

The Symptom

You boot up your Next.js application, and while the UI looks completely fine, your browser console is cluttered with an aggressive yellow warning. If you open the site in Incognito Mode, the error magically disappears.

Warning: Extra attributes from the server: class, style
at body
at html
at RootLayout

The Cure

This warning is almost always caused by third-party browser extensions modifying your DOM before React has a chance to hydrate. You must explicitly tell React to ignore attribute mismatches on your root tags.

Immediate Resolution:

Add the suppressHydrationWarning prop to both your <html> and <body> tags in your root layout.tsx.

tsx (app/layout.tsx)
export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    // 1. Add suppressHydrationWarning to HTML to fix theme extensions
    <html lang="en" suppressHydrationWarning>
      {/* 2. Add suppressHydrationWarning to BODY to fix UI extensions */}
      <body suppressHydrationWarning>
        {children}
      </body>
    </html>
  );
}

The Breakdown: Why Extensions Break Next.js

React Hydration is a strict, two-step process:

Adding suppressHydrationWarning to a tag specifically tells React: "Expect the attributes on this specific DOM node to mismatch. Do not throw a warning, and do not try to fix it."

Important Caveats

Do not abuse this prop. It should only be used on <html> and <body> tags, or highly specific elements (like a timestamp). Applying suppressHydrationWarning deep inside your component tree to mask actual rendering bugs will lead to unpredictable UI states and broken interactivity.

Developer Logs

Loading logs...