<?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: Shagun Bidawatka</title>
    <description>The latest articles on Forem by Shagun Bidawatka (@shagun).</description>
    <link>https://forem.com/shagun</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%2F1176671%2F62b6664c-e771-4c4e-a038-2dac950082ec.jpeg</url>
      <title>Forem: Shagun Bidawatka</title>
      <link>https://forem.com/shagun</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/shagun"/>
    <language>en</language>
    <item>
      <title>GPT-4.1 is Here. Plus, Mini and Nano!</title>
      <dc:creator>Shagun Bidawatka</dc:creator>
      <pubDate>Tue, 15 Apr 2025 13:34:53 +0000</pubDate>
      <link>https://forem.com/shagun/gpt-41-is-here-plus-mini-and-nano-43io</link>
      <guid>https://forem.com/shagun/gpt-41-is-here-plus-mini-and-nano-43io</guid>
      <description>&lt;p&gt;OpenAI just announced new AI models: &lt;strong&gt;GPT-4.1&lt;/strong&gt;, &lt;strong&gt;GPT-4.1 mini&lt;/strong&gt;, and even a &lt;strong&gt;GPT-4.1 nano&lt;/strong&gt;. They're available now in the API.&lt;/p&gt;

&lt;p&gt;It seems OpenAI is focusing on making their models better at coding, following instructions, and handling &lt;em&gt;way&lt;/em&gt; more text. Let's see what this means.&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1911830886896799931-881" src="https://platform.twitter.com/embed/Tweet.html?id=1911830886896799931"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1911830886896799931-881');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1911830886896799931&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;h3&gt;
  
  
  What Has Changed?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Better at Coding:&lt;/strong&gt; This seems to be a major focus. GPT-4.1 scored &lt;strong&gt;54.6% on SWE-bench Verified&lt;/strong&gt; (a software engineering test), which is a massive jump from GPT-4o's 33.2%. They say it's better at real-world coding tasks, understanding codebases, and following specific formats like code diffs.&lt;br&gt;&lt;br&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Follows Instructions Better:&lt;/strong&gt; Sick of the AI not quite doing what you asked? GPT-4.1 is supposed to be more reliable. It scored &lt;strong&gt;38.3% on Scale’s MultiChallenge&lt;/strong&gt; benchmark (up 10.5% from GPT-4o), which tests how well it follows instructions, especially over multiple turns in a conversation. They specifically mention improvements in handling negative instructions (like "don't do XYZ") and complex formatting requests.&lt;br&gt;&lt;br&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;HUGE Context Windows:&lt;/strong&gt; All three new models (4.1, mini, nano) support up to &lt;strong&gt;1 million tokens&lt;/strong&gt; of context! That's up from 128k in GPT-4o. Think of processing massive codebases or multiple long documents at once.&lt;br&gt;&lt;br&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Faster and Cheaper Options:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;GPT-4.1:&lt;/strong&gt; Is &lt;strong&gt;26% cheaper&lt;/strong&gt; than GPT-4o for typical queries.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;GPT-4.1 mini:&lt;/strong&gt; A big improvement over GPT-4o mini. OpenAI claims it &lt;strong&gt;matches or beats GPT-4o&lt;/strong&gt; on some intelligence tests while being nearly &lt;strong&gt;half the latency&lt;/strong&gt; and &lt;strong&gt;83% cheaper&lt;/strong&gt;. Wow!&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;GPT-4.1 nano:&lt;/strong&gt; Their &lt;strong&gt;fastest and cheapest model&lt;/strong&gt; now. Designed for low-latency tasks like autocompletion or classification, but &lt;em&gt;still&lt;/em&gt; has that 1 million token context window.
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;strong&gt;Better Image Understanding (Vision):&lt;/strong&gt; The new models, especially GPT-4.1 mini, show improvements in understanding images, charts, and even long videos. GPT-4.1 got &lt;strong&gt;72.0% on a long video understanding test&lt;/strong&gt;, beating GPT-4o.&lt;br&gt;&lt;br&gt;&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;strong&gt;API Only:&lt;/strong&gt; Important note: These new models (4.1, mini, nano) are &lt;strong&gt;only available via the API&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  When Should You Use These?
&lt;/h3&gt;

&lt;p&gt;Based on the improvements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Coding Tools &amp;amp; Agents:&lt;/strong&gt; The big coding boost makes GPT-4.1 (and maybe mini) much more attractive for code generation, review, debugging, and building automated coding agents.&lt;br&gt;&lt;br&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Complex Instruction Tasks:&lt;/strong&gt; If you need an AI to follow specific formats, multi-step instructions, or remember details from long conversations, GPT-4.1 looks more reliable.&lt;br&gt;&lt;br&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Processing Large Amounts of Text/Code:&lt;/strong&gt; Analyzing long documents, summarizing books, querying across entire code repositories – the 1M token window opens up possibilities here for all three models.&lt;br&gt;&lt;br&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Speed-Sensitive Apps:&lt;/strong&gt; GPT-4.1 mini and nano are explicitly designed for lower latency. Think faster chatbots, real-time analysis, or quick classifications.&lt;br&gt;&lt;br&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cost-Sensitive Apps:&lt;/strong&gt; Nano is the cheapest option, and Mini offers a great performance/cost balance compared to previous models.&lt;br&gt;&lt;br&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  My Quick Opinion
&lt;/h3&gt;

&lt;p&gt;The introduction of &lt;code&gt;mini&lt;/code&gt; and &lt;code&gt;nano&lt;/code&gt; versions alongside the main &lt;code&gt;4.1&lt;/code&gt; is a smart move. It gives developers clear choices based on their needs for performance, speed, and cost.&lt;/p&gt;

&lt;p&gt;It's also good they're focusing on instruction following which I think was much needed even you must have noticed bashing on social platforms for models giving irrelevant responses. Also making these API-only clarifies where developers should look for the latest capabilities.&lt;/p&gt;

&lt;p&gt;All in all, this looks like a solid update focused on practical developer needs. Do check it out - &lt;a href="https://openai.com/index/gpt-4-1/" rel="noopener noreferrer"&gt;https://openai.com/index/gpt-4-1/&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>chatgpt</category>
      <category>webdev</category>
      <category>ai</category>
      <category>openai</category>
    </item>
    <item>
      <title>Break over</title>
      <dc:creator>Shagun Bidawatka</dc:creator>
      <pubDate>Mon, 14 Apr 2025 17:40:30 +0000</pubDate>
      <link>https://forem.com/shagun/break-over-3emc</link>
      <guid>https://forem.com/shagun/break-over-3emc</guid>
      <description>&lt;p&gt;After a break of few months starting the preparation series again. Will be sharing daily content here. I'll cover my whole learning journey as a frontend dev. Stay updated!&lt;/p&gt;

&lt;p&gt;Let's learn together.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>interview</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Announcing: The Ultimate Frontend Interview Preparation Kit</title>
      <dc:creator>Shagun Bidawatka</dc:creator>
      <pubDate>Sat, 26 Oct 2024 11:18:27 +0000</pubDate>
      <link>https://forem.com/shagun/announcing-the-ultimate-frontend-interview-preparation-kit-1ib4</link>
      <guid>https://forem.com/shagun/announcing-the-ultimate-frontend-interview-preparation-kit-1ib4</guid>
      <description>&lt;p&gt;As a developer, facing technical interviews can feel like a marathon. Preparing for interviews requires not only mastering the fundamentals but also keeping up with new techniques and best practices. &lt;/p&gt;

&lt;p&gt;To help you navigate this journey, I'm thrilled to introduce a frontend Interview Preparation Kit—a series of comprehensive blogs aimed at guiding you through all essential concepts, best practices, and frequently asked interview questions.&lt;/p&gt;

&lt;p&gt;I'll be publishing blogs in series.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Inside the Interview Preparation Kit?
&lt;/h2&gt;

&lt;p&gt;Each blog in this series will dive deep into specific frontend topics, targeting main tech stacks in technical interviews. Here’s a sneak peek at what you can expect:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Javascript&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Javascript coding/tricky questions&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ReactJS&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;State management libraries (Eg: Redux)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;System Design (Storage, networking, caching, performance)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;DSA&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;My interview experiences&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Extra discussions and suggestions for job apply and interview&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you’re gearing up for Frontend interviews, this series is designed to make your preparation journey both organized and efficient. &lt;br&gt;
Follow and Stay Tuned!&lt;/p&gt;

&lt;p&gt;Do comment the suggestions and addons you want in the series.&lt;/p&gt;

</description>
      <category>interview</category>
      <category>javascript</category>
      <category>frontend</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Networking Interview Preparation</title>
      <dc:creator>Shagun Bidawatka</dc:creator>
      <pubDate>Mon, 07 Oct 2024 07:59:34 +0000</pubDate>
      <link>https://forem.com/shagun/networking-interview-preparation-cnj</link>
      <guid>https://forem.com/shagun/networking-interview-preparation-cnj</guid>
      <description>&lt;p&gt;I'll sharing important and mostly asked networking topics in interview. In order to keep this blog short and crisp, I'll just add the topic and the intro to the topic. Let's start...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;u&gt;Learn basic of how the internet works&lt;/u&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The internet is a system of connected networks that enables global communication, using protocols, IP addresses, and domain names to direct traffic and exchange information efficiently.&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%2Fa011gc2w2onepky49g4r.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%2Fa011gc2w2onepky49g4r.png" alt="internet" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;u&gt;Protocols in Internet communication&lt;/u&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Protocols provide a set of rules and standards that ensure data is transmitted efficiently, securely, and consistently across the global network.&lt;/p&gt;

&lt;p&gt;Common protocols- HTTP/HTTPS, TCP/IP, DNS, FTP, SMTP, UDP. Give a brief read to each one of them.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;u&gt;&lt;strong&gt;Difference between HTTP and HTTPS&lt;/strong&gt;&lt;/u&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;HTTP is a protocol for transferring data between a browser and a server without encryption, making it vulnerable to interception. HTTPS, on the other hand, encrypts the data using SSL/TLS, ensuring secure and private communication over the internet.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;u&gt;Understanding of IP address, Domain name and DNS&lt;/u&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;IP Addresses - Every device connected to the internet has a unique identifier.&lt;/p&gt;

&lt;p&gt;Domain names- Are easy-to-remember addresses that correspond to IP addresses.&lt;/p&gt;

&lt;p&gt;DNS- When you type a domain name into your browser, DNS takes over to find the corresponding IP address of the website’s server.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;u&gt;REST (Representational State Transfer)&lt;/u&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Architectural style for designing web services that allows systems to communicate over the internet using standard HTTP methods.&lt;/p&gt;

&lt;p&gt;Key concepts- stateless communication, HTTP Methods, Uniform Interface, Representation of Resources.&lt;/p&gt;

&lt;p&gt;Give a read to - HTTP methods like &lt;strong&gt;GET, POST, PUT, and DELETE.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;u&gt;Status code&lt;/u&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;They provide information about whether a request was successful, if there was an error, or if further action is needed.&lt;br&gt;
1xx (Informational) - 100&lt;br&gt;
2xx (Success) - 200, 201&lt;br&gt;
3xx (Redirection) - 301,302&lt;br&gt;
4xx (Client Errors) - 400, 401, 403, 404&lt;br&gt;
5xx (Server Errors) - 500, 503&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;u&gt;OPTIONS method&lt;/u&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It doesn’t request the resource itself, but rather asks what HTTP methods (e.g., GET, POST, DELETE) are supported and what other capabilities are allowed, such as authentication, headers, or CORS (Cross-Origin Resource Sharing) rules.&lt;/p&gt;

