<?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: Vignesh Murugan</title>
    <description>The latest articles on Forem by Vignesh Murugan (@vigneshintech).</description>
    <link>https://forem.com/vigneshintech</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%2F1073323%2Fd5233f8c-a5b6-4ec9-bbf5-d81473a1f2ba.jpg</url>
      <title>Forem: Vignesh Murugan</title>
      <link>https://forem.com/vigneshintech</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/vigneshintech"/>
    <language>en</language>
    <item>
      <title>Server-Sent Events: A Simple Solution you didn't know you needed</title>
      <dc:creator>Vignesh Murugan</dc:creator>
      <pubDate>Wed, 18 Jun 2025 03:30:00 +0000</pubDate>
      <link>https://forem.com/vigneshintech/server-sent-events-a-simple-solution-you-didnt-know-you-needed-3c3m</link>
      <guid>https://forem.com/vigneshintech/server-sent-events-a-simple-solution-you-didnt-know-you-needed-3c3m</guid>
      <description>&lt;h2&gt;
  
  
  Server-Sent Events
&lt;/h2&gt;

&lt;p&gt;is a client-server communication technique with a one-way communication flow. Yes, as it implies the server will sent the data to the client while the client initially establishes a connection using Event Source and sits idle.&lt;/p&gt;

&lt;p&gt;I'm familiar with communication techniques like Short polling, Long polling, and Web Sockets and I implemented them at certain stages in my development journey. &lt;/p&gt;

&lt;p&gt;There came a situation where I have to find and use the right technique to solve the problem at hand, and this article is all about why and how I did it.&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%2Fn8rvdkrr3oc4t9kgd1lj.jpg" 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%2Fn8rvdkrr3oc4t9kgd1lj.jpg" alt="When confused with what to use for a real-time app" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before moving here's a quick overview of each of the technique:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Short Polling: &lt;br&gt;
The client repeatedly requests data from the server at fixed intervals. Simple but inefficient as it creates unnecessary network traffic when there's no new data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Long Polling:&lt;br&gt;
The client makes a request, and the server holds the connection open until it has new data to send. Less wasteful than short polling but can still be resource-intensive on the server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Web Sockets:&lt;br&gt;
Creates a persistent, bi-directional connection between client and server. Great for real-time applications where both sides need to communicate freely, but can be overkill for simpler use cases.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Server Sent Events:&lt;br&gt;
Establishes a one-way connection from server to client. The server can push data whenever it's ready while maintaining a single persistent connection. Lightweight and built into standard HTTP.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Here's why I had to use Server-Sent Events in my case:&lt;/p&gt;

&lt;p&gt;Client will make an API call to the Server consisting of multiple user's data from the dashboard, which the server will process one by one and send the results back one by one.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Initially I thought of using the Web Sockets for the above problem. But upon considering the nature of the problem, design architecture and the use-case it makes a clear sense to use Server-Sent Events.&lt;/p&gt;

&lt;p&gt;Here's why:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Simpler Implementation:&lt;br&gt;
SSE requires minimal setup compared to Web Sockets. The client-side code is surprisingly straightforward.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;One-way Communication Flow:&lt;br&gt;
In my case, data only needed to flow from server to client. The client requests the process to start, and then just listens for updates. No need for the overhead of bi-directional communication.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Standard HTTP: &lt;br&gt;
No special protocols or ports needed, making it easier to work with existing infrastructure and firewalls.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Implementation
&lt;/h2&gt;

