<?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: Hassan Zahar Rifat</title>
    <description>The latest articles on Forem by Hassan Zahar Rifat (@hzahar).</description>
    <link>https://forem.com/hzahar</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%2F786118%2Fc6997899-a7db-4daa-8f8b-c5ab17702705.jpeg</url>
      <title>Forem: Hassan Zahar Rifat</title>
      <link>https://forem.com/hzahar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/hzahar"/>
    <language>en</language>
    <item>
      <title>I Built Cursor for Spreadsheets.. But What for?</title>
      <dc:creator>Hassan Zahar Rifat</dc:creator>
      <pubDate>Tue, 01 Jul 2025 20:30:53 +0000</pubDate>
      <link>https://forem.com/hzahar/i-built-cursor-for-spreadsheets-but-what-for-364e</link>
      <guid>https://forem.com/hzahar/i-built-cursor-for-spreadsheets-but-what-for-364e</guid>
      <description>&lt;h2&gt;
  
  
  🚀 Why I Built It
&lt;/h2&gt;

&lt;p&gt;I manage a side project with a customer base, and like a lot of solo builders, I frequently use Google Sheets to keep track of metrics, revenue, and day-to-day data.&lt;/p&gt;

&lt;p&gt;Over time, I found myself doing the same repetitive tasks — writing formulas, cleaning up tables, copying logic across rows and it started to feel inefficient. Not difficult, just unnecessarily manual.&lt;/p&gt;

&lt;p&gt;That’s when I realized I didn’t want to build another product just for the sake of the hackathon. I wanted to build something that I would actually use, something would solve a real business problem.&lt;/p&gt;

&lt;p&gt;So I scrapped my original idea and started working on a spreadsheet that behaves more like an assistant. One where I could type plain language and get back working formulas, insights, or even full summaries without needing to remember exact syntax or jump between tabs.&lt;/p&gt;

&lt;p&gt;That’s how &lt;strong&gt;Cellmate AI&lt;/strong&gt; started.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔧 Building with Bolt
&lt;/h2&gt;

&lt;p&gt;Once I committed to the idea, I had around 15 days left in the World's Largest Hackathon presented by Bolt. To move quickly, I relied on &lt;a href="https://bolt.new" rel="noopener noreferrer"&gt;Bolt.new&lt;/a&gt; to scaffold most of the application — from UI components to basic functionality.&lt;/p&gt;

&lt;p&gt;Almost every major feature started with a Bolt prompt.&lt;/p&gt;

&lt;p&gt;Some initial examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;"Create a React spreadsheet grid with editable cells"&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;"Add a formula bar which will for now contain the cell value"&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;"Add a toolbar with basic formatting like color, bg, alignments"&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;"Add CSV import/export support"&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Bolt helped me move fast, especially when I broke down prompts into focused tasks. Larger prompts often generated bloated or buggy code, so I kept things small and stitched the parts together manually.&lt;/p&gt;

&lt;p&gt;When Bolt-generated output broke existing logic or styling, I cleaned it up myself. I avoided over-engineering and left out anything that wasn't essential.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 Prompt Strategy and Workflow
&lt;/h2&gt;

&lt;p&gt;My workflow eventually settled into this loop:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Write a clear, single-purpose prompt&lt;/li&gt;
&lt;li&gt;Let Bolt generate a scaffold&lt;/li&gt;
&lt;li&gt;Test it immediately&lt;/li&gt;
&lt;li&gt;Patch or rewrite the pieces that broke&lt;/li&gt;
&lt;li&gt;Move to the next task&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By keeping each step tight, I avoided the usual AI-overhead and kept things predictable. This approach worked well — especially when combining AI-generated logic with my own cleanup.&lt;/p&gt;




&lt;h2&gt;
  
  
  📸 What the App Does
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Cellmate AI&lt;/strong&gt; is a lightweight spreadsheet app with built-in AI support — designed to make working with data faster and less manual.&lt;/p&gt;

