<?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: Athashri Keny</title>
    <description>The latest articles on Forem by Athashri Keny (@athashri_keny).</description>
    <link>https://forem.com/athashri_keny</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%2F3612182%2Fe8c50b3f-a983-4cbe-a14a-beb29d241127.jpeg</url>
      <title>Forem: Athashri Keny</title>
      <link>https://forem.com/athashri_keny</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/athashri_keny"/>
    <language>en</language>
    <item>
      <title>Next.js SSR vs CSR vs SSG which is best to use and when to use?</title>
      <dc:creator>Athashri Keny</dc:creator>
      <pubDate>Wed, 21 Jan 2026 03:37:54 +0000</pubDate>
      <link>https://forem.com/athashri_keny/nextjs-ssr-vs-csr-vs-ssg-which-is-best-to-use-and-when-to-use-3ffi</link>
      <guid>https://forem.com/athashri_keny/nextjs-ssr-vs-csr-vs-ssg-which-is-best-to-use-and-when-to-use-3ffi</guid>
      <description>&lt;p&gt;These names feels confusing first, but when you understood it deeply its much easier than you think! &lt;/p&gt;

&lt;p&gt;SSR (Server-Side Rendering) ,CSR(client Side Rendering) , SSG(Static Side Generation). These all are web page rendering methods&lt;/p&gt;

&lt;p&gt;Let's first dive in&lt;br&gt;
&lt;strong&gt;SSR&lt;/strong&gt;: In SSR(Server-Side rendering) server renders the full html for every request and sends it to the browser. because it is rendered on server not in the client side ie in Brower the page loads quickly.&lt;/p&gt;

&lt;p&gt;pros: SSR is great when you want a good SEO rating on your webpage. For eg news websites , landing pages . but there is a catch you need to have a good server which is capable of handling a ton of requests. &lt;/p&gt;

&lt;p&gt;Cons: Due to heavy load on server these can can cost you a good amount of server bills.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CSR&lt;/strong&gt;: (client side rendering) In CSR, the server sends a minimal HTML shell to the browser. JavaScript then runs in the browser to fetch data and render the content dynamically.&lt;br&gt;
 After the page has been loaded for the first time, navigating to other pages is typically faster because it doesn't require a full page reload - only the necessary data is fetched via API calls, and JavaScript updates the DOM dynamically.&lt;/p&gt;

&lt;p&gt;pros: CSR is great if your data changes consistently on a page. and you don't care about SEO at all. CSR can be used in fetching user data , a live score match etc. and server load is less.&lt;/p&gt;

&lt;p&gt;Cons: Slow initial load. your app takes a noticeable amount of time to load user can feel this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SSG:&lt;/strong&gt; In SSG (Static Site Generation), HTML pages are pre-built at build time (during deployment), not at runtime. These pre-rendered HTML files are served to users on every request, without needing to generate them again.&lt;/p&gt;

&lt;p&gt;pros: SSG offers a fast-performance , excellent seo, reduces server load (this can be lead to lower server bills).&lt;/p&gt;

&lt;p&gt;Cons: All pages are built at the time of the build so this can cause a longer built time, and the content is only updated when site is build again.&lt;/p&gt;

&lt;p&gt;Final Thoughts&lt;br&gt;
Choose based on your needs:&lt;br&gt;
Need SEO + real-time data? → SSR&lt;br&gt;
Building an interactive app? → CSR&lt;br&gt;
Content rarely changes? → SSG&lt;/p&gt;

&lt;p&gt;Thanks for reading i hoped it helped you!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>nextjs</category>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Why useSession() Is undefined on First Load in Next.js When Deployed to Production (and how i fixed it)</title>
      <dc:creator>Athashri Keny</dc:creator>
      <pubDate>Wed, 14 Jan 2026 21:03:49 +0000</pubDate>
      <link>https://forem.com/athashri_keny/why-usesession-is-undefined-on-first-load-in-nextjs-when-deployed-to-production-and-how-i-fixed-53n1</link>
      <guid>https://forem.com/athashri_keny/why-usesession-is-undefined-on-first-load-in-nextjs-when-deployed-to-production-and-how-i-fixed-53n1</guid>
      <description>&lt;p&gt;When I deployed my SaaS (Next.js app) to production, I noticed something strange. On the first load, my console showed session undefined, but when I refreshed the page (for example /dashboard), everything worked perfectly. Even more confusing, this never happened on localhost—it only happened in production. At first, I thought my auth token was broken, but it turned out it wasn’t. This blog explains what was actually happening, why this bug appears only in production, and how to fix it properly.&lt;/p&gt;