&lt;p&gt;Here's a gist of how I implemented it:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Server-side (Node.js with Express):&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;app.get('/api/process-data', (req, res) =&amp;gt; {
  // Set SSE headers
  res.setHeader('Content-Type', 'text/event-stream');
  res.setHeader('Cache-Control', 'no-cache');
  res.setHeader('Connection', 'keep-alive');

  // Get users from the request
  const users = req.query.users.split(',');

  // Process each user and send results as they complete
  users.forEach((user, index) =&amp;gt; {
    // Simulate processing time
    setTimeout(() =&amp;gt; {
      const data = JSON.stringify({
        user,
        result: `Processed data for ${user}`,
        progress: ((index + 1) / users.length) * 100
      });

      // Send the event
      res.write(`data: ${data}\n\n`);

      // If last user, end the response
      if (index === users.length - 1) {
        res.write(`data: ${JSON.stringify({ done: true })}\n\n`);
      }
    }, index * 1000); // Process each user with a delay
  });
});

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Client-side:&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;function processUserData(users) {
  // Create the EventSource
  const eventSource = new EventSource(`/api/process-data?users=${users.join(',')}`);

  // Handle incoming messages
  eventSource.onmessage = (event) =&amp;gt; {
    const data = JSON.parse(event.data);

    if (data.done) {
      console.log('Processing complete!');
      eventSource.close();
      return;
    }

    console.log(`User: ${data.user}, Result: ${data.result}`);
    updateProgressBar(data.progress);
  };

  // Error handling
  eventSource.onerror = (error) =&amp;gt; {
    console.error('SSE error:', error);
    eventSource.close();
  };
}

function updateProgressBar(progress) {
  const progressBar = document.querySelector('.progress-bar');
  progressBar.style.width = `${progress}%`;
  progressBar.textContent = `${Math.round(progress)}%`;
}

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Advantages I Discovered&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Bandwidth Efficiency:&lt;br&gt;
Unlike Web Sockets which maintain a constant connection, SSE only sends data when there's something to send.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Easy Debugging:&lt;br&gt;
Since it's just HTTP, I could test and debug using standard tools like browser dev tools or Postman.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scalability:&lt;br&gt;
For my use case of processing user data sequentially, SSE scaled well without the connection management complexity of Web Sockets.&lt;br&gt;
Progressive Updates: Users see results as they become available, rather than waiting for all processing to complete.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Limitations to Keep in Mind:&lt;/strong&gt;&lt;br&gt;
It's not all sunshine and rainbows though. SSE does have some limitations:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Connection Limits:&lt;br&gt;
Browsers typically limit the number of concurrent SSE connections (usually 6 per domain).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;One-way Communication Only:&lt;br&gt;
If you need the client to send data back frequently, SSE isn't the right choice.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;IE Support: &lt;br&gt;
If you need to support Internet Explorer, you'll need a polyfill.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;Sometimes the simplest solution is the best one. While Web Sockets get all the glory in real-time applications, Server-Sent Events provided exactly what I needed with minimal overhead and complexity.&lt;/p&gt;

&lt;p&gt;For use cases where you need server-to-client updates without the complexity of Web Sockets, give SSE a try. You might find it's the solution you didn't know you needed.&lt;/p&gt;

&lt;p&gt;Have you used SSE in your projects? I'd love to hear about your experiences in the comments below!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>learning</category>
      <category>coding</category>
    </item>
    <item>
      <title>Next Js just killed React hooks</title>
      <dc:creator>Vignesh Murugan</dc:creator>
      <pubDate>Tue, 18 Jun 2024 04:30:00 +0000</pubDate>
      <link>https://forem.com/vigneshintech/next-js-just-killed-react-hooks-913</link>
      <guid>https://forem.com/vigneshintech/next-js-just-killed-react-hooks-913</guid>
      <description>&lt;p&gt;If you've used React hooks like &lt;strong&gt;useState()&lt;/strong&gt; and &lt;strong&gt;useEffect()&lt;/strong&gt; just like me, then the approach Next Js brought can be quite surprising and confusing to you. But trust me once you got hold of this concept you're gonna love it. &lt;/p&gt;

&lt;p&gt;It's React's way to use hooks like useState and useEffect to fetch data from the server and render it in a browser whenever a component mounts on the page. &lt;/p&gt;

