When we use "use client" in a component, we might expect it to behave like older versions of React, where only a single is sent to the client along with a JavaScript bundle that generates the entire DOM tree dynamically in the browser. However, this is not how client components work in Next.js. In Next.js, even after adding "use client", the component is still rendered on the server to generate the initial HTML structure. This server-rendered HTML is sent to the browser to ensure fast loading and SEO benefits. Along with this, a JavaScript bundle is sent to the browser, which enables React to hydrate the component. Hydration involves attaching event listeners, restoring state, and reconciling the React virtual DOM with the pre-rendered server HTML. If the server-generated HTML and the HTML generated during hydration do not match (due to dynamic data, mismatched attributes, etc.), a hydration error will be thrown by Next.js, as React expects the DOM structure to be consistent across both phases.
@beban8109Ай бұрын
Regarding the third option, from the Nextjs documentation: Note: ssr: false option is not supported in Server Components. You will see an error if you try to use it in Server Components. ssr: false is not allowed with next/dynamic in Server Components. Please move it into a client component.
@rgagankumar51914 ай бұрын
Awasome tutorial. Dynamic import is the way best way to tackle hydration errors. Works like a charm. 😊
@cuttingstitching-dressmaki30162 ай бұрын
Hey, what I see is people getting hydration errors after making some code changes in page.tsx but why am I getting this error in boilerplate nextjs code? I think this is rare and dont know why, could there be an installation issue of project?
@BoldLenz2 ай бұрын
Same. I installed the next js project and it was there. Then i pasted on chatgpt and it made some changes to the default fonts etc and it was gone. Now I'm dealing with it carefully so i don't see the error later
@cuttingstitching-dressmaki30162 ай бұрын
@@BoldLenz I am going to delete the project now and reinstall it and see what happens, I just made some changes in boilerplate page.tsx by deleting the boilerplate code and adding my custom code and I got the hydration error, then I started debugging as to what was causing the error and even ctrl-z my way back to boilerplate code but the error still remains! What a start to nextjs journey!
@BoldLenz2 ай бұрын
@cuttingstitching-dressmaki3016 oh. I hope you find a way out of it. Do share with me the solution if you find any. I'll do the same as I'm still figuring out the best shortcut to resolve it forever. (Also, this error just looks bad and doesn't affect the functionality as such. I ignored the error till end eheh and it still worked)
@cuttingstitching-dressmaki3016Ай бұрын
@@BoldLenz Hi, yes I figured out the issue was with the firefox browser I was using, in my new install it gave the same error instantly on firefox again while refreshing the page, this time I made no changes in boilerplate code too but still got the error on refreshing the page. Then I changed the browser to chrome and its gone!! Don't know what the issue was with firefox my default browser, but now I am working in chrome for the time being.
@BoldLenzАй бұрын
@@cuttingstitching-dressmaki3016 Okay. I was already using chrome so I shifted to incognito mode and it's fixed. I mean it's fixed for the time being ; i needed it to vanish as i have to present this in a display. Once done with that I'll fix it through manual ways that include ensuring client and server sides are dealt with correctly along with the correct use of the server-side code in client components.
@uPhanBaАй бұрын
I have a funny question: I switch pages like a normal person and everything is fine, but when I'm like "programmer switches to other pages quickly for 0.2s, the Hydration error appears", the question is: does it have this Hydration error or is it because I switch pages too fast?
@ibrahim_youssef_13.124 ай бұрын
Youuuuuuu aaaare aweeeesomeeee 😍😍😍 , Thanks
@Os_rwt12Ай бұрын
Sir i just created a new next app. And getting same error. I dont know why. I am new in next js
@shubham-ri4reАй бұрын
same here if you get the solution please share
@Os_rwt12Ай бұрын
@shubham-ri4re turn off your extension of browser .and see magic ✨🪄
@Os_rwt12Ай бұрын
@shubham-ri4re ✨
@k303k4 ай бұрын
Thanks a million sir.😊
@DhvanitMonpara2 ай бұрын
Thanks, you saved my day
@edwardgaming56814 ай бұрын
Wonder if all of these won’t affect the seo??
@einfachmax604Ай бұрын
Just if you disable Server-Side-Rendering with dynamic
@mandipSapkota365Ай бұрын
One of the best way is to remove grammarly or other unnecessary extension
@hungnguyentuan19894 ай бұрын
Please next is search debounce and pagination with Server action
@k303k4 ай бұрын
Yess pls sir
@hungnguyentuan19894 ай бұрын
Yup and formik has a new Typescript version, please create video introduce them
@k303k4 ай бұрын
I think yup is good but react hook form and zod works well too.
@shailendraryvensinghАй бұрын
Thank you
@abdurahmonvahobov86844 ай бұрын
first and second ways are similar
@ProgrammingwithUmair3214 ай бұрын
Not really. in second method I am not touching state variable default value.
@Adam-mx8cx22 күн бұрын
Legend
@k303k4 ай бұрын
Hi sir Can I request Jest and Cypress tutorial pls