<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Manish Kumar Sahu</title>
    <description>The latest articles on Forem by Manish Kumar Sahu (@manishsahu001).</description>
    <link>https://forem.com/manishsahu001</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3610585%2Fa03b5f67-1334-40f1-98d2-822cf62da9c9.jpg</url>
      <title>Forem: Manish Kumar Sahu</title>
      <link>https://forem.com/manishsahu001</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/manishsahu001"/>
    <language>en</language>
    <item>
      <title>What is Hydration in Next.js ⚠️?</title>
      <dc:creator>Manish Kumar Sahu</dc:creator>
      <pubDate>Sat, 15 Nov 2025 21:41:48 +0000</pubDate>
      <link>https://forem.com/manishsahu001/what-is-hydration-in-nextjs--mh9</link>
      <guid>https://forem.com/manishsahu001/what-is-hydration-in-nextjs--mh9</guid>
      <description>&lt;p&gt;When you use Next.js, the page render twice:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;On the Server Side (SSR) :-&lt;/strong&gt; In this process HTML is generated.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;On the Client (Browser):-&lt;/strong&gt; React hydrates that HTML and attaches the event listeners.
Think of hydration as: “React wakes up the static HTML and converts it into an interactive app.”
For hydration to work, the HTML that the server generates must match the HTML that React generates in the browser.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If they don’t match → Next.js throws a hydration error.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Eg:- Server generated HTML = A&lt;br&gt;
Browser generated HTML = B&lt;br&gt;
React is confused&lt;br&gt;
Hydration breaks&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ficmw0d55gd3jx2srqi7m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ficmw0d55gd3jx2srqi7m.png" alt=" " width="800" height="386"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Reason - Why Does This Happen?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;1.&lt;strong&gt;Using browser-only APIs during SSR&lt;/strong&gt;:- &lt;br&gt;
Server → window doesn't exist → error&lt;br&gt;
Client → window exists → mismatch&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const width = window.innerWidth;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.&lt;strong&gt;Using Date, Math.random(), or dynamic values during render&lt;/strong&gt;:- Server timestamp ≠ client timestamp → mismatch.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;p&amp;gt;{Date.now()}&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3.&lt;strong&gt;Conditionally rendering components differently on server vs client&lt;/strong&gt;:- &lt;br&gt;
Server → window undefined → renders nothing&lt;br&gt;
Client → window exists → renders sidebar&lt;br&gt;
Mismatch → hydration error.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{typeof window !== "undefined" &amp;amp;&amp;amp; &amp;lt;Sidebar /&amp;gt;}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4.&lt;strong&gt;Fetching data differently on server and client&lt;/strong&gt;:- You might accidentally:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fetch server-side once&lt;/li&gt;
&lt;li&gt;Fetch client-side again with a different result
This changes HTML → mismatch.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How to Fix Hydration Issues?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;1.&lt;strong&gt;Wrap client-only code inside useEffect&lt;/strong&gt;:- Anything using window, document, localStorage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const [width, setWidth] = useState(null);
useEffect(() =&amp;gt; {
  setWidth(window.innerWidth);
}, []);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Server renders nothing → client fills it later.&lt;/p&gt;

&lt;p&gt;2.&lt;strong&gt;Avoid Date.now() or Math.random() directly in render&lt;/strong&gt;:- Use useEffect or calculate once.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const [time, setTime] = useState(null);
useEffect(() =&amp;gt; setTime(Date.now()), []);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3.&lt;strong&gt;Use dynamic import for client-only components&lt;/strong&gt;:- Example: charts, maps, heavy UI.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const Chart = dynamic(() =&amp;gt; import("../Chart"), { ssr: false });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the component loads only on client → no mismatch.&lt;/p&gt;

&lt;p&gt;4.&lt;strong&gt;Make sure data is consistent between server and client&lt;/strong&gt;:- Use server-only fetching (app router) or React Query with proper hydration.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Hydration errors happen when the HTML React expects in the browser doesn’t match the HTML generated by Next.js on the server.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>frontend</category>
      <category>fullstack</category>
      <category>development</category>
    </item>
    <item>
      <title>Things I Wish I Knew as a Fresher Developer on My First Project</title>
      <dc:creator>Manish Kumar Sahu</dc:creator>
      <pubDate>Fri, 14 Nov 2025 15:57:11 +0000</pubDate>
      <link>https://forem.com/manishsahu001/things-i-wish-i-knew-as-a-fresher-developer-on-my-first-project-4bjl</link>
      <guid>https://forem.com/manishsahu001/things-i-wish-i-knew-as-a-fresher-developer-on-my-first-project-4bjl</guid>
      <description>&lt;p&gt;If you’ve just joined a company as a fresher and you’re lucky enough to get a project early, there are a few important things you should always keep in mind:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Don’t hesitate to discuss your task.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Don’t hesitate to ask questions.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Don’t hesitate to ask for help from seniors.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Stick to the ETA you commit.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;If you realize midway that the ETA isn’t enough, highlight it immediately. Don’t wait for the catch-up call.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Document your work.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Don’t be shy to talk about your work.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;If you’re doing great and you stay silent about it, nobody will know the effort you’re putting in.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Always talk about your work. Always.&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you don’t communicate, it may reflect poorly on your performance. And if you’re stuck somewhere, ask your senior in a polite way — don’t rush or panic. Seniors have more responsibilities, so your patience and clarity matter.&lt;/p&gt;

&lt;p&gt;Discuss technical things with them, take guidance, understand how they think. This will help you grow faster and understand your role and responsibilities from a senior perspective.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwlijco93ar008mb6e4tk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwlijco93ar008mb6e4tk.png" alt=" " width="800" height="580"&gt;&lt;/a&gt;&lt;br&gt;
Most freshers (including me once) make a very common mistake:&lt;br&gt;
When a task is assigned and the TL or RM asks for an ETA, let’s say you say 3 hours. Freshers usually start coding immediately — and that’s the biggest mistake.&lt;/p&gt;

&lt;p&gt;Instead, spend the first 30 minutes understanding the requirement properly. Take a pen and paper, or open Excalidraw. Think through the flow, break the task down, understand what exactly needs to be done.&lt;/p&gt;

&lt;p&gt;Once the flow is clear, then start writing the code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7idiop1zj1m55292lcm3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7idiop1zj1m55292lcm3.png" alt=" " width="800" height="795"&gt;&lt;/a&gt;&lt;br&gt;
You may face challenges depending on the complexity — that’s absolutely normal. Let’s say coding takes 1.5 hours. At this point, you’ve already used 2 hours. Now, if your gut feeling says the 3-hour ETA is not enough, immediately inform your TL or RM. Don’t wait to be asked.&lt;/p&gt;

&lt;p&gt;Now you still have 1 hour left. Since you’ve already communicated the risk, your mind will be calmer, and your TL/RM will also be aware. Use that remaining time to push as much as possible, and if needed, take help from a senior.&lt;/p&gt;

&lt;p&gt;And lastly — don’t forget to document your work.&lt;br&gt;
And during catch-up calls, openly talk about your analysis, what you faced, and how you solved it. It builds trust and shows ownership.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>career</category>
      <category>beginners</category>
      <category>developers</category>
    </item>
  </channel>
</rss>