&lt;p&gt;This traditional approach is quite ineffective when it comes to components that are not going to be interactive on the client side. &lt;br&gt;
You might've sensed what I'm trying to talk about, if not it's about the Server Side Rendering(SSR) or Server components introduced by Next Js. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Two important issues Next Js fixes here:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;SEO optimization&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Waterfall problem&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&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%2Fn4siusa8lhycp38rkd69.jpg" 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%2Fn4siusa8lhycp38rkd69.jpg" alt="Talk is cheap, show me the code" width="400" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enough of the talk, let me walk you through the code that gets the work done.&lt;br&gt;
First, let's see how React handles data fetching and rendering.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;React Code:&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;import axios from "axios";
import { useState, useEffect } from "react";

export default function UserCard() {
  //useState hook for state management
  const [user, setUser] = useState({});

  // useEffect hook for data fetching
  useEffect(() =&amp;gt; {
    axios
      .get("https://jsonplaceholder.typicode.com/users/1")
      .then((response) =&amp;gt; {
        setUser(response.data);
        console.log(response.data);
      });
  }, []);

  return (
    &amp;lt;div className="flex items-center justify-center h-screen"&amp;gt;
      &amp;lt;div className="flex flex-col justify-center items-center border-2 p-4 rounded-lg"&amp;gt;
        &amp;lt;p&amp;gt;
          &amp;lt;span className="font-bold"&amp;gt;Name: &amp;lt;/span&amp;gt;
          {user?.name}
        &amp;lt;/p&amp;gt;
        &amp;lt;p&amp;gt;
          &amp;lt;span className="font-bold"&amp;gt;Email: &amp;lt;/span&amp;gt;
          {user?.email}
        &amp;lt;/p&amp;gt;
        &amp;lt;p&amp;gt;
          &amp;lt;span className="font-bold"&amp;gt;City: &amp;lt;/span&amp;gt;
          {user?.address?.city}
        &amp;lt;/p&amp;gt;
        &amp;lt;p&amp;gt;
          &amp;lt;span className="font-bold"&amp;gt;Company: &amp;lt;/span&amp;gt;
          {user?.company?.name}
        &amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code is for a UserCard React component which we render on the client side.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&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%2Fzsdp8umci4f2r6gzo0ny.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%2Fzsdp8umci4f2r6gzo0ny.png" alt="react code output" width="592" height="268"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's how the process works in React:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The UserCard component is rendered initially.&lt;/li&gt;
&lt;li&gt;The useEffect hook runs because of the empty dependency array [], meaning it will only run once when the component mounts.&lt;/li&gt;
&lt;li&gt;Inside useEffect, an HTTP GET request is made using Axios to fetch user data from the specified URL (&lt;a href="https://jsonplaceholder.typicode.com/users/1" rel="noopener noreferrer"&gt;https://jsonplaceholder.typicode.com/users/1&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;Once the response is received, the setUser function is called with the fetched user data, updating the state.&lt;/li&gt;
&lt;li&gt;As a result of the state update, the component re-renders with the updated user data.&lt;/li&gt;
&lt;/ol&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%2F622xlzd0dmcpk12m5l1l.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%2F622xlzd0dmcpk12m5l1l.png" alt="explanation of react hooks operation" width="685" height="358"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;It's time to find out what Next Js has got to offer us!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next Js code:&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;import axios from "axios";

// API call with no useState and useEffect hooks
async function getUser() {
  const response = await axios.get("https://jsonplaceholder.typicode.com/users/1")
 return response.data;
}

// Function here is a Async Function
export default async function UserCard() {
  const user = await getUser();

  return (
    &amp;lt;div className="flex items-center justify-center h-screen"&amp;gt;
      &amp;lt;div className="flex flex-col justify-center items-center border-2 p-4 rounded-lg"&amp;gt;
        &amp;lt;p&amp;gt;
          &amp;lt;span className="font-bold"&amp;gt;Name: &amp;lt;/span&amp;gt;
          {user?.name}
        &amp;lt;/p&amp;gt;
        &amp;lt;p&amp;gt;
          &amp;lt;span className="font-bold"&amp;gt;Email: &amp;lt;/span&amp;gt;
          {user?.email}
        &amp;lt;/p&amp;gt;
        &amp;lt;p&amp;gt;
          &amp;lt;span className="font-bold"&amp;gt;City: &amp;lt;/span&amp;gt;
          {user?.address?.city}
        &amp;lt;/p&amp;gt;
        &amp;lt;p&amp;gt;
          &amp;lt;span className="font-bold"&amp;gt;Company: &amp;lt;/span&amp;gt;
          {user?.company?.name}
        &amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Next Js, every component is a Server component by default.&lt;/p&gt;

&lt;p&gt;Server-side rendering (SSR) is a great add-on to React's arsenal, as it will improve the SEO and waterfall problem.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The UserCard component will be rendered on the server side, which means the API call will be made on the server and the response data will be populated inside the component. &lt;/li&gt;
&lt;li&gt;Next Js will send the component with all the populated data which is SEO-friendly to the client side (note: this is a server component).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;React has a big issue, it's the &lt;strong&gt;Anti SEO pattern&lt;/strong&gt;, but Next Js fixed it and made SSR popular. Doing the same SSR in React can be a bit tedious set up initially, but we also need to consider that Next Js is a full-stack framework.&lt;/p&gt;

&lt;p&gt;Even though SSR might sound cool it also comes with some drawbacks like load on the server side, static components.&lt;br&gt;
 &lt;br&gt;
It's essential to understand the tradeoffs each approach provides and choose the one that fits your needs.&lt;/p&gt;

&lt;p&gt;Follow me for more awesome tech contents!&lt;br&gt;
&lt;a href="https://www.linkedin.com/in/vignesh-murugan-dev/" rel="noopener noreferrer"&gt;LinkedIn &lt;/a&gt;| &lt;a href="https://x.com/Web3Vicky" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>nextjs</category>
      <category>ssr</category>
      <category>reacthooks</category>
    </item>
    <item>
      <title>AWS Arsenal: An array of Cloud Services</title>
      <dc:creator>Vignesh Murugan</dc:creator>
      <pubDate>Tue, 05 Mar 2024 05:35:00 +0000</pubDate>
      <link>https://forem.com/vigneshintech/aws-arsenal-an-array-of-cloud-services-4k1o</link>
      <guid>https://forem.com/vigneshintech/aws-arsenal-an-array-of-cloud-services-4k1o</guid>
      <description>&lt;p&gt;&lt;strong&gt;AWS&lt;/strong&gt; provides Cloud-based services to perform Cloud computing, Web hosting, Storage, Networking, Security, and much more. AWS is a &lt;strong&gt;pay-as-you-use service&lt;/strong&gt;, which means you only pay for the services you use in the AWS cloud infrastructure making it more accessible to everyone.&lt;/p&gt;

&lt;p&gt;First things first. What is AWS? It stands for &lt;strong&gt;Amazon Web Services&lt;/strong&gt;. Imagine a network of global computer servers located worldwide that you can rent for your usage, that's what AWS is. &lt;br&gt;
In the world of Cloud Computing, AWS has the first-comer advantage and a &lt;strong&gt;market share of 31% in Cloud Infrastructure&lt;/strong&gt; service. &lt;/p&gt;




&lt;p&gt;Today we are going to discuss a few commonly used AWS Cloud services, what are they, and why we need to use them.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;EC2&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;AMPLIFY&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;LAMBDA&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;S3&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CLOUDFRONT&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ACM&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  EC2 🖥️
&lt;/h2&gt;

&lt;p&gt;EC2 stands for &lt;strong&gt;Elastic Compute Cloud&lt;/strong&gt;. What is EC2 in layman's terms? Imagine a &lt;strong&gt;Virtual machine&lt;/strong&gt; just like your PC or Laptop but in the cloud, you can access it anytime/ anywhere and all you need is a computer with internet access. &lt;/p&gt;

&lt;p&gt;You can perform any computing operation in your EC2 instance. The main advantage of an EC2 instance is that you can choose from a variety of Operating Systems and can easily upgrade/ downgrade the configurations anytime.&lt;/p&gt;

&lt;h2&gt;
  
  
  AMPLIFY 📲
&lt;/h2&gt;

&lt;p&gt;AWS Amplify is a cloud service that makes it easy to create &lt;strong&gt;Full-stack web and mobile applications&lt;/strong&gt; that are scalable with cloud infrastructure. It supports a wide range of frameworks, languages, and features like Auth, Storage, and Functions. It takes care of the &lt;strong&gt;CI/ CD&lt;/strong&gt; for you so that you can focus on building great products for your users.&lt;/p&gt;

&lt;h2&gt;
  
  
  LAMBDA ⁁
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;AWS Lambda&lt;/strong&gt; is a cloud-computing service that allows developers to build and run code without managing servers. It is also known as Function-as-a-service(&lt;strong&gt;FaaS&lt;/strong&gt;) or &lt;strong&gt;Serverless&lt;/strong&gt;. It is mainly used to &lt;strong&gt;run backend applications&lt;/strong&gt; in the Cloud without spending much time setting up and maintaining server infrastructure. &lt;/p&gt;

&lt;h2&gt;
  
  
  S3 🪣
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;AWS S3&lt;/strong&gt; stands for &lt;strong&gt;Simple Storage Service&lt;/strong&gt;, S3 is an &lt;strong&gt;object storage service&lt;/strong&gt; through a web interface. S3 helps to store and retrieve any amount of data like &lt;strong&gt;images, audio, videos, and document files as objects&lt;/strong&gt; in the cloud that can be accessed anywhere.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Files are stored in Bucket&lt;/strong&gt;. A bucket is like a folder available in S3 that stores the files. It provides developers with a secure, flexible, and durable way to store any data and limit its accessibility to others by authentication.&lt;/p&gt;

&lt;h2&gt;
  
  
  CLOUDFRONT 🌦️
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;AWS CloudFront&lt;/strong&gt; is a &lt;strong&gt;CDN(content delivery network)&lt;/strong&gt; service that helps &lt;strong&gt;distribute content across the world&lt;/strong&gt; through its cloud network. You can serve files, images, documents, videos, and applications to the end users through &lt;strong&gt;CDN links&lt;/strong&gt;. The main advantage is that Amazon has a lot of cloud servers around the world so the content you distribute can be delivered to the end user with the lowest latency and high transfer speed.&lt;/p&gt;

&lt;h2&gt;
  
  
  ACM 📇
&lt;/h2&gt;

&lt;p&gt;AWS ACM stands for &lt;strong&gt;AWS Certificate Manager&lt;/strong&gt;. It is a one-stop solution for creating, storing, and renewing &lt;strong&gt;public and private SSL/ TLS certificates&lt;/strong&gt; for AWS and other internal services. In simple terms, it helps to secure your local HTTP network and turn it into **HTTPS **that your users can access with trust.&lt;/p&gt;




&lt;p&gt;Thanks for reading my article! Let me know your thoughts. ❤️&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>cloudcomputing</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Boost Your Productivity with Redux Toolkit (RTK) in React JS/Next JS</title>
      <dc:creator>Vignesh Murugan</dc:creator>
      <pubDate>Fri, 28 Apr 2023 09:36:12 +0000</pubDate>
      <link>https://forem.com/vigneshintech/boost-your-productivity-with-redux-toolkit-rtk-in-react-jsnext-js-3ik8</link>
      <guid>https://forem.com/vigneshintech/boost-your-productivity-with-redux-toolkit-rtk-in-react-jsnext-js-3ik8</guid>
      <description>&lt;p&gt;If you’re looking for a proper guide to using REDUX TOOLKIT (RTK) with REACT/ NEXT JS for your project, then you have landed at the right location.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Redux Toolkit is a powerful and user-friendly library that simplifies state management in React applications, allowing developers to focus on building their apps rather than worrying about managing complex state interactions.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Why do I say that? Because I’m also just like you searched for the correct way to implement RTK in my project but was unable to get any easy, simplified approach. After lots of struggle, I found the right way of implementing RTK in my project, so I’m here to share my learning with you.&lt;/p&gt;

&lt;p&gt;Enough of the talk, let’s dive into the coding part. 🌊🏊‍♂️&lt;/p&gt;

&lt;p&gt;First things First, I hope you know how to create a React/ Next project so I’m skipping those steps and getting directly to the point. Here I used NEXT JS 13 application since CRA is officially dead.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;1.) Install the necessary dependencies&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install react-redux
npm install @reduxjs/toolkit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;2.) Create a folder named “store” in your project’s root directory&lt;/p&gt;

&lt;p&gt;3.) Inside that directory create a file named “store.js” which will act as our centralized store for state management.&lt;/p&gt;

&lt;p&gt;4.) In “store.js” import ‘configureStore’ from Redux Toolkit&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

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

import { configureStore } from "@reduxjs/toolkit";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;5) Create a new Redux store called “store” as the variable name and use configureStore function to add your reducers. As of now enter the code below, then we can create some reducers and get back here.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

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