&lt;p&gt;Here’s what it currently supports:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Formula generation from plain text&lt;/strong&gt;&lt;br&gt;
Type something like &lt;code&gt;"Sum column B if column C is complete"&lt;/code&gt; and it returns a working &lt;code&gt;=SUMIF()&lt;/code&gt; formula.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Sheet-level changes via prompt&lt;/strong&gt;&lt;br&gt;
You can ask it to delete rows, add columns, or clean up sections without touching any menu.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Natural language insights&lt;/strong&gt;&lt;br&gt;
Ask questions like &lt;code&gt;"Which product had the highest revenue?"&lt;/code&gt; or &lt;code&gt;"How many users signed up last week?"&lt;/code&gt; — and it gives you answers based on the data in the sheet.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Auto-generated summary reports&lt;/strong&gt;&lt;br&gt;
One prompt can generate a full summary of the sheet contents.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;CSV import/export&lt;/strong&gt;&lt;br&gt;
Quickly upload or download data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Supabase integration for persistence and auth&lt;/strong&gt;&lt;br&gt;
User sessions and sheet data are synced using Supabase — so it works across devices.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧰 Tech Stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Bolt (scaffolding + code generation)&lt;/li&gt;
&lt;li&gt;React + TypeScript
&lt;/li&gt;
&lt;li&gt;ShadCN&lt;/li&gt;
&lt;li&gt;TailwindCSS
&lt;/li&gt;
&lt;li&gt;Vite
&lt;/li&gt;
&lt;li&gt;OpenAI (natural language → formula/insight)
&lt;/li&gt;
&lt;li&gt;Supabase (auth + database)
&lt;/li&gt;
&lt;li&gt;Hosted on Netlify&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ✅ What’s Working
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Spreadsheet grid with editable cells
&lt;/li&gt;
&lt;li&gt;Formula generation from plain text
&lt;/li&gt;
&lt;li&gt;Sheet-level structural changes via prompt
&lt;/li&gt;
&lt;li&gt;Insights and summary report generation
&lt;/li&gt;
&lt;li&gt;CSV import/export
&lt;/li&gt;
&lt;li&gt;User login and data sync via Supabase&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Here's a demo video describing the current stage (0.75x might help):&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/68-IMUzXERc"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;




&lt;h2&gt;
  
  
  🐞 What’s Missing (for now)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;No multi-sheet/tab support
&lt;/li&gt;
&lt;li&gt;No real-time collaboration
&lt;/li&gt;
&lt;li&gt;No AI-generated charting or visualization tools
&lt;/li&gt;
&lt;li&gt;Some UX rough edges in prompt result placement&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  💡 What I Learned
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Building from a real pain point made it easier to stay focused.&lt;/li&gt;
&lt;li&gt;Bolt can be used beyond prototyping; it landed some great features by providing clear-cut instructions.&lt;/li&gt;
&lt;li&gt;Prompt clarity mattered more than prompt length — vague requests broke things quickly. (Thanks to revert/undo option)&lt;/li&gt;
&lt;li&gt;I didn’t try to do everything, and it helped me finish a foundational MVP.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔜 What’s Next
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Support for Excel file uploads
&lt;/li&gt;
&lt;li&gt;Summary dashboards and report saving
&lt;/li&gt;
&lt;li&gt;Sharing and collaboration features
&lt;/li&gt;
&lt;li&gt;Possibly releasing a public version with pricing&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Thanks to Bolt, DEV, and the hackathon team — the pressure helped me shift gears and build something that I'm happy about.&lt;/p&gt;

&lt;p&gt;Try it out: &lt;a href="https://cellmateai.xyz" rel="noopener noreferrer"&gt;https://cellmateai.xyz&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Questions, feedback, bugs? Happy to hear them.&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>wlhchallenge</category>
      <category>bolt</category>
      <category>ai</category>
    </item>
    <item>
      <title>Communication Among Services in Microservices Architecture? Let's Clear it Out!</title>
      <dc:creator>Hassan Zahar Rifat</dc:creator>
      <pubDate>Mon, 27 May 2024 19:10:37 +0000</pubDate>
      <link>https://forem.com/hzahar/communication-among-services-in-microservices-architecture-lets-clear-it-out-14h6</link>
      <guid>https://forem.com/hzahar/communication-among-services-in-microservices-architecture-lets-clear-it-out-14h6</guid>
      <description>&lt;p&gt;When services communicate with each other in a microservices architecture, there are two common patterns: Sync and Async.&lt;/p&gt;