&lt;p&gt;When a client (e.g., a web browser) makes a cross-origin request (i.e., a request to a different domain), the browser first sends an OPTIONS request to the server to check if the actual request is allowed. It is crucial for security.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;u&gt;Headers&lt;/u&gt;&lt;/strong&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://dev.to/shagun/understanding-request-and-response-headers-in-rest-apis-43nf"&gt;https://dev.to/shagun/understanding-request-and-response-headers-in-rest-apis-43nf&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I just tried to collate the topics, you should give a brief read about them. I'll be adding further more blogs on interview questions. &lt;br&gt;
Feel free to comment, if you find any missed out topics or want to add anything on it. &lt;/p&gt;

&lt;p&gt;For 1:1 discussion, connect here: &lt;a href="https://topmate.io/shagun" rel="noopener noreferrer"&gt;https://topmate.io/shagun&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>networking</category>
      <category>interview</category>
      <category>developer</category>
    </item>
    <item>
      <title>A practical Guide - Migrating to Next.js App Router</title>
      <dc:creator>Shagun Bidawatka</dc:creator>
      <pubDate>Tue, 01 Oct 2024 07:19:06 +0000</pubDate>
      <link>https://forem.com/shagun/a-practical-guide-migrating-to-nextjs-app-router-31k7</link>
      <guid>https://forem.com/shagun/a-practical-guide-migrating-to-nextjs-app-router-31k7</guid>
      <description>&lt;p&gt;With the release of the Next.js App Router, many developers are eager to migrate their existing projects. In this post, I’ll share my experience migrating a project to the Next.js App Router, including key challenges, changes, and how you can make the process smoother.&lt;/p&gt;

&lt;p&gt;It's an incremental approach, you can use the page router and app router simultaneously. &lt;/p&gt;

&lt;h2&gt;
  
  
  Why Migrate to the Next.js App Router?
&lt;/h2&gt;

&lt;p&gt;The App Router introduces several advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Improved Routing: Cleaner file-system-based routing.&lt;/li&gt;
&lt;li&gt;Server-Side Rendering (SSR) Enhancements: More efficient handling of server-side data.&lt;/li&gt;
&lt;li&gt;Meta Handling: Simplified SEO management.&lt;/li&gt;
&lt;li&gt;Improved Performance: Built-in optimizations for various components.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By migrating, you can future-proof your application to take advantage of the latest Next.js features.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps to Migrate to the App Router
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Update Dependencies&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The first step is to ensure your Next.js and related dependencies are up to date. Run the following commands to install the latest versions of Next.js and React:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install next@latest react@latest react-dom@latest
npm install -D eslint-config-next@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Structure the App Folder&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The App Router relies on the new app directory for managing routes, metadata, and layouts. Here's how to structure it:&lt;/p&gt;

&lt;p&gt;App Folder: Move your pages into the app folder. Each route now has its own dedicated folder containing a page.tsx file.&lt;/p&gt;

&lt;p&gt;Layouts: Add a layout.tsx file to define layouts for specific sections of your app. This is particularly useful for handling shared components like navigation bars or footers.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Router Changes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One of the most significant changes is the replacement of next/router with next/navigation for routing and navigation functionality.&lt;/p&gt;

&lt;p&gt;Replace all next/router imports with next/navigation.&lt;br&gt;
Update functions like useRouter with new equivalents, such as usePathname, useSearchParams, and useRouter() where appropriate.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Refactor Server-Side Code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;getServerSideProps and getStaticProps are deprecated in the App Router.&lt;br&gt;
Use async server components or server actions for data fetching in server-side pages.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export async function getData() {
  const res = await fetch('https://getData.com/data');
  return res.json();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Handling Client-Side Components&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Client components:&lt;br&gt;
Any component that uses React hooks, browser APIs, or user interactions must be marked with 'use client'. This tells Next.js to render them on the client side.&lt;/p&gt;

&lt;p&gt;Server Components:&lt;br&gt;
Any component that does not require interaction with the browser can remain as a server component. These are more efficient since they avoid shipping unnecessary JavaScript to the client.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Handling External Libraries&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you are using external libraries like React Query, AntDesign or framer etc. You need to update them and make changes as needed. Can't include all the changes in this blog. Although changes are mentioned in their documentation. &lt;/p&gt;

&lt;h2&gt;
  
  
  Common Challenges During Migration
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Router Event Handling:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With the change from next/router to next/navigation, handling router events might require a different approach.&lt;br&gt;
Ensure that you update any router event listeners or hooks accordingly.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Layout Shift Issues:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When migrating pages with complex layouts (especially those with animations), you may notice layout shifts. Add placeholder or keep proper alignment on server-side itself to prevent layout shifts.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Image and Link Component Updates:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The App Router introduces changes to the Image and Link components.&lt;br&gt;
Use codemods to automatically update components.&lt;br&gt;
For the Image component, remove deprecated attributes like responsive.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Animations &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Animation related components like framer, swiper, and lootie files need to be kept at the client side.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Migrating to the Next.js App Router comes with its challenges but also with significant improvements in performance, scalability, and flexibility. By breaking down the migration into manageable sections (app-level, page-level, and feature updates), I was able to tackle each change systematically. &lt;/p&gt;

&lt;p&gt;Let me know if you have any questions or tips from your own migrations!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>nextjs</category>
      <category>approuter</category>
    </item>
    <item>
      <title>Communication: Data Fetching Patterns</title>
      <dc:creator>Shagun Bidawatka</dc:creator>
      <pubDate>Tue, 10 Sep 2024 06:15:50 +0000</pubDate>
      <link>https://forem.com/shagun/communication-data-fetching-patterns-5d7a</link>
      <guid>https://forem.com/shagun/communication-data-fetching-patterns-5d7a</guid>
      <description>&lt;p&gt;Big announcement!&lt;br&gt;
I have started my daily learning journey of &lt;strong&gt;Frontend system design&lt;/strong&gt;. And I'll be sharing insights from each module in the blogs. So, here's the start and there is much more to come!&lt;/p&gt;

&lt;p&gt;In this blog, we’ll explore different data fetching mechanisms essential to front-end system design, including short polling, long polling, WebSockets, server-sent events (SSE), and webhooks. Each technique addresses specific needs for delivering data to and from the client and server, and understanding them is crucial for designing scalable, real-time web applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Short Polling
&lt;/h2&gt;

&lt;p&gt;Short polling is a method where the client repeatedly sends requests to the server at regular intervals to check for updates.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fnemx20jl827vw1yw3uyi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fnemx20jl827vw1yw3uyi.png" alt="Short Polling"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;setInterval(async () =&amp;gt; {
  const response = await fetch('/api/get-posts');
  const data = await response.json();
  // Update UI with new data
}, 5000); // Poll every 5 seconds

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

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Short live communication&lt;/li&gt;
&lt;li&gt;No persistence of the data&lt;/li&gt;
&lt;li&gt;Less resource utility&lt;/li&gt;
&lt;li&gt;Server load due to the repeated requests&lt;/li&gt;
&lt;li&gt;Increased bandwidth usage&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Eg - Stock market ticker, Social media feeds&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Long Polling
&lt;/h2&gt;

