Skip to content
next

Fix Next.js warning: "Extra attributes from the server: data-new-gr-c-s-check-loaded .. "

Sep 13, 2024Abhishek EH2 Min Read
Fix Next.js warning: "Extra attributes from the server: data-new-gr-c-s-check-loaded .. "

When you are running Next.js application in development mode, you might have seen the following error in developer console:

warning message

In this article, let's see why it occurs and how to fix it.

Why does the warning occur?

Next.js renders the page in Server side and hydrates it in the client side. Once the hydration is done, it compares the HTML rendered in the client with the one sent from the server. If there is mismatch, you will see warnings like these in the console. If you see these kind of warning, that means someone has modified the HTML in the client side.

Who is responsible?

The main culprits here are browser extensions. Browser extensions modify the HTML to apply their own elements and styles. Few examples of the extensions are Grammarly, ColorZilla, and LanguageTool.

attribute added to body tag by extension

Based on the abbreviation used in the error, you can detect the extension: lt stands for LanguageTool, gr for Grammarly, and cz for ColorZilla.

How to prevent the warning

While the warning is not harmful, and you can safely ignore it.

If you still want to hide this warning, you can use the suppressHydrationWarning attribute in your HTML where the warning is occurring. In our case it will be added to the body tag:

layout.js
1import "./globals.css";
2
3export default function RootLayout({ children }) {
4 return (
5 <html lang="en">
6 <body suppressHydrationWarning>
7 <main>{children}</main>
8 </body>
9 </html>
10 );
11}

The suppressHydrationWarning attribute is applied only for that particular element. If you are getting the warning for any other element, you have to pass the attribute there as well.

Do follow me on twitter where I post developer insights more often!

Leave a Comment

© 2024 CodingDeft.Com