import { configureStore } from "@reduxjs/toolkit";

const store = configureStore({
  reducer: {
    // your reducers here
  },
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;6.) We can create multiple slice reducers based on our needs and functionality and add it to the reducer object of ‘store.js’ . Here I will create a slice reducer of user details and export it to the store.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Create a file called ‘userSlice.js’ under the “store” directory where we will save the state variables of username and password entered by the user.&lt;br&gt;
&lt;/p&gt;

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

import { createSlice } from "@reduxjs/toolkit";

const initialState = {
    user: '',
    password: '',
}

const userSlice = createSlice({
    name: 'user',
    initialState,
    reducers: {
        setUser: (state, action) =&amp;gt; {
            state.user = action.payload;
        },
        setPassword: (state, action) =&amp;gt; {
            state.password = action.payload;
        }
    }
});

export const { setUser, setPassword } = userSlice.actions;

export default userSlice.reducer;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Import the ‘createSlice’ from redux toolkit libaray.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a variable called initialState and set the initial values. Here user, password are assigned with ‘ ’ empty strings as initial values.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now create a Redux Slice using createSlice function with the name, initial state, and reducers (setUser, setPassword).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Each reducer takes in a ‘state’ object and an ‘action’ object.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;‘setUser’ sets the ‘user’ state to the ‘action.payload’ (which is passed in when the action is dispatched).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;‘setPassword’ sets the ‘password’ state to the ‘action.payload’&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The ‘export’ statement exports both the ‘setUser’ and ‘setPassword’ actions as named exports, and exports the ‘userSlice.reducer’ as the default export.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;7.) Now let’s import the ‘userSlice’ to the store and use it in our reducers object. The final code in ‘store.js’ will look like this with our ‘store’ exported.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

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

