How to fix Extra attributes from the server: data-reactroot, data-reactid in React

ReactBEGINNERLOWUpdated Dec 9, 2025ยท 254 views

This warning occurs during React hydration when server-rendered HTML contains attributes that the client-side code doesn't expect. In older React versions (pre-16), data-reactroot and data-reactid were internal attributes used by React. Modern React has removed these attributes, but the warning can still appear due to browser extensions or version mismatches.

Quick fix

Fixes Extra attributes from the server: data-reactroot, data-reactid

{
  "dependencies": {
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  }
}
  1. Verify React versions match on server and client
  2. Use the correct hydration API for your React version
  3. Check for browser extension interference
  4. Upgrade from React 15 to React 16+
react โ€” error
{
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
}
Extra attributes from the server: data-reactroot, data-reactid

What this error means

This warning appears when React's hydration process detects a mismatch between the server-rendered HTML and the client-side React tree. Specifically, the server-rendered markup contains HTML attributes that the client doesn't recognize or expect. In React versions before 16, React automatically added internal attributes like data-reactroot (to mark the root element) and data-reactid (to uniquely identify each component in the tree). These attributes helped React reconcile the DOM during hydration. However, React 16 removed data-reactid entirely, and modern versions no longer add data-reactroot in most cases. If you're seeing this warning in a modern React application, it typically means you're either using an outdated version of React, have a mismatch between your server and client React versions, or browser extensions are injecting unexpected attributes into your HTML. The warning won't break your application, but it indicates that React had to do extra work during hydration, which can impact performance.

Typical symptoms

  • Warning message in browser console: "Extra attributes from the server: data-reactroot, data-reactid"
  • Application still functions normally but shows hydration warnings
  • May see additional attributes like data-reactroot="" on your root element
  • Warning appears only on initial page load, not on client-side navigation
  • Performance may be slightly degraded during hydration

Common causes

  1. Using React 15 or earlier on the server with React 16+ on the client
  2. Mismatch between server-side and client-side React versions
  3. Browser extensions (like Grammarly, password managers) injecting attributes into the DOM
  4. Using ReactDOM.render() instead of ReactDOM.hydrate() for server-rendered content
  5. Outdated build tools or bundler configuration serving old React builds
  6. Custom server rendering that manually adds React internal attributes

How to fix "Extra attributes from the server: data-reactroot, data-reactid"

1Verify React versions match on server and client

Check that your server and client are using the same version of React. Open your package.json and confirm the versions:

json
{
  "dependencies": {
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  }
}

Delete your node_modules and lock file, then reinstall:

bash
rm -rf node_modules package-lock.json
npm install

Rebuild your application to ensure both server and client bundles use the same React version.

2Use the correct hydration API for your React version

For React 16-17, ensure you're using ReactDOM.hydrate() instead of ReactDOM.render():

javascript
// React 16-17
import ReactDOM from 'react-dom';
import App from './App';

const rootElement = document.getElementById('root');
ReactDOM.hydrate(<App />, rootElement);

For React 18+, use hydrateRoot():

javascript
// React 18+
import { hydrateRoot } from 'react-dom/client';
import App from './App';

const rootElement = document.getElementById('root');
hydrateRoot(rootElement, <App />);

Using the wrong API can cause hydration warnings.

3Check for browser extension interference

Browser extensions like Grammarly, LastPass, or React DevTools can inject attributes into your HTML. Test in an incognito/private window with extensions disabled:

Chrome/Edge: Ctrl+Shift+N (Windows) or Cmd+Shift+N (Mac)
Firefox: Ctrl+Shift+P (Windows) or Cmd+Shift+P (Mac)

If the warning disappears, a browser extension is the cause. You can suppress the warning for specific elements:

jsx
<html suppressHydrationWarning>
  <body suppressHydrationWarning>
    {children}
  </body>
</html>

Note: Only use suppressHydrationWarning on elements where you expect external modifications (like <html> or <body>).

4Upgrade from React 15 to React 16+

If you're still on React 15, upgrade to a modern version. React 16 removed data-reactid entirely:

bash
npm install react@latest react-dom@latest

Key migration changes:
- Replace ReactDOM.render() with ReactDOM.hydrate() for SSR
- Remove any code that relies on data-reactid or data-reactroot
- Update server rendering to use renderToString() or renderToStaticMarkup()

After upgrading, clear your build cache:

bash
rm -rf .next  # Next.js
rm -rf build  # Create React App

Rebuild and test your application.

5Ensure consistent server-side rendering

Verify your server-side rendering produces clean HTML without extra React attributes. For static pages or when you don't need hydration, use renderToStaticMarkup():

javascript
import { renderToStaticMarkup } from 'react-dom/server';

// This doesn't add any React attributes
const html = renderToStaticMarkup(<App />);

For pages that need hydration, use renderToString():

javascript
import { renderToString } from 'react-dom/server';

// This adds minimal attributes needed for hydration
const html = renderToString(<App />);

In Next.js, this is handled automatically, but ensure you're not manually adding data-reactroot or data-reactid attributes in custom Document or layout components.

Advanced notes

Historical Context: React 15 and earlier used data-reactid extensively to track component positions in the virtual DOM tree. Each element received a unique ID like "0.0.1.2", forming a hierarchical path. React 16's fiber architecture eliminated the need for these attributes, resulting in cleaner HTML output and smaller payloads.

Version-Specific Behavior:
- React 15: Always adds data-reactroot and data-reactid to all elements
- React 16-17: No data-reactid, data-reactroot only on root with hydrate()
- React 18+: Uses hydrateRoot(), minimal extra attributes

Next.js Considerations: Next.js handles hydration automatically. If you see this warning in Next.js, check for:
- Custom _document.tsx or _app.tsx modifications
- Third-party libraries rendering with old React versions
- Browser extensions (most common cause)

Production Impact: While the warning is cosmetic, hydration mismatches can cause React to discard server-rendered HTML and re-render from scratch, negating SSR performance benefits. In production builds, React may log fewer warnings, but the performance cost remains.

Debugging Technique: Use React DevTools Profiler to measure hydration time. If it's significantly slower than expected, you likely have attribute mismatches forcing React to rebuild the tree.

Frequently asked questions

What does "Extra attributes from the server: data-reactroot, data-reactid" mean?
This warning appears when React's hydration process detects a mismatch between the server-rendered HTML and the client-side React tree. Specifically, the server-rendered markup contains HTML attributes that the client doesn't recognize or expect. In React versions before 16, React automatically added internal attributes like data-reactroot (to mark the root element) and data-reactid (to uniquely identify each component in the tree).
How do I fix "Extra attributes from the server: data-reactroot, data-reactid"?
This warning occurs during React hydration when server-rendered HTML contains attributes that the client-side code doesn't expect. In older React versions (pre-16), data-reactroot and data-reactid were internal attributes used by React. Modern React has removed these attributes, but the warning can still appear due to browser extensions or version mismatches.
What causes "Extra attributes from the server: data-reactroot, data-reactid"?
Using React 15 or earlier on the server with React 16+ on the client Mismatch between server-side and client-side React versions Browser extensions (like Grammarly, password managers) injecting attributes into the DOM
Is the "Extra attributes from the server: data-reactroot, data-reactid" error serious?
It is a low-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading