252

I am getting the following warning from my Next.js application:

Warning: Extra attributes from the server: data-new-gr-c-s-check-loaded,data-gr-ext-installed,cz-shortcut-listen,data-lt-installed

I don't know why it happens. What is the explanation for this?

21 Answers 21

561

This is usually caused by an extension passing these extra attributes with your code when it is executed on the browser trying to interact with the UI, this creates a mismatch between what was rendered on the server and what is rendered on the client.

Extensions similar to Grammarly, ColorZilla and LanguageTool are therefore the cause of this warning, so you have to find out which one is doing this and then disable/configure it to not run on the ports you usually use for development. This is the straightforward fix for the warning, since it is always recommended to avoid extensions in development.


You can find those extra attributes if you inspect the app pure HTML in the Elements section of the devTools

enter image description here

An abbreviation is usually used, like here, lt stands for LanguageTool, gr for Grammaly, and cz for ColorZilla. this can help detect the extension.


Good to know:

You can suppress hydration warnings by setting suppressHydrationWarning to true in the opening <body> tag of the RootLayout:

export default RootLayout({ children }) {
  return (
   <html lang="en">
      <body suppressHydrationWarning={true}>
        {children}
      </body>
    </html>
  )
}

sometimes you have to put it in the opening <html> tag if attributes are added there

<html lang="en" suppressHydrationWarning={true}>

suppresshydrationwarning only works one level deep so if you put it in the <html> element, it won't suppress hydration warnings for the <body> element since it is in a deeper level, that's great! because we don't want to suppress hydration warnings for our server components which are in a deeper level.

Sign up to request clarification or add additional context in comments.

20 Comments

I added the attribute and it worked. Then I removed the extensions which I've not used since ages and also removed the attribute and it worked too. Thanks for your answer, it helped me clean up my browser : youtube.com/…
This suppressHydrationWarning prop fixed it for me, but the error should specify which element is throwing the error. Mine was input, form, and button elements within my server actions (which are experimental still, so that might be the issue).
@douglasrcjames It is not an error it is a warning, and it will not harm anything, what is more recommended is to disable extensions when developing
<body suppressHydrationWarning={true}> works well
What about production? What if the final user does have that extension? Will that cause the hydration to also fail but just without showing an error?
|
139

Disabling the Grammarly extension solved the problem for me.

You could upvote https://chromewebstore.google.com/reviews/9c74943a-2ebb-4f73-af5f-2b2945c97349 to lobby Grammarly to fix their extension.

5 Comments

It's little strange, disabling both grammarly and colorzilla extentions fixed the issue.
I had a problem with Grammarly, if someone use other one, need to disable that also for fixing the error.
If we run the code in incognito mode, there will be no such warnings.
Deserves upvote - still valid. After killing Colorzilla and Grammerly, I still had the error. Plugins are turned off in Chrome Incognito for me, where the errors vanished. I suspect is was another plugin contributing to the error.
For me, I tried to disable all the extensions with no luck. Moving to another browser (Firefox) fixed the issue. But does anyone know another solution for Chrome?
57

Chrome has released a new feature to disable extensions for specific URLs which is great, since this warning seems to just be a development environment issue. Simply put chrome://flags/#extensions-menu-access-control into your Chrome browser to enable this flag and restart Chrome.

After you restart you can click on the extensions icon (in the upper-right corner of your browser), while you are browsing http://localhost:3000 URL, to toggle off your extensions for that URL (only)! No need for the suppressHydrationWarning={true} prop mentioned above.

enter image description here

3 Comments

This is brilliant, if you're developing on Chrome it's the way to go. It's also a generally useful Chrome tip - thanks for sharing.
Thanks for this tip. I had other extensions that I didn't want to use while I am working.
It doesn't work for me, I can't black list a specific URL origin with this.
38

disabling ColorZilla extension solved the problem for me.

Comments

19

Stop ColorZilla and Grammarly extensions fix my problem.

enter image description here

Update: more extensions that are causing related issues:

  • ColorZilla
  • Grammarly
  • Wikiwand: Wikipedia Modernized
    • Error message: Warning: Extra attributes from the server: style
    • Solution: Change Site Access extension option, from On all sites to on specific sites and enter the URL: https://*.wikipedia.org/*

1 Comment

Add Urban VPN extension to the list
10

Just wanted to add to this - if anyone is using chrome extension Grammarly or similar extensions, this causes the same issue as it adds these attributes to the <body/> tag

I was getting the same warning and could not figure it out, I thought it was my UI library but then with some help from the community we were able to figure out it from from a chrome extension.

Once I removed Grammarly this warning never came back! Hope this helps anyone else in the same situation that gets directed to this post!

1 Comment

UrbanVPN extension was the one causing it for me
6

You should add suppressHydrationWarning on the html tag.

<html lang="en" suppressHydrationWarning>
  <body className={`${inter.className} antialiased`}>
    <ThemeProvider
      attribute="class"
      defaultTheme="system"
      enableSystem
      disableTransitionOnChange
    >
      {children}
    </ThemeProvider>
  </body>
</html>

Comments

5

In my case Disabling the Grammarly and ColorZilla extension solved the problem.

Comments

5

Since this seems to be an issue in development, the following worked for me:

export default function RootLayout({ children }: RootLayoutProps) {
    const isDev = process.env.NODE_ENV === 'development'

    return (
        <html lang="en" suppressHydrationWarning={isDev}>
            <body className={inter.className}>
                <AppProvider>
                    <MainLayout>
                        {children}
                    </MainLayout>
                </AppProvider>
            </body>
        </html>
    )
}

This makes it so you won't have to change your browser settings in every browser you cross test in.

1 Comment

This isn't a development-only issue, because browser extensions run in production too.
4

1. Disable extensions

The warning message you're seeing in your JavaScript console, specifically:

Warning: Extra attributes from the server: cz-shortcut-listen...

is related to some attributes being sent from the server that your code might not be handling properly or expecting. This warning is typically not critical and doesn't prevent your application from running, but it's a good practice to address it to ensure that your code remains clean and maintainable.

Temporarily disable browser extensions, except for those required for development in your browser. Browser extensions can sometimes interfere with the behavior of web applications, including altering the content of network requests or injecting additional attributes into HTML elements.

or

2. Prevent hydration

Add suppressHydrationWarning={true} in the opening tag of <body>.

Example: <body className={inter.className} suppressHydrationWarning={true}> your code</body>

Example

2 Comments

adding suppressHydrationWarning={true} did not solve the problem for me, rather adding just suppressHydrationWarning on the html tag solved it as metioned in ans by Raja P.B.
2

This warning message indicates that there are some extra attributes on the HTML element that Next.js received from the server that it does not recognize. These attributes are added by various browser extensions, plugins, or toolbars that modify the HTML of the page.

In your case, the attributes data-new-gr-c-s-check-loaded, data-gr-ext-installed, and cz-shortcut-listen are likely being added by one or more browser extensions that are installed in your browser. These attributes are not recognized by Next.js, which is why it is warning you about them.

To get rid of the warning, you can filter out the data-* attributes that next.js does not recognize by using the dangerouslySetInnerHTML prop on the element.

<div 
    dangerouslySetInnerHTML = {{
        __html: htmlString.replace(
            / data-(?!react[\w-]+=)[\w-]+="[^"]*"/g,
            ''
        ),
    }}
/>

2 Comments

How should I set the dangerouslySetInnerHTML? Should I do it on the <body> tag in the layout.tsx(_app.tsx)? And what should I replace htmlString with since I don't really know where the browser extension could have injected those attributes?
what a horrible idea... bulk string replacement in innerHTML. For anyone considering doing this ... don't.
2

In the app folder and your layout.js file should be like below:

import { Inter } from "next/font/google";
import "./globals.css";

const inter = Inter({ subsets: ["latin"] });

export const metadata = {
  title: "Create Next App",
  description: "Generated by create next app",
};

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body className={inter.className} suppressHydrationWarning={true}>
        {children}
      </body>
    </html>
  );
}

1 Comment

This worked for me by adding suppressHydrationWarning={true} to the body tag as follows : <body className={inter.className} suppressHydrationWarning={true}>{children}</body>
2

There are many Google Extensions for CSS measurements and edits. Most of them are producing errors.

So, after disabling the Measurement extension for the page removed the error.

Comments

2

To avoid this error go to the extensions and switch off your developer mode.

Comments

1

also if you are using multiple route layouts with html / body and then you have a top level one also with html / body elements, it will cause this error.

If you are experiencing this, remove all children group layouts html / body elements and just leave them at the top root one

Comments

1

Mostly ColorZilla extension in chrome is the main culprit. But there might be some other extensions. You can check by disabling all the installed extensions one by one. Hence its not a critical error. You can ignore this error for your next.js application development.

To disable extensions in chrome check the 3 dot icon at the top right corner. Then go to Extensions -> Manage Extensions.

Comments

1

GSAP and NextJS

Adding another posibility case because nobody aproched that here. Using GSAP library for animations.

To solve this issue i aproched the solution posted here (by a gsap creator): https://gsap.com/community/forums/topic/35440-warning-extra-attributes-from-the-server-style/?do=findComment&comment=190094

This is how it worked out:

this file is gonna be the same to everyone.

// useIsomorphicLayoutEffect.ts 
import { useLayoutEffect, useEffect } from "react";

const useIsomorphicLayoutEffect =
  typeof window !== "undefined" ? useLayoutEffect : useEffect;

export default useIsomorphicLayoutEffect;

here make sure to add the plugins you will use.

// components/RegisterComponent.tsx
"use client";

import gsap from "gsap";
import { ScrollTrigger } from "gsap/dist/ScrollTrigger";
import useIsomorphicLayoutEffect from "./useIsomorphicLayoutEffect ";

const RegisterComponent = () => {
  useIsomorphicLayoutEffect(() => {
    gsap.registerPlugin(ScrollTrigger);
  }, []);

  return null; // The component does not render anything, it's just for registering plugins
};

export default RegisterComponent;

and finally, your animation:

"use client"

import gsap from "gsap";
import { useGSAP } from "@gsap/react";
import RegisterComponent from "./gsapRegister";

export default function AnimationContainer() {
    const element = <div></div>

    // special useEffect for gsap code:
    useGSAP(() => {
        // just to show it:
        gsap.to(element, {})
    })
    return (
        <div>
            <RegisterComponent/>
            {/* everything else under */}
        </div>
    )
}

Versions

"gsap": "^3.12.5",
"next": "^14.2.14",
"@gsap/react": "^2.1.1",

Hope it helps!!

Comments

1

Open your localhost on the Incognito tab to solve all of these issues.

It worked for me, no need to disable extensions.

Comments

0

I had a problem with the 1688.com plugin that analyzes images in my browser. After disconnecting the problem was solved.

Comments

0

I am using next js wiht next themes, the next themes was the one that adds classes & styles causing it to show warnings. What solves my issue is, by adding this to <html> on root layout

suppressHydrationWarning={true}

Comments

0
import { ThemeProvider, StyledEngineProvider } from "@mui/material/styles";
import { AppRouterCacheProvider } from "@mui/material-nextjs/v14-appRouter";
import InitColorSchemeScript from "@mui/material/InitColorSchemeScript";
import { CssBaseline } from "@mui/material";
    
  <AppRouterCacheProvider>
        <StyledEngineProvider injectFirst>
          <ThemeProvider
            theme={theme}
            modeStorageKey={themeKey}
            colorSchemeStorageKey={colorMode}
          >
            <InitColorSchemeScript attribute={""} />
            <CssBaseline />
            {children}
          </ThemeProvider>
        </StyledEngineProvider>
      </AppRouterCacheProvider>

For config theme provider in mui with nextjs 14 app router

1 Comment

Thank you for your interest in contributing to the Stack Overflow community. This question already has quite a few answers—including one that has been extensively validated by the community. Are you certain your approach hasn’t been given previously? If so, it would be useful to explain how your approach is different, under what circumstances your approach might be preferred, and/or why you think the previous answers aren’t sufficient. Can you kindly edit your answer to offer an explanation?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.