&lt;p&gt;In Sync architecture, services call each other typically via direct API calls or other request/response methods. This means that if a service is down, all other dependent services are also down. But this pattern can simplify handling data consistency and reduce data duplication as each service can fetch data when needed.&lt;/p&gt;

&lt;p&gt;In Async architecture, services send messages to each other via messaging systems like message queues or event streams where messages are sent without requiring an immediate response. Services are relatively independent and don’t need to wait for each other to respond. If one service fails, other services continue functioning without caring much and will process messages as they become available once the failed service is restored. But this approach usually requires data duplication and extra consistency handling mechanisms, since each service most likely needs to have its own data copy to serve independently.&lt;/p&gt;

&lt;p&gt;It might seem like the async approach is the best choice for unicorn projects, but this isn't always the case. Whether to use Sync or Async pattern depends on various factors such as the requirements of the software, budget, market demand, etc. It's important to note that gaining one advantage usually means sacrificing another. Most large-scale software is built on a hybrid pattern to maximize optimization.&lt;/p&gt;

&lt;p&gt;I'm building a simple application using microservices architecture in my free time for fun.&lt;/p&gt;

&lt;p&gt;Shoot any questions you have. Stay tuned to get updates &amp;lt;3&lt;/p&gt;

</description>
      <category>microservices</category>
      <category>architecture</category>
      <category>softwareengineering</category>
      <category>software</category>
    </item>
    <item>
      <title>10 Impeccable JavaScript Projects for Beginners</title>
      <dc:creator>Hassan Zahar Rifat</dc:creator>
      <pubDate>Mon, 26 Jun 2023 09:17:32 +0000</pubDate>
      <link>https://forem.com/hzahar/10-impeccable-javascript-projects-for-beginners-2b53</link>
      <guid>https://forem.com/hzahar/10-impeccable-javascript-projects-for-beginners-2b53</guid>
      <description>&lt;p&gt;Hey, JavaScript enthusiasts! &lt;/p&gt;

&lt;p&gt;Congrats on your decision of learning JavaScript. You've entered into an ocean of opportunities. Now, here without any biting around the bush, I'd help you to push your level forward from novice to semi-intermediate.&lt;/p&gt;

&lt;p&gt;How's that possible? Well, your skills could be sharpen like a sword only by doing projects. But what projects would be the best fit for beginners? We'll uncover that now.&lt;/p&gt;

&lt;p&gt;If you're just starting out with JavaScript, I could suggest 10 hottest beginner-friendly JS projects:&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Drum Kit:
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;Create a virtual drum kit where users can play different drum sounds by pressing corresponding keys on their keyboard or by clicking on the drum pads. Enhance it with visual feedback and interactive animations. &lt;/p&gt;

&lt;p&gt;Play the 'numb', record, and share!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  2. Image Slider:
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;Develop an image slider that cycles through a collection of images. Implement features like navigation arrows, auto-play, and image captions. You can even add transition effects for a visually appealing slider. It'd be a great utility library.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  3. Quiz Application:
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;Develop an interactive quiz app with multiple-choice questions. Implement a scoring system, timers, and a progress bar to make it engaging. Add different difficulty levels or integrate external APIs to fetch quiz questions from various categories.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  4. Expense Tracker:
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;Build an expense tracker that allows users to add and categorize their expenses. Implement features like income tracking, expense filtering, and graphical representations of spending patterns. It'd help you grasp data manipulation and data visualization.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  5. Chat Application:
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;Develop a real-time chat application using technologies like Node.js and Socket.IO. Enable users to join rooms, exchange messages, and display online/offline status. Enhance it further with features like file sharing and user authentication.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  6. Recipe Finder:
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;Create a recipe finder app that fetches recipes from various sources using APIs. Implement search filters, sorting options, and user ratings. You can even include advanced features like dietary restrictions, personalized recommendations, and meal planning.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  7. GitHub Profile Viewer:
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;Develop an application that fetches and displays GitHub user profiles. Include features like repositories, followers, activity feeds, and user statistics. You can also experiment with data visualization libraries to present the information.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  8. Music Player:
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;Build a sleek and user-friendly music player that can stream and play music from various sources. Implement features like playlists, song searching, and audio visualization. Take it a step further by integrating APIs to fetch lyrics or album information.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  9. E-commerce Store:
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;Create a fully functional e-commerce website with features like product listing, search, shopping cart, and secure payment integration. Focus on responsive design and smooth user experience.&lt;/p&gt;