import { configureStore } from "@reduxjs/toolkit";
import authSlice from "./authSlice";

const store = configureStore({
  reducer: {
    auth: authSlice,
  },
});

export default store;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;8.) Now we need to import our store and pass it to the Provider, then wrap ouraround the ‘App’ component in REACT/  in terms of NEXT JS. So the code in the ‘App.js’ or ‘_app.js’ component will look like below.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

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

import { Provider } from 'react-redux';
import store from '../store/store';

function MyApp({ Component, pageProps }) {
  return (
    &amp;lt;Provider store={store}&amp;gt;
      &amp;lt;Component {...pageProps} /&amp;gt;
    &amp;lt;/Provider&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That’s it, you have successfully integrated REDUX TOOLKIT to your REACT/ NEXT application.&lt;/p&gt;

&lt;p&gt;Tada 🧙‍♂️🎇It might sound/ look hectic at the beginning, but trust me using REDUX straightforward is much more complicated than this and that’s why REDUX became legacy code and RTK came into the picture. Try using this a few times and trust me the learning curve of RTK will become much smoother.&lt;/p&gt;

&lt;p&gt;Is it useful?! Give this a clap and share it with your friends, do follow for more content.&lt;/p&gt;

&lt;p&gt;See you in the next article, Happy Coding! 👨‍💻❤&lt;/p&gt;

</description>
      <category>react</category>
      <category>redux</category>
      <category>nextjs</category>
      <category>rtk</category>
    </item>
  </channel>
</rss>