&lt;p&gt;Long polling is an enhancement over short polling, where the client sends a request, and the server holds the connection open until it has new data to return.&lt;/p&gt;

&lt;p&gt;From Back-end, the response will be sent only when data is updated, till then it will hold the request. If there is no update for a long time then the timeout is processed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fvv374wrny23khqfi0tgh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fvv374wrny23khqfi0tgh.png" alt="Long Polling"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Client side&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function subscribe() {
  let response = await fetch("/subscribe");

  if (response.status == 502) {
    // Status 502 is a connection timeout error, let's reconnect
    await subscribe();
  } else if (response.status != 200) {
    // An error - let's show it
    showMessage(response.statusText);
    // Reconnect in one second
    await new Promise(resolve =&amp;gt; setTimeout(resolve, 1000));
    await subscribe();
  } else {
    // Get and show the message
    let message = await response.text();
    showMessage(message);
    // Call subscribe() again to get the next message
    await subscribe();
  }
}

subscribe();

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

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Single long-lived connection&lt;/li&gt;
&lt;li&gt;Provides real-time updates with fewer requests than short polling.&lt;/li&gt;
&lt;li&gt;Reduces unnecessary data transfer when there are no updates.&lt;/li&gt;
&lt;li&gt;The connection can be kept open for long durations, increasing server load.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Eg- Live customer support chats&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Web Sockets
&lt;/h2&gt;

&lt;p&gt;WebSockets allow for full-duplex communication between the client and server, making it the most efficient method for real-time data transfer.&lt;/p&gt;

&lt;p&gt;The client opens a WebSocket connection with the server and both the client and server can send messages to each other over this single connection.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fhzcr2f2mmncsnxaam4fh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fhzcr2f2mmncsnxaam4fh.png" alt="Web Sockets"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;webSocket = new WebSocket(url, protocols);

// Send message
webSocket.send("Here's some text that the server is urgently awaiting!");