&lt;p&gt;I know it's a challenging and super common project, but worth it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  10. Social Media Dashboard:
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;Develop a social media dashboard that aggregates data from multiple platforms like LinkedIn, Twitter, and Instagram. Implement features like post-scheduling, analytics, and social media integration.&lt;/p&gt;

&lt;p&gt;PS: It's my personal favorite!!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Thanks for checking out this blog.&lt;br&gt;
Now the first thing to do:&lt;br&gt;
Pick up one and start.&lt;br&gt;
Happy coding! 🚀&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>coding</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Can I Show Pie Charts on My Website? - Introducing Recharts</title>
      <dc:creator>Hassan Zahar Rifat</dc:creator>
      <pubDate>Sat, 05 Mar 2022 03:18:03 +0000</pubDate>
      <link>https://forem.com/hzahar/can-i-show-pie-charts-on-my-website-introducing-recharts-55p</link>
      <guid>https://forem.com/hzahar/can-i-show-pie-charts-on-my-website-introducing-recharts-55p</guid>
      <description>&lt;p&gt;&lt;strong&gt;Pre-requisite:&lt;/strong&gt; Basic React.js&lt;/p&gt;

&lt;p&gt;Hello developers! Thanks in advance for your interest. Maybe at this moment, you're thinking about improving UX of your website by visualizing data in form of pie charts or something like that. Because at the end of the day, user impression mostly depends on the UX. So the good news is if you're using React, you can work on data visualization easily with Reacharts package.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Reacharts?&lt;/strong&gt;&lt;br&gt;
Hold on a minute before going to the main attraction. Do we know what Reacharts is? According to the official documentation, Recharts is an npm package for using in React projects built on top of the SVG elements (We can follow SVG styling rules to style) with lightweight dependency of D3 (JavaScript library to visualize data) submodules. It's customizable by changing the props values.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installation&lt;/strong&gt;&lt;br&gt;
Okay, now! moving on to the installation.&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 recharts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Importing Components&lt;/strong&gt;&lt;br&gt;
After installation, we can use the components of Recharts by importing. To make a simple pie chart, we need to import ResponsiveContainer, PieChart, Pie, ToolTip. ResponsiveContainer is a wrapping container with responsive behavior. PieChart is a canvas component. Inside this component, one or many Pie component can be declared. Also, Other features of the pie chart(s) of the canvas can be declared inside PieChart (such as: ToolTip). Pie is the component for printing a pie chart. Tooltip is used if we want to show details on hovering.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import { ResponsiveContainer, PieChart, Pie, Tooltip } from 'recharts';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Structure of the raw data&lt;/strong&gt;&lt;br&gt;
Let's understand the structure of the data we have to have. In this particular example, we should have an array of objects and each object will have name and value keys with their corresponding values. name (string type) would contain the title of the data and value (number type) would be the data. For example,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const data = [
  { name: 'A', value: 400 },
  { name: 'B', value: 300 },
  { name: 'C', value: 300 },
  { name: 'D', value: 200 },
  { name: 'E', value: 100 },
  { name: 'F', value: 700 },
];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Core Components and Explanation&lt;/strong&gt;&lt;br&gt;
After that, we'll be able to print our pie chart at the twinkles of an eye. We have to write our codes inside return of the component. Let's have a look of the code. Don't worry, I won't leave without explaining necessary parts.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    return (
      &amp;lt;ResponsiveContainer width="100%" height="100%"&amp;gt;
        &amp;lt;PieChart width={400} height={400}&amp;gt;
          &amp;lt;Pie
            dataKey="value"
            isAnimationActive={true}
            data={data}
            cx="50%"
            cy="50%"
            innerRadius={0}
            outerRadius={80}
            fill="#8884d8"
            label
          /&amp;gt;
          &amp;lt;Tooltip /&amp;gt;
        &amp;lt;/PieChart&amp;gt;
      &amp;lt;/ResponsiveContainer&amp;gt;
    )
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We have assigned the canvas size 400x400 in PieChart component. After that, we have decent amount of props in Pie components in form of SVG styling. cx and cy defines the position of x and y axis respectively. Assigning 50% both in cx and cy means the pie chart will be shown at the center. label means label={true} and we'll get the pie chart labeled with the values nicely if label is true. isAnimationTrue sets default animations. If we don't want the animation, we have to assign false. fill would be used to set background color. outerRadius defines the solid redial size. But if we want to make the pie hollow, we need to change the value of innerRadius and assign more than 0. Most importantly, We need to pass the dataset as props named data. And finally, we must have to define the dataKey prop with value, so that it can extract the value of the value key of the dataset and do the elementary math for visualizing the pie chart.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Concluding Remarks&lt;/strong&gt;&lt;br&gt;
So far, we've got enough for getting started. If you like and appreciate this blog, we'll be going deeper towards data visualization. &lt;em&gt;&lt;strong&gt;Note:&lt;/strong&gt;&lt;/em&gt; &lt;em&gt;I'm not gonna attach any preview image of pie chart. Try it yourself, show us the pies and Best of luck!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>recharts</category>
      <category>react</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Wanna Create your Own Version of Messenger? - Learn Setting up Socket.io</title>
      <dc:creator>Hassan Zahar Rifat</dc:creator>
      <pubDate>Fri, 25 Feb 2022 14:04:30 +0000</pubDate>
      <link>https://forem.com/hzahar/wanna-create-your-own-version-of-messenger-learn-setting-up-socketio-3lkj</link>
      <guid>https://forem.com/hzahar/wanna-create-your-own-version-of-messenger-learn-setting-up-socketio-3lkj</guid>
      <description>&lt;p&gt;&lt;strong&gt;Pre-requisite:&lt;/strong&gt; Basic React.js, Basic Express.js, CLI&lt;/p&gt;

