<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nikhil Rajpurohit on Medium]]></title>
        <description><![CDATA[Stories by Nikhil Rajpurohit on Medium]]></description>
        <link>https://medium.com/@rajpurohitnikhil008?source=rss-8f80132b0257------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*tADQ6bO9PdthELnAuALjjQ.jpeg</url>
            <title>Stories by Nikhil Rajpurohit on Medium</title>
            <link>https://medium.com/@rajpurohitnikhil008?source=rss-8f80132b0257------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 11:55:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rajpurohitnikhil008/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Understanding Dynamic Routes and Slugs in Next.js (From Confusion to Clarity)]]></title>
            <link>https://medium.com/@rajpurohitnikhil008/understanding-dynamic-routes-and-slugs-in-next-js-from-confusion-to-clarity-10d638493708?source=rss-8f80132b0257------2</link>
            <guid isPermaLink="false">https://medium.com/p/10d638493708</guid>
            <dc:creator><![CDATA[Nikhil Rajpurohit]]></dc:creator>
            <pubDate>Thu, 22 Jan 2026 06:26:26 GMT</pubDate>
            <atom:updated>2026-01-22T06:31:48.093Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>I had confusion about params in Next.js.</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yuJb_lwd9DGwKcuN0GyhUg.png" /></figure><p>So I started making projects.<br>Deleted some.<br>Still creating a few.</p><p>And that’s where things finally started to click.</p><p>This blog is not theory-first.<br>It’s <strong>how params actually work when you build real apps</strong>.</p><h3>The Core Confusion</h3><p>When you start with Next.js routing, questions pile up fast:</p><ul><li>What is a slug?</li><li>When do I use [id] vs [...slug]?</li><li>How do I handle multiple params?</li><li>How deep can routing go?</li><li>Is this frontend logic or backend logic?</li></ul><p>Let’s break it down <strong>from simple → complex</strong>, exactly how you’ll face it in projects.</p><h3>1. Single Param (Basic Dynamic Route)</h3><h3>Folder</h3><pre>app/posts/[id]/page.tsx</pre><h3>URL</h3><pre>/posts/123</pre><h3>What happens</h3><ul><li>id comes from the URL</li><li>Next.js injects it into params</li></ul><pre>export default function Page({ params }: { params: { id: string } }) {<br>  return &lt;div&gt;Post ID: {params.id}&lt;/div&gt;;<br>}</pre><h3>Use case</h3><ul><li>Blog post</li><li>Product page</li><li>User profile</li></ul><p>This is <strong>99% of beginner use cases</strong>.</p><h3>2. Multiple Params (Structured Depth)</h3><h3>Folder</h3><pre>app/course/[courseId]/chapter/[chapterId]/page.tsx</pre><h3>URL</h3><pre>/course/mern/chapter/3</pre><h3>Params received</h3><pre>params = {<br>  courseId: &quot;mern&quot;,<br>  chapterId: &quot;3&quot;<br>}</pre><h3>When to use</h3><ul><li>Data has <strong>fixed structure</strong></li><li>You know how many levels you need</li><li>Clean, readable URLs</li></ul><p>Use this for:</p><ul><li>Courses</li><li>Documentation</li><li>Dashboards</li></ul><h3>3. Catch-All Routes (Unknown Depth)</h3><p>This is where most confusion starts.</p><h3>Folder</h3><pre>app/docs/[...slug]/page.tsx</pre><h3>URLs</h3><pre>/docs<br>/docs/react<br>/docs/react/hooks<br>/docs/react/hooks/useEffect</pre><h3>Params received</h3><pre>params.slug = [&quot;react&quot;, &quot;hooks&quot;, &quot;useEffect&quot;]</pre><p>It’s always an <strong>array</strong>.</p><h3>4. Optional Catch-All</h3><h3>Folder</h3><pre>app/docs/[[...slug]]/page.tsx</pre><h3>URLs supported</h3><pre>/docs<br>/docs/react<br>/docs/react/hooks</pre><h3>Difference from normal catch-all</h3><ul><li>Normal [...slug] → /docs not allowed</li><li>Optional [[...slug]] → /docs allowed</li></ul><p>Use this when:</p><ul><li>Root page + nested pages share same UI</li><li>Docs, knowledge base, learning platforms</li></ul><h3>5. Selecting Data Based on Depth</h3><p>This is the <strong>real power</strong>.</p><pre>const slug = params.slug ?? [];</pre><pre>if (slug.length === 0) {<br>  // Show docs home<br>} else if (slug.length === 1) {<br>  // Category page<br>} else if (slug.length === 2) {<br>  // Sub-category<br>} else {<br>  // Deep content<br>}</pre><p>You’re not creating folders endlessly.<br>You’re <strong>handling depth programmatically</strong>.</p><h3>6. How Real Apps Use This</h3><h3>Example: Course Platform</h3><pre>/course/mern<br>/course/mern/basics<br>/course/mern/basics/async-await</pre><p>Backend stores:</p><pre>{<br>  &quot;course&quot;: &quot;pern&quot;,<br>  &quot;sections&quot;: [&quot;basics&quot;, &quot;async-await&quot;]<br>}</pre><p>Frontend:</p><ul><li>URL → params</li><li>params → API request</li><li>API → DB query</li></ul><p><strong>URL is just a selector</strong>, not logic.</p><h3>7. Frontend vs Backend Responsibility</h3><h3>Frontend (Next.js)</h3><ul><li>Reads params</li><li>Renders UI</li><li>Calls APIs</li></ul><h3>Backend</h3><ul><li>Validates params</li><li>Fetches correct data</li><li>Handles ownership, auth, payments</li></ul><p>Params are <strong>not data</strong>, they are <strong>keys to data</strong>.</p><h3>8. When You Actually Need Catch-All</h3><p>Use catch-all <strong>only when</strong>:</p><ul><li>Depth is unknown</li><li>Content structure is flexible</li><li>You want CMS-like URLs</li></ul><p>Do NOT use it for:</p><ul><li>Simple CRUD</li><li>Fixed routes</li><li>Dashboards</li></ul><h3>Final Clarity I Got After Projects</h3><ul><li>[id] → simple &amp; clean</li><li>[a]/[b] → structured systems</li><li>[...slug] → flexible depth</li><li>[[...slug]] → flexible + root support</li></ul><p>Most confusion disappears once you <strong>stop reading and start breaking URLs</strong>.</p><p>I didn’t understand params by tutorials.<br>I understood them by building, deleting, and rebuilding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y9wZf7p9uSknsZ1rpJiRiQ.png" /></figure><p>That’s how Next.js routing finally made sense &amp; give this doc a read as well <a href="https://nextjs.org/docs/pages/building-your-application/routing/dynamic-routes">https://nextjs.org/docs/pages/building-your-application/routing/dynamic-routes</a></p><p>Next blog will be on indepth covering hydration &amp; it’s tests in nextjs<br>do clap, it feels good🤩🙏</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=10d638493708" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Do We Need TypeScript Over JavaScript?]]></title>
            <link>https://medium.com/@rajpurohitnikhil008/why-do-we-need-typescript-over-javascript-3c3f6a9427de?source=rss-8f80132b0257------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c3f6a9427de</guid>
            <dc:creator><![CDATA[Nikhil Rajpurohit]]></dc:creator>
            <pubDate>Mon, 03 Nov 2025 16:29:36 GMT</pubDate>
            <atom:updated>2025-11-03T16:29:36.028Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Welcome back to the blog</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*v79X5AkIVF6BLL0R_Suqlw.png" /></figure><p>Before diving into <em>why TypeScript is needed</em>, it’s important to understand what it means for a language to be <em>strongly typed</em> or <em>loosely typed</em>. These terms describe how strictly a programming language enforces type rules and handles type conversions</p><h3>Strongly Typed Languages</h3><p>A <strong>strongly typed language</strong> is one where the type of a variable is strictly enforced: meaning, once you declare a variable with a specific type, you cannot assign a value of a different type to it. The compiler or interpreter checks for type consistency <em>before</em> running the code, helping developers catch potential issues early.</p><p><strong>Examples:</strong> Java, C++, C#, Rust</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*6WDfVl58jAe-AU-Ls9lp0w.png" /></figure><h3>Loosely Typed Languages</h3><p>A <strong>loosely typed language</strong>, on the other hand, is more flexible with types. Variables can hold values of any type, and the interpreter often performs implicit type conversions automatically.</p><p><strong>Examples:</strong> Python, JavaScript, PHP, Perl</p><p><strong>Example JavaScript :</strong></p><pre>function main() {<br>  let number = 10;<br>  number = &quot;text&quot;; //here we can assign number as string <br>  return number;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*70_ZqpD2qcF5FHpNZj2XhA.png" /><figcaption>js &amp; cpp visit</figcaption></figure><h3>Why Do We Need TypeScript Over JavaScript?</h3><p><strong>Type Safety</strong><br> Catches type errors at compile time, reducing runtime crashes.<br><strong>Developer Experience</strong><br> Autocompletion and clear errors boost productivity.<br><strong>Scalability</strong><br> Keeps large codebases consistent and predictable.<br><strong>Refactoring</strong><br> Safer changes with compiler warnings.<br><strong>Collaboration</strong><br> Type annotations act as self-documentation.<br><strong>Compatibility</strong><br> Compiles to JavaScript, works everywhere JS runs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*zXVKzhq4YVv45TFZWcTBug.png" /></figure><h3>Compile the ts file to js file</h3><pre>tsc -b</pre><p>under Standing the The tsconfig.json File</p><p>The <strong>tsconfig.json</strong> file controls how TypeScript compiles your code. It has many options that affect compilation, output, and type checking. Here are some key ones:</p><h3>target</h3><ul><li>Specifies the <strong>ECMAScript version</strong> the TypeScript compiler will output.</li></ul><pre>const greet = (name: string) =&gt; `Hello, ${name}!`;</pre><ul><li>Compiled with <strong>ES5</strong> → Older syntax (functions become function instead of arrow functions, template strings converted to string concatenation).</li><li>Compiled with <strong>ES2020</strong> → Modern JavaScript (keeps arrow functions, template literals).</li></ul><h3>rootDir</h3><ul><li>Tells the compiler <strong>where to look for </strong><strong>.ts files</strong>.</li><li>Best practice: set it to the src folder.</li></ul><pre>&quot;rootDir&quot;: &quot;./src&quot;</pre><p>This ensures only files inside src are compiled.</p><h3>outDir</h3><ul><li>Specifies <strong>where compiled </strong><strong>.js files should go</strong>.</li></ul><pre>&quot;outDir&quot;: &quot;./dist&quot;</pre><ul><li>Compiles src/index.ts → dist/index.js.</li></ul><h3>noImplicitAny</h3><ul><li>Controls whether variables without a type are allowed to implicitly become any</li></ul><pre>const greet = (name) =&gt; `Hello, ${name}!`; // name has implicit type `any`</pre><p><strong>Enabled:</strong> TypeScript gives an error → forces you to explicitly type variables.</p><p><strong>Disabled:</strong> TypeScript allows it → name is any.</p><h3>TypeScript Essentials for Modern Development</h3><p><strong>Interfaces</strong> : Define object shapes and contracts for classes or objects.</p><pre>interface User { name: string; age: number; }</pre><p><strong>Types</strong> : Alias for types, can combine primitives, unions, or intersections.</p><pre>type ID = string | number;</pre><p><strong>Arrays</strong> : Hold multiple values of a type.</p><pre>const numbers: number[] = [1,2,3]</pre><p><strong>Enums: </strong>Named constants for better readability.</p><pre>enum Role { Admin, User, Guest }</pre><p><strong>Generics</strong> : Create reusable components with type placeholders.</p><pre>function identity&lt;T&gt;(value: T): T { return value; }</pre><p><strong>Utility Types</strong></p><ul><li><strong>Partial</strong> : Makes all properties optional</li><li><strong>Readonly</strong> : Makes properties immutable.</li><li><strong>Record: </strong>Creates an object type with specific key/value types.<strong>Pick / Omit / Map: </strong>Select, remove, or transform properties.</li></ul><p><strong>Type Inference in Zod</strong> : Automatically infers TypeScript types from schemas, reducing manual type declarations.</p><pre>const schema = z.object({ name: z.string() });<br>type User = z.infer&lt;typeof schema&gt;;</pre><p>Read more about Type Inference in Zod from here itslf<br><a href="https://zod.dev/basics?id=inferring-types">https://zod.dev/basics?id=inferring-types</a></p><p><strong>Read More In-Depth</strong><br> These are just quick highlights. To really get TypeScript, try stuff in real projects, play with edge cases, and see how it works with JS and Zod. That’s how you write clean, safe, and scalable code./</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*KZ-zM_OzopnSdCAvERnfNw.png" /></figure><p>Hope you vibed with the TypeScript tips, now go code something awesome!</p><p>Do clap ;)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c3f6a9427de" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JWT vs Session-Based Authentication]]></title>
            <link>https://medium.com/@rajpurohitnikhil008/jwt-vs-session-based-authentication-83988bd783af?source=rss-8f80132b0257------2</link>
            <guid isPermaLink="false">https://medium.com/p/83988bd783af</guid>
            <dc:creator><![CDATA[Nikhil Rajpurohit]]></dc:creator>
            <pubDate>Tue, 28 Oct 2025 13:16:08 GMT</pubDate>
            <atom:updated>2025-10-28T20:01:19.375Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Welcome back to the blog guys</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*3yY4jNBbv3_e7zcDeFNPVQ.png" /></figure><h3>Session-Based Authentication: The Classic Approach</h3><p>Session-based authentication has been around for decades.</p><p><strong>Login:</strong> The user provides credentials.<br><strong>Session creation:</strong> The server generates a unique session ID and stores user data in a server-side session store.<br><strong>Cookie delivery:</strong> The session ID is sent to the client as a cookie.<br><strong>Request validation:</strong> Every request from the client sends the cookie. The server looks up the session ID, retrieves user info, and validates access.</p><p><strong>Where the data lives:</strong></p><ul><li><strong>Server:</strong> Stores actual session data (user ID, permissions, timestamps).</li><li><strong>Client:</strong> Stores only the session ID in a cookie.</li></ul><p>Think of a <strong>SessionController</strong> handling all login, logout, and protected routes.</p><h3>Explaining via controllers logic:</h3><p>When a user logs in, their credentials are sent to the server. The server then creates a <strong>session</strong> on the server side and generates a <strong>unique session ID</strong>. This session ID is sent back to the frontend, usually stored as a <strong>cookie</strong>. The actual user data (like user ID, permissions, etc.) is stored <strong>only on the server</strong>, not on the client.</p><p>For protected routes or isAuthenticated bool, the server checks incoming requests for the session ID in the cookie. It looks up the corresponding session in the server’s session store, verifies the user, and then responds accordingly.</p><p>This flow ensures that the server maintains full control over user sessions, making <strong>logout and session invalidation simple</strong>, but it does require server-side storage for each active session.</p><pre>// controllers<br>export const login = (req, res) =&gt; {<br>  const { username } = req.body;<br>  // Normally validate credentials here<br>  req.session.user = { username };<br>  res.send(&#39;Logged in successfully!&#39;);<br>};</pre><pre>export const dashboard = (req, res) =&gt; {<br>  if (req.session.user) {<br>    res.send(`Welcome ${req.session.user.username} to your dashboard!`);<br>  } else {<br>    res.status(401).send(&#39;Unauthorized&#39;);<br>  }<br>};</pre><pre>export const dashboard = (req, res) =&gt; {<br>  if (req.session.user) {<br>    res.send(`Welcome ${req.session.user.username} to your dashboard!`);<br>  } else {<br>    res.status(401).send(&#39;Unauthorized&#39;);<br>  }<br>};</pre><pre>export const logout = (req, res) =&gt; {<br>  req.session.destroy(err =&gt; {<br>    if (err) return res.status(500).send(&#39;Logout failed&#39;);<br>    res.send(&#39;Logged out successfully!&#39;);<br>  });<br>};</pre><h3>JWT (JSON Web Token): The Modern Passport</h3><p>JWT is a <strong>stateless authentication mechanism</strong> — the server doesn’t have to remember anything. Think of it like a <strong>self-verifying passport</strong>:</p><ol><li><strong>Login:</strong> The user provides credentials.</li><li><strong>Token creation:</strong> The server generates a signed JWT containing the user’s info.</li><li><strong>Token storage:</strong> The client stores the JWT in localStorage or a cookie.</li><li><strong>Request validation:</strong> The client sends the JWT with every request. The server verifies the token signature and grants access if it’s valid.Similarly, a <strong>JwtController</strong> can handle login and token-protected routes.</li></ol><h3><strong>Explaining via controllers logic:</strong></h3><p>When a user logs in, their credentials are first sent to the server. The server then generates a <strong>JWT</strong> using jwt.sign(), which creates a signed token containing the user’s information. This token is sent back in the response and can be stored on the frontend, typically in <strong>localStorage </strong>for subsequent requests.</p><p>To secure protected routes, we use a <strong>middleware</strong> that intercepts incoming requests and checks for the JWT. The middleware verifies the token using a <strong>SECRET KEY</strong> stored in the .env file. Once the token is validated, the middleware identifies the user and allows the request to proceed, returning the appropriate response.</p><p>This flow ensures that the server doesn’t need to store session data, keeping the authentication <strong>stateless and scalable</strong>.</p><pre>// controllers<br>import jwt from &#39;jsonwebtoken&#39;;<br>const SECRET_KEY = &#39;myJwtSecret&#39;; //.env<br></pre><pre>export const login = (req, res) =&gt; {<br>  const { username } = req.body;<br>  // Normally validate credentials here<br>  const token = jwt.sign({ username }, SECRET_KEY, { expiresIn: &#39;1h&#39; });<br>  res.json({ token });<br>};</pre><pre>export const middleware = (req, res) =&gt; {<br>  const authHeader = req.headers[&#39;authorization&#39;];<br>  const token = authHeader &amp;&amp; authHeader.split(&#39; &#39;)[1];<br>  if (!token) return res.status(401).send(&#39;Unauthorized&#39;);<br><br>  jwt.verify(token, SECRET_KEY, (err, user) =&gt; {<br>    if (err) return res.status(403).send(&#39;Forbidden&#39;);<br>    res.send(`Welcome ${user.username} to your dashboard!`);<br>  });<br>};</pre><h3>So, Which Should You Use?</h3><ul><li><strong>Session-based:</strong> Great for small apps, strict security, or projects where server control is essential.</li><li><strong>JWT-based:</strong> Ideal for modern apps, mobile apps, distributed systems, or whenever you need <strong>stateless scalability</strong>.</li></ul><h3>Personal Preference is JWT</h3><p>For most projects I work on, <strong>JWT is my go-to choice</strong>. Its stateless nature, flexibility, and scalability make it perfect for building APIs, microservices, and SPAs (Single Page Applications). Plus, carrying extra info in the token itself simplifies permission handling across the app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*4Bzfstwr5P0iVi-LZxhWsA.png" /></figure><p>Thanks for reading &amp; do upvote the blog ;)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=83988bd783af" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding State Management in React: Context API v/s Zustand]]></title>
            <link>https://medium.com/@rajpurohitnikhil008/understanding-state-management-in-react-context-api-v-s-zustand-98e7272d3513?source=rss-8f80132b0257------2</link>
            <guid isPermaLink="false">https://medium.com/p/98e7272d3513</guid>
            <dc:creator><![CDATA[Nikhil Rajpurohit]]></dc:creator>
            <pubDate>Tue, 28 Oct 2025 12:50:24 GMT</pubDate>
            <atom:updated>2025-10-31T16:39:19.280Z</atom:updated>
            <content:encoded><![CDATA[<p>Sometimes, managing state feels like controlling an army of Iron Man suits… and yep, you need the right tools to avoid total chaos</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*BJE3s1Hmme8LNPxeTK7Axw.png" /></figure><p>In the world of React, “state” is basically the brain of your app. It remembers stuff user info, UI toggles, API responses… you name it. But as your app grows, managing state can get messy. Enter <strong>state management libraries</strong> like <strong>Context API</strong> and <strong>Zustand</strong> : our trusty sidekicks in this superhero saga.</p><h3>The Problem is Prop Drilling</h3><p>Before we talk tools, let’s understand the villain: <strong>prop drilling</strong>.</p><p>Imagine you have a component tree like this:</p><pre>&lt;App&gt;<br>  &lt;Header&gt;<br>    &lt;Nav&gt;<br>      &lt;Profile /&gt;<br>    &lt;/Nav&gt;<br>  &lt;/Header&gt;<br>&lt;/App&gt;</pre><p>And your user’s name lives in &lt;App&gt;. To show it in &lt;Profile&gt;, you have to pass it down like this:</p><pre>&lt;App&gt;<br>  &lt;Header user={user}&gt;<br>    &lt;Nav user={user}&gt;<br>      &lt;Profile user={user} /&gt;<br>    &lt;/Nav&gt;<br>  &lt;/Header&gt;<br>&lt;/App&gt;</pre><p>Ugly, right? That’s prop drilling. As apps grow, passing props through multiple layers becomes painful. We need something cleaner.</p><h3>Here comes Context API</h3><p>React’s <strong>Context API</strong> is like a teleportation device for props. Instead of passing props layer by layer, you can “provide” state at a high level and “consume” it anywhere below.</p><pre>// 1. Create a context<br>const UserContext = React.createContext();</pre><pre>// 2. Provide context<br>&lt;UserContext.Provider value={user}&gt;<br>  &lt;App /&gt;<br>&lt;/UserContext.Provider&gt;</pre><pre>// 3. Consume context<br>const user = useContext(UserContext);</pre><h3>Meet Zustand : State management library</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*qnHIhado6TgUcYcQJHA1xg.png" /></figure><p>Now, if Context API is a teleportation device, <strong>Zustand</strong> is like J.A.R.V.I.S. a super-efficient AI managing all your suits without drama.</p><p>Zustand is a lightweight state management library that lets you store state outside React components, avoiding unnecessary <strong>re-renders.</strong></p><pre>import create from &#39;zustand&#39;;</pre><pre>// Create store<br>const useStore = create((set) =&gt; ({<br>  user: null,<br>  setUser: (user) =&gt; set({ user }),<br>}));</pre><pre>// Use store in component<br>const user = useStore((state) =&gt; state.user);<br>const setUser = useStore((state) =&gt; state.setUser);</pre><p>State management doesn’t have to be a nightmare. If your app is small and simple, <strong>Context API</strong> is your best friend. But if you’re building the next Iron Man army-level app with multiple suits… <strong>Zustand</strong> is the J.A.R.V.I.S you want in your corner. 🦾</p><p>So, suit up, choose your tool, and let your React app fly</p><p>do the clapping as well 😋😋</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98e7272d3513" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[why Reactjs over of javascript/Vanillajs for beginners]]></title>
            <link>https://medium.com/@rajpurohitnikhil008/why-reactjs-over-of-javascript-vanillajs-for-beginners-da5a30b0ca98?source=rss-8f80132b0257------2</link>
            <guid isPermaLink="false">https://medium.com/p/da5a30b0ca98</guid>
            <dc:creator><![CDATA[Nikhil Rajpurohit]]></dc:creator>
            <pubDate>Tue, 07 Oct 2025 11:08:24 GMT</pubDate>
            <atom:updated>2025-10-28T12:27:50.958Z</atom:updated>
            <content:encoded><![CDATA[<h3>why Reactjs over of javascript/Vanillajs for beginners.</h3><p>When you first start web development, it feels simple: write HTML for structure, CSS for styling, and sprinkle JavaScript for interactivity. And yes, you <em>can</em> build websites that way.</p><p>But imagine this: you’re building a shopping cart or a real-time chat app. Suddenly, updating the UI for every tiny change, keeping data in sync, and reusing parts of your code becomes a nightmare. That’s why developers switched to <strong>React</strong></p><h3>The Problem with Vanilla JavaScript</h3><p>Let’s say you have a simple counter:</p><pre>&lt;div id=&quot;counter&quot;&gt;0&lt;/div&gt;<br>&lt;button id=&quot;increment&quot;&gt;Increment&lt;/button&gt;<br><br>&lt;script&gt;<br>  let count = 0;<br>  const counter = document.getElementById(&#39;counter&#39;);<br>  const button = document.getElementById(&#39;increment&#39;);<br><br>  button.addEventListener(&#39;click&#39;, () =&gt; {<br>    count++;<br>    counter.innerText = count;<br>  });<br>&lt;/script&gt;</pre><p>This works for one small counter. But what if you have <strong>ten counters</strong> or a <strong>list of 100 items</strong>? Now you’re manually updating the DOM everywhere. As your app grows, this approach becomes messy and hard to maintain.</p><h3>Virtual DOM</h3><p>The Virtual DOM is a lightweight copy of the real DOM. When your data changes, React updates the Virtual DOM first, compares it with the previous version (<strong>diffing</strong>), and updates only the parts of the real DOM that actually changed.</p><p>This is why React apps feel fast and responsive.</p><p>Here’s the same counter in React:</p><pre>import React, { useState } from &#39;react&#39;;<br><br>function Counter() {<br>  const [count, setCount] = useState(0);<br><br>  return (<br>    &lt;button onClick={() =&gt; setCount(count + 1)}&gt;<br>      Count: {count}<br>    &lt;/button&gt;<br>  );<br>}<br><br>export default Counter;<br></pre><p>No manual DOM manipulation, no getElementById(). React keeps the UI in sync with your state automatically.</p><p>Thanks for reading the blog,<br>above was just a small explanation to why &amp; how to start react</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da5a30b0ca98" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>