&lt;p&gt;The setup I was using was very common: Next.js (App Router), NextAuth, useSession() on the client, and a protected dashboard page.&lt;/p&gt;

&lt;p&gt;he problem appeared on the initial page load. I had the following code:&lt;br&gt;
&lt;code&gt;&lt;br&gt;
const { data: session } = useSession();&lt;br&gt;
console.log(session);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The output was undefined. However, after refreshing the page, the output became { user: {...}, expires: "..." }. This raised the main question: why is the session undefined on first load but works after refresh?&lt;/p&gt;

&lt;p&gt;The real reason is that useSession() is asynchronous. This was the key thing I misunderstood at first. When the page renders, React renders components immediately, and at the same time useSession() starts fetching the session. At that moment, the session is not available yet, so console.log(session) prints session = undefined with status = "loading". This is expected behavior.&lt;/p&gt;

&lt;p&gt;This issue does not usually appear on localhost because of speed differences. On localhost, the app is slower, so the session often resolves early before you notice the problem. In production, the app loads much faster, so the render happens before the session is ready, which exposes the issue.&lt;/p&gt;

&lt;p&gt;The correct fix on the client side starts with always checking the session status:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const { data: session, status } = useSession();

if (status === "loading") {
  return null;
}

if (!session) {
  redirect("/login");
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second important fix is guarding your useEffect so it does not run before the session exists:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;useEffect(() =&amp;gt; {
  if (!session) return;

  fetchBills(session.user.id);
}, [session]);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The big lesson I learned from this is that rendering happens before async data is ready, so you should always assume undefined at least once. This does not apply only to useSession(), but also to API calls, database fetches, React Query, and any asynchronous data in React.&lt;/p&gt;

&lt;p&gt;Production bugs don’t mean you’re bad—they mean you’re learning real-world development.&lt;/p&gt;

&lt;p&gt;Thanks for reading. If this helped you, feel free to share or connect with me.&lt;br&gt;
Athashri Keny&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>nextjs</category>
      <category>react</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Deploying Full-Stack Next.js Apps: Vercel vs Render Comparison</title>
      <dc:creator>Athashri Keny</dc:creator>
      <pubDate>Sun, 11 Jan 2026 10:20:50 +0000</pubDate>
      <link>https://forem.com/athashri_keny/deploying-full-stack-nextjs-apps-vercel-vs-render-comparison-ojj</link>
      <guid>https://forem.com/athashri_keny/deploying-full-stack-nextjs-apps-vercel-vs-render-comparison-ojj</guid>
      <description>&lt;p&gt;Hello I am Athashri Keny a full stack web developer , i have created and deployed many full stack projects&lt;/p&gt;

&lt;p&gt;In my Journey and there is my personal opinion which is better&lt;/p&gt;

&lt;p&gt;Choosing the right deployment platform can make or break your portfolio project. After deploying dozens of Next.js apps, here's what you need to know about Vercel vs Render.&lt;/p&gt;

&lt;p&gt;Vercel:&lt;/p&gt;

&lt;p&gt;I am using vercel since long time for deploying and its best platform as specially if you are student or working professional Want College Projects to be deployed At free of cost. Vercel free tier is for you ie vercel hobby plan and trust me that’s enough for you unless you have a bigger projects with such as video streaming platform or such heavy projects. In my opinion pick vercel when you have modern frontend (react , Vue) etc And you prioritize speed.&lt;/p&gt;

&lt;p&gt;Render:&lt;/p&gt;

&lt;p&gt;I tried render when i was in early stage of my learning full stack development in fact my first project i deployed was on render only. Render gives all over the control of the backend. The best part of render i think i that the Always on web-services (no cold starts) But there is a catch Render free tier Always on web-services can shutdown due to inactivity leading to cold starts when opening. This is the worst part of render i think cause if you are student and the recruiter opens the your projects and its inactive for longer period of time leading to slow starts of opening that’s the bad impression to recruiter&lt;/p&gt;

&lt;p&gt;Conclusion&lt;br&gt;
If you are building a modern frontend-heavy Next.js app and want fast deployments with minimal setup, Vercel is the best choice.&lt;br&gt;
If you need more backend control and always-on services for APIs, Render can be a good option, but the free tier has limitations.&lt;br&gt;
For students and portfolio projects, I personally prefer Vercel because of speed, simplicity, and reliability.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>vercel</category>
      <category>nextjs</category>
    </item>
  </channel>
</rss>