&lt;p&gt;Hello amazing developers! Feeling bored? How about starting to make something like Messenger, Whatsapp or text version of Zoom? You know something very basic about React, Express and you're good to go.&lt;/p&gt;

&lt;p&gt;Today, we'll start learning Socket.io to serve our goal and at the end of this writing, we'll be able to setup Socket.io perfectly. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Socket.io?&lt;/strong&gt;&lt;br&gt;
-&amp;gt; According to the official documentation, Socket.io is a library that enables real-time, bidirectional, event-based communication between browser (client side) and server.&lt;/p&gt;

&lt;p&gt;It uses WebSocket connection (computer communications protocol providing full duplex channel over a TCP connection) whenever possible and if not, it takes HTTP long polling technology (Half duplex connection). WebSocket [a whole another chapter] connection is pretty fast as users can spontaneously send and receive data through this connection.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;One important note:&lt;/em&gt; Socket.io is easier to use and gives more features than that of WebSocket and also it definitely uses WebSocket for data transportation, but it cannot send data from its client side to WebSocket server and vice-versa. Okay, enough of theoretical jargons. Let's make real good stuff now! &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installation:&lt;/strong&gt; We have to install socket.io, express, cors, nodemon (to run the server continuously) in node server. Also we need to initialize the server to configure the package.json file and create an index.js file in where we will write the code. Then We'll install react and socket.io-client for client side. Finally, we'll run both the server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Server side:&lt;/strong&gt; In package.json, inside "scripts": {...}, add&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"start": "node index",
"start-dev": "nodemon index"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm init -y
echo null &amp;gt; index.js [using CMD]
npm install -g nodemon
npm install socket.io express cors
npm run start-dev
&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;npx create-react-app name-of-the-app
cd name-of-the-app
npm install socket.io-client
npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now what? - Now, first set up the server with some complementary works. we'll import express, cors (!important), the socket.io package. built in http node module (this will be used to create an http server). After that, we'll have to specify the port number with proccess.env.PORT || 5000. (proccess.env.PORT will be used after deployment by the hosting sites).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const express = require('express');
const cors = require('cors');
const socketio = require('socket.io');
const http = require('http');
const port = proccess.env.PORT || 5000;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, we'll initialize express and use cors (Cross-Origin Rrsource Sharing &amp;gt;&amp;gt; helps to prevent blocking requests due to different origin. For example, request from localhost:3000 to localhost:5000 will be blocked if we don't use cors ).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const app = express();
app.use(cors());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, we'll create an http server on top of express and connect it with socket.io.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const server = http.createServer(app);
const io = socketio(server, {options});
// , {options} won't be written for now;
// will be used in future to handle cors policy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, inside the io.on() method 'connection' event will be declared with an instant of socket.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;io.on('connection', (socket) =&amp;gt; {
    // console.log('New connection!');
    // codes...
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All the codes related to socket.io will written inside this method. Now, moving on to the client side. To set all up, we'll import socket.io-client and pass the endpoint containing server side url inside the useEffect without any dependency so that it remain connected.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import io from 'socket.io-client';
...
...
// Inside Component
let socket;
useEffect(() =&amp;gt; {
    socket = io('http://localhost:5000/')
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, thus installation, client-server side initialization and basic setup can easily be handled.&lt;/p&gt;

&lt;p&gt;If you like this blog, we'll definitely be going deeper towards Socket.io in my upcoming blogs. Happy developing :3 &lt;/p&gt;

</description>
      <category>socketio</category>
      <category>express</category>
      <category>react</category>
      <category>beginners</category>
    </item>
    <item>
      <title>You Must Know the Answers to the 7 Most Basic Questions about React</title>
      <dc:creator>Hassan Zahar Rifat</dc:creator>
      <pubDate>Wed, 12 Jan 2022 17:45:12 +0000</pubDate>
      <link>https://forem.com/hzahar/you-must-know-the-answers-to-the-7-most-basic-questions-about-react-24j2</link>
      <guid>https://forem.com/hzahar/you-must-know-the-answers-to-the-7-most-basic-questions-about-react-24j2</guid>
      <description>&lt;p&gt;&lt;strong&gt;1. What is reactjs? Tell us about advantages and disadvantages of using react js.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;-&amp;gt; React.js is a JavaScript library that is used to build scalable Frontend UI.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Advantages:&lt;/em&gt;&lt;br&gt;
Easy to learn.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Gives syntactic sugar by which HTML code can be written inside JavaScript.&lt;br&gt;
By writing one component once, it can be used whenever it needs to be used.&lt;br&gt;
Huge community support&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;Disadvantages:&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Core React.js frameworks is not SEO friendly&lt;br&gt;
Huge dependency on many third party libraries.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;2. What is JSX? How does it work?&lt;/strong&gt;&lt;br&gt;
-&amp;gt; JSX refers to JavaScript XML. It gives syntactic sugar and ease to React.js. By using JSX, we can write HTML code inside JavaScript without the burden of using createElement(), appendChild() or template literals.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. What is Virtual dom? What are the differences between virtual and real dom?&lt;/strong&gt;&lt;br&gt;
Or what is the diff algorithm? How does it work?&lt;br&gt;
-&amp;gt; Virtual DOM is a virtual copy of real DOM. It is kept in memory and is synced with real DOM by ReactDOM. DOM manipulation is a less speedy and less efficient process and this is why without rendering the whole document for a little change changing the particular portion is efficient. Virtual DOM does this very well. Whenever change happens, virtual DOM captures the change using diff algorithm and then it updates just that important part that needs to be updated.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Differences between props and state?&lt;/strong&gt;&lt;br&gt;
-&amp;gt; Props are immutable and can be passed as child components but states are mutable, owned by the component and mutable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. What is the purpose of useState? When and why will you use it?&lt;/strong&gt;&lt;br&gt;
-&amp;gt; The useState hook is used for initializing, storing and managing the states of any variable. -&amp;gt; const [state, setState] = useState();&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. What is prop drilling?&lt;/strong&gt;&lt;br&gt;
-&amp;gt; Sometimes it becomes necessary to pass a value to a child component and from that child component to it’s child component as props. This process of nested passing is called prop drilling.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. why do we need to inject dependency for useEffect?&lt;/strong&gt;&lt;br&gt;
-&amp;gt; Using useEffect, it’s necessary to inject dependencies as whenever the state of the dependencies change, the code inside the useEffect executes.&lt;/p&gt;

</description>
      <category>react</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