// Receive message
webSocket.onmessage = (event) =&amp;gt; {
  console.log(event.data);
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Continuous bi-directional communication&lt;/li&gt;
&lt;li&gt;Multiple libraries to implement it - ws, socket.io etc.&lt;/li&gt;
&lt;li&gt;Efficient for high-frequency updates with low overhead&lt;/li&gt;
&lt;li&gt;Challenges - maintain communication with 1 server, handle failure and scaling, occupies the resources.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Eg- Live chat applications, Online multiplayer games&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Server-Sent Events (SSE)
&lt;/h2&gt;

&lt;p&gt;SSE provides a unidirectional stream of updates from the server to the client over an HTTP connection.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fyatruj4duxhlpigka8te.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fyatruj4duxhlpigka8te.png" alt="Server-Sent Events"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const evtSource = new EventSource("ssedemo.php");

evtSource.onmessage = (event) =&amp;gt; {
  const newElement = document.createElement("li");
  const eventList = document.getElementById("list");

  newElement.textContent = `message: ${event.data}`;
  eventList.appendChild(newElement);
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Long live uni-directional communication&lt;/li&gt;
&lt;li&gt;Single HTTP connection&lt;/li&gt;
&lt;li&gt;Challenges - resource utilization, Browser compatibility and behaviour on inactive tabs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Eg - Feeds, Notifications&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Webhooks
&lt;/h2&gt;

&lt;p&gt;Webhooks are a server-to-server communication mechanism where the server sends data to a predefined URL when an event occurs. The client doesn’t need to keep checking the server for updates.&lt;/p&gt;

&lt;p&gt;Popular for triggering actions between systems, such as payment notifications, GitHub events, or third-party service integrations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Choosing the right communication method depends on your application's requirements. WebSockets and SSE are perfect for real-time and streaming data, while long polling offers a balance between performance and ease of use. Short polling is a simple solution for infrequent updates but can be resource-intensive, and webhooks are ideal for server-to-server notifications.&lt;/p&gt;

&lt;p&gt;Each technique has its own advantages and limitations. Understanding these can help you make informed decisions to build efficient, responsive web applications.&lt;/p&gt;

&lt;p&gt;This blog is open for suggestions and discussions!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>frontend</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Understanding Request and Response Headers in REST APIs</title>
      <dc:creator>Shagun Bidawatka</dc:creator>
      <pubDate>Tue, 27 Aug 2024 07:18:57 +0000</pubDate>
      <link>https://forem.com/shagun/understanding-request-and-response-headers-in-rest-apis-43nf</link>
      <guid>https://forem.com/shagun/understanding-request-and-response-headers-in-rest-apis-43nf</guid>
      <description>&lt;p&gt;Headers play a vital role in the communication between a client and a server by providing essential information about the request or response. In this blog, we’ll dive deep into what headers are, why they matter, and some of the most commonly used headers in REST APIs.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are HTTP Headers?
&lt;/h2&gt;

&lt;p&gt;HTTP headers are key-value pairs sent in the request or response of an HTTP transaction. These headers convey information about the request or response, such as the type of data being sent, the encoding method used, authentication credentials etc.&lt;/p&gt;

&lt;p&gt;Headers are used at both request and response time. They facilitate smooth, secure, and efficient communication between the client and server in REST APIs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Request Headers
&lt;/h2&gt;

&lt;p&gt;Contain more information about the resource to be fetched, or about the client requesting the resource.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Header&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Use Case&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Authorization&lt;/td&gt;
&lt;td&gt;Authorization: Bearer &lt;/td&gt;
&lt;td&gt;Sends credentials to authenticate the client with the server.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Content-Type&lt;/td&gt;
&lt;td&gt;Content-Type: application/json&lt;/td&gt;
&lt;td&gt;Specifies the media type of the data being sent by the client.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Accept&lt;/td&gt;
&lt;td&gt;Accept: application/json&lt;/td&gt;
&lt;td&gt;Indicates the content types the client can process.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;User-Agent&lt;/td&gt;
&lt;td&gt;User-Agent: Mozilla/5.0&lt;/td&gt;
&lt;td&gt;Identifies the client software making the request.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cache-Control&lt;/td&gt;
&lt;td&gt;Cache-Control: no-cache&lt;/td&gt;
&lt;td&gt;Directs how the request should be cached by the server or caches.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Host&lt;/td&gt;
&lt;td&gt;Host: example.com&lt;/td&gt;
&lt;td&gt;Specifies the domain name of the server the client is requesting.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Accept-Encoding&lt;/td&gt;
&lt;td&gt;Accept-Encoding: gzip, deflate&lt;/td&gt;
&lt;td&gt;Lists the encoding methods the client can handle.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Accept-Language&lt;/td&gt;
&lt;td&gt;Accept-Language: en-US&lt;/td&gt;
&lt;td&gt;Indicates the preferred languages for the response.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Referer&lt;/td&gt;
&lt;td&gt;Referer: &lt;a href="https://example.com" rel="noopener noreferrer"&gt;https://example.com&lt;/a&gt;
&lt;/td&gt;
&lt;td&gt;Provides the URL of the resource from which the request was initiated.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Origin&lt;/td&gt;
&lt;td&gt;Origin: &lt;a href="https://example.com" rel="noopener noreferrer"&gt;https://example.com&lt;/a&gt;
&lt;/td&gt;
&lt;td&gt;Identifies the origin of the request, especially for CORS.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Response Headers
&lt;/h2&gt;

&lt;p&gt;Hold additional information about the response, like its location or about the server providing it.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Header&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Use Case&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Content-Type&lt;/td&gt;
&lt;td&gt;application/json&lt;/td&gt;
&lt;td&gt;Indicates the media type of the resource in the response body.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cache-Control&lt;/td&gt;
&lt;td&gt;max-age=3600&lt;/td&gt;
&lt;td&gt;Defines caching directives for the client and intermediate caches.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Location&lt;/td&gt;
&lt;td&gt;/new-resource&lt;/td&gt;
&lt;td&gt;Indicates the URL to redirect a client to another resource.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Set-Cookie&lt;/td&gt;
&lt;td&gt;sessionId=abc123&lt;/td&gt;
&lt;td&gt;Sends cookies from the server to the client for session management.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;WWW-Authenticate&lt;/td&gt;
&lt;td&gt;Basic realm="Resource"&lt;/td&gt;
&lt;td&gt;Defines the authentication method for accessing a resource.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Content-Encoding&lt;/td&gt;
&lt;td&gt;gzip&lt;/td&gt;
&lt;td&gt;Specifies the encoding method used on the response data.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Content-Length&lt;/td&gt;
&lt;td&gt;348&lt;/td&gt;
&lt;td&gt;Indicates the size of the response body in bytes.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Expires&lt;/td&gt;
&lt;td&gt;Wed, 21 Oct 2024&lt;/td&gt;
&lt;td&gt;Gives the date/time after which the response is considered stale.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ETag&lt;/td&gt;
&lt;td&gt;"34a64d..."&lt;/td&gt;
&lt;td&gt;Provides a unique identifier for a specific version of a resource.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Last-Modified&lt;/td&gt;
&lt;td&gt;Tue, 15 Nov 2023&lt;/td&gt;
&lt;td&gt;Indicates the date and time the resource was last modified.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Understanding and properly using request and response headers is fundamental to building REST APIs. These headers give information about security, authentication, caching, content negotiation, and API usability.&lt;/p&gt;

</description>
      <category>restapi</category>
      <category>api</category>
      <category>axios</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Understanding YAGNI (You Aren’t Gonna Need It)</title>
      <dc:creator>Shagun Bidawatka</dc:creator>
      <pubDate>Tue, 13 Aug 2024 08:07:40 +0000</pubDate>
      <link>https://forem.com/shagun/understanding-yagni-you-arent-gonna-need-it-4165</link>
      <guid>https://forem.com/shagun/understanding-yagni-you-arent-gonna-need-it-4165</guid>
      <description>&lt;p&gt;Let's discuss feature planning, picking and complexity.&lt;br&gt;
To catch the pace, we keep adding features and building complex systems. Thinking, "This will be useful" or "What if we need this in the future?" But often, those extra features end up unused, complicating the code, and slowing down the project. This is where YAGNI, which stands for "You Aren’t Gonna Need It," comes in.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is YAGNI?
&lt;/h2&gt;

&lt;p&gt;YAGNI is a concept from Agile and Extreme Programming (XP) methodologies. It states that don’t add functionality until you actually need it. While it might seem smart to build for future possibilities, it often leads to over-engineering—making things more complicated than they need to be.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;“Always implement things when you actually need them, never when you just foresee that you need them.”&lt;/strong&gt; – Ron Jeffries, one of the founders of XP&lt;/p&gt;

&lt;h2&gt;
  
  
  Examples of YAGNI in Action
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Over-Architecting a User Authentication System
Imagine you’re building a web application with a user authentication system. You might be tempted to implement a complex, multi-tiered authentication system with social logins, two-factor authentication, and a password recovery mechanism. However, if your application is still in its early stages, with a small user base, such complexity might not be necessary.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By adhering to YAGNI, you could start with a simple email/password authentication system. As your user base grows and the need for more robust security features becomes apparent, you can then iteratively add the necessary components. This approach allows you to ship your product faster and avoid spending time and resources on features that might not be needed in the immediate future.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Premature Optimization in Code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Developers often feel the urge to optimize code early, ensuring it’s as efficient as possible from the get-go. However, optimizing code before it’s clear where the performance bottlenecks lie can be a waste of time.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Building Features for Hypothetical Future Use Cases&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;YAGNI advises you to hold off on building feature until you have a clear demand for it from your users. This approach helps you avoid unnecessary complexity and keeps your codebase lean and focused on delivering the core functionality that your users need right now.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pros and Cons of YAGNI
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Simplifies Codebase:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;YAGNI helps keep your codebase lean by avoiding unnecessary features. This makes the code easier to understand, maintain, and extend.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Faster Development:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;By focusing only on what’s needed, you can deliver features and products more quickly.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Cost Efficiency:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Time and resources are spent on features that provide immediate value, reducing the overall cost of development and maintenance.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Improves Flexibility:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;With a lean codebase, it’s easier to pivot or adapt to changes in user needs or business requirements.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Potential for Short-Term Thinking:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Focusing too much on the present can lead to missed opportunities for future-proofing. Some features might be more difficult or costly to add later.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Risk of Technical Debt:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you delay too many features, you might end up with a backlog of work that becomes technical debt, which can be difficult to address later on.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Possible Rework:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Avoiding features until they are needed might result in rework or refactoring if the system wasn’t originally designed with future needs in mind.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Balancing Act:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It can be challenging to strike the right balance between avoiding unnecessary work and planning for future needs. Overemphasis on YAGNI might leave a project unprepared for growth or change.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So, it's not about implementing the YAGNI principle completely in your project, it's about finding the balance.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>product</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>Why to Choose Types Instead of Interfaces</title>
      <dc:creator>Shagun Bidawatka</dc:creator>
      <pubDate>Mon, 05 Aug 2024 07:36:53 +0000</pubDate>
      <link>https://forem.com/shagun/why-to-choose-use-types-instead-of-interfaces-3c1p</link>
      <guid>https://forem.com/shagun/why-to-choose-use-types-instead-of-interfaces-3c1p</guid>
      <description>&lt;p&gt;In TypeScript, both Types and Interfaces are used to define the types of objects. However, they have different uses and features. Both can help developers constrain the types of variables and objects when writing code, thereby reducing errors and improving code readability.&lt;/p&gt;

&lt;p&gt;So why Types? Let's discuss this.&lt;/p&gt;

&lt;h2&gt;
  
  
  Types
&lt;/h2&gt;

&lt;p&gt;In TypeScript, a type lets you define the shape of data. It’s flexible and can be used to create unions, intersections, and more.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type User = {
  name: string;
  age: number;
};

type Admin = User &amp;amp; {
  isAdmin: boolean;
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Interfaces
&lt;/h2&gt;

&lt;p&gt;An interface is another way to define the shape of an object. It’s more rigid than types and is mainly used for defining object shapes and class contracts.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface User {
  name: string;
  age: number;
}

interface Admin extends User {
  isAdmin: boolean;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why I Prefer Types
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Union&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Union types let you define a type that can be one of several types. This is handy for function parameters and return types. Here, ID can be either a string or a number, demonstrating the power of union types.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type ID = string | number;

function getUserId(id: ID): string {
  return `User ID: ${id}`;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;String Literals&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Literal types let you specify exact values a variable can have. This can be really useful for defining constants or configuration options.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type Direction = 'north' | 'south' | 'east' | 'west';

function move(direction: Direction) {
  console.log(`Moving ${direction}`);
}

move('north');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Conditional types&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Types allow the creation of conditional types, enabling the selection of types based on conditions&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type Check&amp;lt;T&amp;gt; = T extends string ? string : number;

let result1: Check&amp;lt;string&amp;gt;; // result1 is of type string
let result2: Check&amp;lt;number&amp;gt;; // result2 is of type number
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Intersection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Intersection types allow you to combine multiple types into one. This is especially useful for creating complex type compositions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type Person = {
  name: string;
  age: number;
};

type Employee = {
  employeeId: number;
};

type EmployeeDetails = Person &amp;amp; Employee;

const employee: EmployeeDetails = {
  name: 'Dev',
  age: 30,
  employeeId: 12345,
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Choosing between types and interfaces ultimately depends on your specific use case and personal preference. However, understanding the strengths of each can help you make more informed decisions and write better TypeScript code.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>react</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Principle of least astonishment - tech product POV</title>
      <dc:creator>Shagun Bidawatka</dc:creator>
      <pubDate>Thu, 01 Aug 2024 07:14:43 +0000</pubDate>
      <link>https://forem.com/shagun/principle-of-least-astonishment-tech-product-pov-3mcn</link>
      <guid>https://forem.com/shagun/principle-of-least-astonishment-tech-product-pov-3mcn</guid>
      <description>&lt;p&gt;As a developer, you strive to create interfaces that are not only functional but also intuitive and user-friendly. One of the guiding principles to achieve this is the Principle of Least Astonishment (PoLA). This principle states that a system should behave in a way that least surprises its users, ensuring that their expectations are met and interactions are smooth. In this blog, we'll explore PoLA from a developer's perspective, its importance, and practical ways to implement it in your projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why PoLA Matters
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;User Experience (UX): Good UX is about meeting user expectations. When an application behaves as users anticipate, it reduces frustration and increases satisfaction.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Usability: Consistency and predictability make an application easier to learn and use. Users spend less time figuring out how things work and more time achieving their goals.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Error Reduction: When users understand the consequences of their actions, they are less likely to make mistakes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Trust: Predictable behaviour fosters trust. Users are more likely to return to an application that consistently meets their expectations.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How to implement it in the project&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Consistent Design Patterns&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Consistency in design helps users build a mental model of how the application works. Here are some key aspects to focus on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Navigation: Use familiar navigation patterns. A product should follow common navigation structures like top menus, sidebars, and breadcrumb trails.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Forms: Place labels and input fields in predictable locations. For instance, labels are typically placed above or to the left of input fields and common way of showcasing field and form validations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Buttons: Use standard button styles for usual actions like "Submit," "Cancel,", "Edit" and "Delete". &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Clear and Immediate Feedback on user actions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Feedback informs users about the outcome of their actions. To implement this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Visual Feedback: Highlight interactive elements and use loading indicators for actions that take time to process.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Notifications or toasts: Display messages for successful actions, errors, and warnings. Prefer these messages to be clear and concise.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Animations: Use animations to indicate changes, but it shouldn't be distracting and disturbing.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Meaningful Defaults&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Giving default values an idea to the users.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Form Fields: Pre-fill fields with common values where appropriate.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Settings: Choose default settings that cater to the majority of users while providing options for customization.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Avoiding Surprises&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use text and labels that are understandable to the users. Surprising users can lead to confusion and frustration. Avoid this by adding clear terminology and not hiding things or information behind interactions. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Challenges in Applying POLA&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;While POLA is a valuable principle, there are challenges in its application. Balancing innovation with familiarity can be difficult, as introducing new features or designs might initially surprise users. However, clear communication and gradual introduction of changes can mitigate this.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Case Study&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In one of our projects, we implemented a file upload feature where users needed to upload a file, enter a name, and then click an "Add" button to complete the upload process. Initially, we displayed the uploaded file in the interface as soon as the user selected it, which led users to believe the file had been successfully uploaded without needing to click "Add". This led to confusion and as a result, many users reported the issue of the upload file feature. &lt;/p&gt;

&lt;p&gt;This illustrates a practical application of the Principle of Least Astonishment, showing how misalignment between user expectations and system behaviour can cause issues. And they can be avoided and corrected. Embracing PoLA will not only make your applications more user-friendly but also set you apart as a thoughtful and skilled professional in the tech industry.&lt;/p&gt;

</description>
      <category>product</category>
      <category>webdev</category>
      <category>ux</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>Advanced State Management - XState</title>
      <dc:creator>Shagun Bidawatka</dc:creator>
      <pubDate>Sun, 21 Jul 2024 11:30:06 +0000</pubDate>
      <link>https://forem.com/shagun/advanced-state-management-xstate-lmh</link>
      <guid>https://forem.com/shagun/advanced-state-management-xstate-lmh</guid>
      <description>&lt;p&gt;Here, we will use and discuss about &lt;strong&gt;XState&lt;/strong&gt; which is a state management and orchestration solution for both JavaScript and TypeScript apps for both frontend and backend applications.&lt;/p&gt;

&lt;p&gt;For bigger applications managing the global state properly is essential, there are several ways to do so, like using React context, Redux, MobX and React Query.&lt;/p&gt;

&lt;p&gt;XState is a simple library to manage state component level as well as global level by using their hooks. So, let's dive into it's implementation.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Import the module
&lt;/h2&gt;

&lt;p&gt;We will be importing both xstate and @xstate/react latest versions into our existing project.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install xstate @xstate/react&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Adding machine
&lt;/h2&gt;

&lt;p&gt;Create a new file eg: MyFirstMachine.ts&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const countMachine = createMachine({
  context: {
    count: 0,
  },
  on: {
    INC: {
      actions: assign({
        count: ({ context }) =&amp;gt; context.count + 1,
      }),
    },
    DEC: {
      actions: assign({
        count: ({ context }) =&amp;gt; context.count - 1,
      }),
    },
    SET: {
      actions: assign({
        count: ({ event }) =&amp;gt; event.value,
      }),
    },
  },
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can see the visualisation of the machine using Xstate Vscode extension.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  3. Using machine and create actor
&lt;/h2&gt;

&lt;p&gt;To use the global logic we have implemented in our machine. We will use two hooks &lt;strong&gt;useMachine&lt;/strong&gt; and &lt;strong&gt;createActor&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; const [state, send] = useMachine(countMachine);
 const countActor = createActor(countMachine).start();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Performing actions
&lt;/h2&gt;

&lt;p&gt;Now, can perform read and write actions using these constants. &lt;br&gt;
To modify the value use -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;send({ type: "INC" })
send({ type: "DEC" })
send({ type: "SET", value: 5 })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the access the updated real-time value we will value use-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;state.context
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Adding complete code file for accessing and modifying for your convenience.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useMachine } from "@xstate/react";
import { countMachine } from "./XstateMachine";
import { createActor } from "xstate";

const App = () =&amp;gt; {
  const [state, send] = useMachine(countMachine);
  const countActor = createActor(countMachine).start();

  countActor.subscribe((state) =&amp;gt; {
    console.log(state.context.count);
  });

  return (
      &amp;lt;div className="relative z-0 bg-primary text-center"&amp;gt;
        &amp;lt;div&amp;gt;Hello XSTATE&amp;lt;/div&amp;gt;
        &amp;lt;div&amp;gt;{JSON.stringify(state.context)}&amp;lt;/div&amp;gt;

        &amp;lt;button onClick={() =&amp;gt; send({ type: "INC" })}&amp;gt;Increase By 1&amp;lt;/button&amp;gt;

        &amp;lt;button onClick={() =&amp;gt; send({ type: "DEC" })}&amp;gt;Decrease By 1&amp;lt;/button&amp;gt;

        &amp;lt;button onClick={() =&amp;gt; send({ type: "SET", value: 5 })}&amp;gt;
          Set Count to 5
        &amp;lt;/button&amp;gt;
      &amp;lt;/div&amp;gt;
  );
};

export default App;

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

&lt;/div&gt;



&lt;p&gt;That's how you can read, write and modify the state just by using XState. I have used multiple state management ways, it is one of the simplest ways I found. If you have anything to add to it feel free to comment. &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>state</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Import Excel/datasheet data to your Nextjs application</title>
      <dc:creator>Shagun Bidawatka</dc:creator>
      <pubDate>Wed, 17 Jul 2024 08:55:15 +0000</pubDate>
      <link>https://forem.com/shagun/import-exceldatasheet-data-to-your-nextjs-application-i64</link>
      <guid>https://forem.com/shagun/import-exceldatasheet-data-to-your-nextjs-application-i64</guid>
      <description>&lt;p&gt;Here, we will look into the process of importing Excel data into your nextjs application and show it in the way you want. I'll keep it crisp and to the point. So let's dive into the process-&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Create the Nextjs project
&lt;/h2&gt;

&lt;p&gt;To create a Nextjs project use the command - &lt;br&gt;
&lt;code&gt;npx create-next-app excel-next&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And to run the application&lt;br&gt;
&lt;code&gt;npm run dev&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  2. Node module for Excel import
&lt;/h2&gt;

&lt;p&gt;The node module we will use to import Excel data is &lt;strong&gt;xlsx&lt;/strong&gt;. To import the module run command -&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install xlsx&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  3. Create a file to import and show Excel data
&lt;/h2&gt;

&lt;p&gt;To get the data we will make an Axios fetch call to the sheet url-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const options = { url, responseType: "arraybuffer", };
let axiosResponse = await axios(options);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Read Workbook
&lt;/h2&gt;

&lt;p&gt;To get the data in readable form we will use xlsx. &lt;strong&gt;read&lt;/strong&gt; attempts to parse data and return a workbook object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const workbook = XLSX.read(axiosResponse.data)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Simplify and show data
&lt;/h2&gt;

&lt;p&gt;We are getting all the sheets from our excel in this workbook data. So let's sort out sheet and data in simplified object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; let worksheets = workbook.SheetNames.map((sheetName) =&amp;gt; {
       return {
         sheetName,
         data: XLSX.utils.sheet_to_json(workbook.Sheets[sheetName]),
       };
     });

 console.log("json:\n", JSON.stringify(worksheets), "\n\n");

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

&lt;/div&gt;



&lt;p&gt;Output: &lt;/p&gt;

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

&lt;p&gt;Here you can notice the sheet name and the corresponding data. Also, the first object of the data is the title of the rows. So, while showing the data we will slice the array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; {sheetData &amp;amp;&amp;amp;
    sheetData.map((sheet) =&amp;gt; (
      &amp;lt;&amp;gt;
       &amp;lt;p&amp;gt;{sheet?.sheetName}&amp;lt;/p&amp;gt;
       &amp;lt;Table dataSource={sheet?.data?.slice(1)} columns={columns} /&amp;gt;
      &amp;lt;/&amp;gt;
 ))}

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

&lt;/div&gt;



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

&lt;p&gt;For convenience adding the combined code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Col, Row, Table } from "antd";
import { useEffect, useState } from "react";

export default function MyNextJsExcelSheet() {
  const axios = require("axios");
  const XLSX = require("xlsx");
  const [sheetData, setSheetData] = useState&amp;lt;any&amp;gt;([]);

  const testAxiosXlsx = async (url) =&amp;gt; {
    const options = {
      url,
      responseType: "arraybuffer",
    };
    let axiosResponse = await axios(options);
    const workbook = XLSX.read(axiosResponse.data);

    let worksheets = workbook.SheetNames.map((sheetName) =&amp;gt; {
      return {
        sheetName,
        data: XLSX.utils.sheet_to_json(workbook.Sheets[sheetName]),
      };
    });
    setSheetData(worksheets);
    console.log("json:\n", JSON.stringify(worksheets), "\n\n");
  };
  const validate = () =&amp;gt; {
    testAxiosXlsx(
      "https://docs.google.com/spreadsheets/d/1arazUp1Aq9WeNMYDAK8d4_kz8YpwcHv1UdxMJKFOUIk/edit?usp=sharing"
    );
  };

  const columns = [
    {
      title: "Segment",
      dataIndex: "A",
      key: "Segment",
    },
    {
      title: "Country",
      dataIndex: "B",
      key: "Country",
    },
    {
      title: "Product",
      dataIndex: "C",
      key: "Product",
    },
    {
      title: "Units Sold",
      dataIndex: "D",
      key: "Units Sold",
    },
    {
      title: "Manufacturing Price",
      dataIndex: "E",
      key: "Manufacturing Price",
    },
    {
      title: "Sale Price",
      dataIndex: "F",
      key: "Sale Price",
    },
  ];

  useEffect(() =&amp;gt; validate(), []);
  return (
    &amp;lt;div&amp;gt;
        &amp;lt;Col lg={12}&amp;gt;
          &amp;lt;h3&amp;gt;The Data of The Uploaded Excel Sheet&amp;lt;/h3&amp;gt;
        &amp;lt;/Col&amp;gt;
        &amp;lt;Col lg={24}&amp;gt;
          {sheetData &amp;amp;&amp;amp;
            sheetData.map((sheet) =&amp;gt; (
              &amp;lt;&amp;gt;
                &amp;lt;p&amp;gt;{sheet?.sheetName}&amp;lt;/p&amp;gt;
                &amp;lt;Table dataSource={sheet?.data?.slice(1)} columns={columns} /&amp;gt;
              &amp;lt;/&amp;gt;
            ))}
        &amp;lt;/Col&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

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

&lt;/div&gt;



&lt;p&gt;With these steps, you're now equipped to seamlessly integrate Excel data into your Next.js application, opening up a world of possibilities for dynamic and data-driven web experiences.&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>import</category>
      <category>webdev</category>
      <category>frontend</category>
    </item>
  </channel>
</rss>
