<?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>DEV Community: Ricardo Esteves</title>
    <description>The latest articles on DEV Community by Ricardo Esteves (@ricardogesteves).</description>
    <link>https://dev.to/ricardogesteves</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%2F348972%2Faf06d408-8ae8-4bd3-b18d-aefd989199d6.jpg</url>
      <title>DEV Community: Ricardo Esteves</title>
      <link>https://dev.to/ricardogesteves</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ricardogesteves"/>
    <language>en</language>
    <item>
      <title>Zustand, When, how and why</title>
      <dc:creator>Ricardo Esteves</dc:creator>
      <pubDate>Tue, 03 Sep 2024 12:03:10 +0000</pubDate>
      <link>https://dev.to/ricardogesteves/zustand-when-how-and-why-1kpi</link>
      <guid>https://dev.to/ricardogesteves/zustand-when-how-and-why-1kpi</guid>
      <description>&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Introduction to State Management&lt;/li&gt;
&lt;li&gt;Understanding Zustand&lt;/li&gt;
&lt;li&gt;Types of State&lt;/li&gt;
&lt;li&gt;Getting Started with Zustand&lt;/li&gt;
&lt;li&gt;Key Features of Zustand&lt;/li&gt;
&lt;li&gt;Implementing Zustand&lt;/li&gt;
&lt;li&gt;Zustand vs. Other State Management Solutions&lt;/li&gt;
&lt;li&gt;System Design of Zustand&lt;/li&gt;
&lt;li&gt;Persisting State with Zustand&lt;/li&gt;
&lt;li&gt;Using Zustand Outside React Components&lt;/li&gt;
&lt;li&gt;Real-World Examples&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;li&gt;Tips: Handling Asynchronous Code with Zustand&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  1. Introduction to State Management
&lt;/h2&gt;

&lt;p&gt;State management is a crucial aspect of modern web development, especially in complex applications. It involves handling the data that can change over time and ensuring that this data is consistently represented across the entire application. Effective state management leads to more predictable and maintainable applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Understanding Zustand
&lt;/h2&gt;

&lt;p&gt;Zustand is a small, fast, and scalable state management solution for React applications. Created by Jared Palmer and Daishi Kato, Zustand offers a simple and intuitive API that makes state management less cumbersome compared to other solutions.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Types of State
&lt;/h2&gt;

&lt;p&gt;Before diving deeper into Zustand, let's understand the different types of state in web applications:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Local State&lt;/strong&gt;: State that is specific to a component and doesn't need to be shared with other parts of the application.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Global State&lt;/strong&gt;: State that needs to be accessed and modified by multiple components across the application.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Remote State&lt;/strong&gt;: State that represents data fetched from an external source, typically an API.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Zustand excels in managing both local and global state, and can be integrated with solutions for remote state management.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Getting Started with Zustand
&lt;/h2&gt;

&lt;p&gt;To start using Zustand, first install it via npm, yarn or pnpm:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;zustand
&lt;span class="c"&gt;# or&lt;/span&gt;
yarn add zustand
&lt;span class="c"&gt;# or&lt;/span&gt;
pnpm add zustand
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  5. Key Features of Zustand
&lt;/h2&gt;

&lt;p&gt;Zustand comes with several features that make it stand out:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Simplicity&lt;/strong&gt;: Zustand has a minimal API, making it easy to learn and use.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No boilerplate&lt;/strong&gt;: Unlike some other state management solutions, Zustand requires very little setup code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hooks-based&lt;/strong&gt;: Zustand leverages React Hooks, making it feel native to modern React development.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TypeScript support&lt;/strong&gt;: Zustand works great with TypeScript, providing excellent type inference.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Middleware support&lt;/strong&gt;: Zustand allows you to extend its functionality through middleware.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Devtools support&lt;/strong&gt;: Zustand integrates well with Redux DevTools for debugging.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Framework agnostic&lt;/strong&gt;: While primarily used with React, Zustand can be used in any JavaScript environment.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  6. Implementing Zustand
&lt;/h2&gt;

&lt;p&gt;Let's look at a basic implementation of Zustand:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;create&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;zustand&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;useStore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;bears&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;increasePopulation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;bears&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bears&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;})),&lt;/span&gt;
  &lt;span class="na"&gt;removeAllBears&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;bears&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;}),&lt;/span&gt;
&lt;span class="p"&gt;}))&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;BearCounter&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bears&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useStore&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bears&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;bears&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;around&lt;/span&gt; &lt;span class="nx"&gt;here&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Controls&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;increasePopulation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useStore&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;increasePopulation&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;increasePopulation&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;one&lt;/span&gt; &lt;span class="nx"&gt;up&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In this example, we create a store with a &lt;code&gt;bears&lt;/code&gt; state and two actions to modify it. The &lt;code&gt;BearCounter&lt;/code&gt; and &lt;code&gt;Controls&lt;/code&gt; components can then access and modify the state using the &lt;code&gt;useStore&lt;/code&gt; hook.&lt;/p&gt;
&lt;h2&gt;
  
  
  7. Zustand vs. Other State Management Solutions
&lt;/h2&gt;

&lt;p&gt;Let's compare Zustand with other popular state management solutions:&lt;/p&gt;
&lt;h3&gt;
  
  
  Zustand vs. Redux
&lt;/h3&gt;

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

&lt;ul&gt;
&lt;li&gt;Simpler API with less boilerplate&lt;/li&gt;
&lt;li&gt;No need for action creators or switch statements&lt;/li&gt;
&lt;li&gt;Smaller bundle size&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;Less established ecosystem&lt;/li&gt;
&lt;li&gt;Fewer middleware options&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Zustand vs. MobX
&lt;/h3&gt;

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

&lt;ul&gt;
&lt;li&gt;More straightforward, less magical API&lt;/li&gt;
&lt;li&gt;Better performance for larger applications&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;Less reactive by default&lt;/li&gt;
&lt;li&gt;No computed values out of the box&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Zustand vs. Recoil
&lt;/h3&gt;

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

&lt;ul&gt;
&lt;li&gt;Simpler mental model&lt;/li&gt;
&lt;li&gt;Works outside of React&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;Less granular reactivity&lt;/li&gt;
&lt;li&gt;No built-in atom family concept&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  8. System Design of Zustand
&lt;/h2&gt;

&lt;p&gt;Zustand's system design is based on a few key principles:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Single store&lt;/strong&gt;: Zustand encourages the use of a single store for all application state.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Immutability&lt;/strong&gt;: State updates are handled immutably, ensuring predictable behavior.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Subscriptions&lt;/strong&gt;: Components subscribe to specific parts of the state, re-rendering only when those parts change.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Middleware&lt;/strong&gt;: Zustand uses a middleware system for extending functionality.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This design allows Zustand to be both simple and powerful, providing excellent performance even in large applications.&lt;/p&gt;
&lt;h2&gt;
  
  
  9. Persisting State with Zustand
&lt;/h2&gt;

&lt;p&gt;Zustand makes it easy to persist state, which is crucial for many applications. Here's an example using the &lt;code&gt;persist&lt;/code&gt; middleware:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;create&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;zustand&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;persist&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;zustand/middleware&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;useStore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;persist&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;fishes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;addAFish&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;fishes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;fishes&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;}),&lt;/span&gt;
  &lt;span class="p"&gt;}),&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;food-storage&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// unique name&lt;/span&gt;
    &lt;span class="na"&gt;getStorage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;localStorage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// (optional) by default, 'localStorage' is used&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This will automatically save the state to localStorage and rehydrate it when the app reloads.&lt;/p&gt;
&lt;h2&gt;
  
  
  10. Using Zustand Outside React Components
&lt;/h2&gt;

&lt;p&gt;One of Zustand's strengths is that it can be used outside of React components. This is particularly useful for integrating with other parts of your application or for testing:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;getState&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useStore&lt;/span&gt;

&lt;span class="c1"&gt;// Getting state&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;getState&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;bears&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;// Setting state&lt;/span&gt;
&lt;span class="nf"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;bears&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// Using actions&lt;/span&gt;
&lt;span class="nf"&gt;getState&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;increasePopulation&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  11. Real-World Examples
&lt;/h2&gt;

&lt;p&gt;Let's look at some real-world examples of using Zustand:&lt;/p&gt;
&lt;h3&gt;
  
  
  Authentication State
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;create&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;zustand&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;useAuthStore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;isAuthenticated&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;login&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userData&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;userData&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;isAuthenticated&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}),&lt;/span&gt;
  &lt;span class="na"&gt;logout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;isAuthenticated&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;}),&lt;/span&gt;
&lt;span class="p"&gt;}))&lt;/span&gt;

&lt;span class="c1"&gt;// Usage in a component&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;LoginButton&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;isAuthenticated&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;login&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;logout&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useAuthStore&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleAuth&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;isAuthenticated&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;logout&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// Simulate login&lt;/span&gt;
      &lt;span class="nf"&gt;login&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John Doe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleAuth&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;isAuthenticated&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Logout&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Login&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Shopping Cart
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;create&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;zustand&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;useCartStore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt;
  &lt;span class="na"&gt;addItem&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;})),&lt;/span&gt;
  &lt;span class="na"&gt;removeItem&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;itemId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nx"&gt;itemId&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="p"&gt;})),&lt;/span&gt;
  &lt;span class="na"&gt;clearCart&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="p"&gt;}),&lt;/span&gt;
  &lt;span class="na"&gt;total&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;updateTotal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;total&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;price&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="p"&gt;})),&lt;/span&gt;
&lt;span class="p"&gt;}))&lt;/span&gt;

&lt;span class="c1"&gt;// Usage in components&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;CartSummary&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;removeItem&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useCartStore&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;price&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;removeItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Remove&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="p"&gt;))}&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Total&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;total&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Theme Switcher
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;create&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;zustand&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;persist&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;zustand/middleware&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;useThemeStore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;persist&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;light&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;toggleTheme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;theme&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;light&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dark&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;light&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;})),&lt;/span&gt;
  &lt;span class="p"&gt;}),&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;theme-storage&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="c1"&gt;// Usage in a component&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;ThemeToggle&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;toggleTheme&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useThemeStore&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;toggleTheme&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nx"&gt;Switch&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;theme&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;light&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dark&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;light&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;mode&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  12. Conclusion
&lt;/h2&gt;

&lt;p&gt;Zustand offers a refreshing approach to state management in React applications. Its simplicity, flexibility, and performance make it an excellent choice for both small and large projects. By reducing boilerplate and providing a straightforward API, Zustand allows developers to focus on building features rather than managing complex state logic.&lt;/p&gt;

&lt;p&gt;While it may not have the extensive ecosystem of some older state management solutions, Zustand's design principles and ease of use make it a compelling option for modern React development. Its ability to work outside of React components and easy integration with persistence solutions further extend its utility.&lt;/p&gt;

&lt;p&gt;For many React applications, Zustand strikes an excellent balance between simplicity and power, making it worth considering for your next project.&lt;/p&gt;
&lt;h3&gt;
  
  
  Bonus tips:
&lt;/h3&gt;

&lt;p&gt;Zustand also handles asynchronous functions/code really well and without the need for any Middleware setup.&lt;/p&gt;

&lt;p&gt;Let's talk a bit about that:&lt;/p&gt;
&lt;h2&gt;
  
  
  13. Handling Asynchronous Code with Zustand
&lt;/h2&gt;

&lt;p&gt;One of Zustand's strengths is its simplicity in handling asynchronous operations without the need for additional middleware or complex setups. This makes it particularly easy to work with API calls, data fetching, and other asynchronous tasks.&lt;/p&gt;
&lt;h3&gt;
  
  
  How Zustand Handles Asynchronous Code
&lt;/h3&gt;

&lt;p&gt;Zustand's approach to asynchronous code is straightforward:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Direct Integration&lt;/strong&gt;: Asynchronous functions can be defined directly in the store.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No Special Syntax&lt;/strong&gt;: You don't need to use special action creators or thunks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;State Updates&lt;/strong&gt;: You can update the state within async functions using the &lt;code&gt;set&lt;/code&gt; function.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Error Handling&lt;/strong&gt;: Error states can be managed directly within the async functions.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Implementing Asynchronous Code
&lt;/h3&gt;

&lt;p&gt;Here's an example of how to implement asynchronous code in Zustand:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;create&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;zustand&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;useUserStore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;isLoading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;fetchUser&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;isLoading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`https://api.example.com/users/&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Failed to fetch user&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;userData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
      &lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;userData&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;isLoading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;isLoading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;}));&lt;/span&gt;

&lt;span class="c1"&gt;// Usage in a component&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;UserProfile&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;userId&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;isLoading&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fetchUser&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useUserStore&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;fetchUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;isLoading&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Loading&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In this example:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We define an async &lt;code&gt;fetchUser&lt;/code&gt; function directly in the store.&lt;/li&gt;
&lt;li&gt;The function manages loading and error states alongside the user data.&lt;/li&gt;
&lt;li&gt;We use the &lt;code&gt;set&lt;/code&gt; function to update the state at different points in the async operation.&lt;/li&gt;
&lt;li&gt;In the component, we can use the store's state and actions as usual, with React hooks handling the component lifecycle.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Benefits of Zustand's Approach to Async Code
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Simplicity&lt;/strong&gt;: No need for additional middleware or complex action creators.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Flexibility&lt;/strong&gt;: You can structure your async logic however you prefer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Readability&lt;/strong&gt;: Async operations are defined close to the relevant state.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Easy Testing&lt;/strong&gt;: Async functions can be easily unit tested.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Comparison with Other Solutions
&lt;/h3&gt;

&lt;p&gt;Unlike Redux, which often requires middleware like Redux Thunk or Redux Saga for handling async operations, Zustand's approach is much more straightforward. This simplicity can lead to less boilerplate and a gentler learning curve, especially for developers new to state management.&lt;/p&gt;

&lt;p&gt;MobX and Recoil also offer ways to handle async operations, but Zustand's approach might be considered more intuitive due to its direct use of async/await syntax without additional abstractions.&lt;/p&gt;
&lt;h2&gt;
  
  
  In conclusion for async
&lt;/h2&gt;

&lt;p&gt;Zustand's handling of asynchronous code exemplifies its philosophy of simplicity and flexibility. By allowing developers to write async functions directly in the store without special syntax or middleware, Zustand makes it easy to manage complex state operations while keeping the codebase clean and readable.&lt;/p&gt;

&lt;p&gt;This approach to async code, combined with Zustand's other features like its small bundle size and easy setup, makes it an excellent choice for projects of all sizes, particularly those that involve significant asynchronous state management.&lt;/p&gt;

&lt;p&gt;Hope this "kinda guide" was useful and insightful for any of you that's thinking on how to manage your global application state.&lt;br&gt;
Thank you and Happy coding.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Have a look on my website at &lt;a href="https://www.ricardogesteves.com/" rel="noopener noreferrer"&gt;https://www.ricardogesteves.com&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Follow me &lt;strong&gt;&lt;a class="mentioned-user" href="https://dev.to/ricardogesteves"&gt;@ricardogesteves&lt;/a&gt;&lt;/strong&gt; &lt;br&gt;
&lt;a href="https://twitter.com/ricardogesteves" rel="noopener noreferrer"&gt;X(twitter)&lt;/a&gt;&lt;/p&gt;


&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
      &lt;div class="c-embed__cover"&gt;
        &lt;a href="https://github.com/RicardoGEsteves" class="c-link s:max-w-50 align-middle" rel="noopener noreferrer"&gt;
          &lt;img alt="" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Favatars.githubusercontent.com%2Fu%2F30535937%3Fv%3D4%3Fs%3D400" height="auto" class="m-0"&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;div class="c-embed__body"&gt;
      &lt;h2 class="fs-xl lh-tight"&gt;
        &lt;a href="https://github.com/RicardoGEsteves" rel="noopener noreferrer" class="c-link"&gt;
          RicardoGEsteves (Ricardo Esteves) · GitHub
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;p class="truncate-at-3"&gt;
          Full-Stack Developer | Passionate about creating intuitive and impactful user experiences | Based in Lisbon, Portugal 🇵🇹 - RicardoGEsteves
        &lt;/p&gt;
      &lt;div class="color-secondary fs-s flex items-center"&gt;
          &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.githubassets.com%2Ffavicons%2Ffavicon.svg"&gt;
        github.com
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;



</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>typescript</category>
      <category>react</category>
    </item>
    <item>
      <title>Prepare Yourself for a Systems Design Interview</title>
      <dc:creator>Ricardo Esteves</dc:creator>
      <pubDate>Tue, 27 Aug 2024 12:49:57 +0000</pubDate>
      <link>https://dev.to/ricardogesteves/prepare-yourself-for-a-systems-design-interview-4m8a</link>
      <guid>https://dev.to/ricardogesteves/prepare-yourself-for-a-systems-design-interview-4m8a</guid>
      <description>&lt;p&gt;Hi &lt;code&gt;DEV's&lt;/code&gt;,&lt;br&gt;
Let's dive in the topic of &lt;code&gt;Systems Design/ Architecture&lt;/code&gt;, what to expect  and how to prepare yourself for an interview. &lt;/p&gt;
&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Systems design interviews are a crucial part of the hiring process for senior software engineering roles, especially at large tech companies. These interviews assess your ability to design scalable, reliable, and efficient systems. &lt;br&gt;
Now a days most of the companies(to not say all) required you to have this knowledge and is one of the most important fases on your hiring process. &lt;/p&gt;
&lt;h2&gt;
  
  
  Understanding the Purpose
&lt;/h2&gt;

&lt;p&gt;Before diving into preparation, it's important to understand what interviewers are looking for:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Problem-solving skills&lt;/li&gt;
&lt;li&gt;Knowledge of distributed systems&lt;/li&gt;
&lt;li&gt;Ability to make trade-offs&lt;/li&gt;
&lt;li&gt;Communication skills&lt;/li&gt;
&lt;li&gt;Experience with real-world systems&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Preparation Strategy
&lt;/h2&gt;
&lt;h3&gt;
  
  
  1. Study Fundamental Concepts
&lt;/h3&gt;

&lt;p&gt;Focus on these key areas:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Scalability&lt;/li&gt;
&lt;li&gt;Load balancing&lt;/li&gt;
&lt;li&gt;Caching&lt;/li&gt;
&lt;li&gt;Database sharding and replication&lt;/li&gt;
&lt;li&gt;Microservices architecture&lt;/li&gt;
&lt;li&gt;API design&lt;/li&gt;
&lt;li&gt;Consistency models&lt;/li&gt;
&lt;li&gt;Messaging systems&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  Example: Scalability
&lt;/h4&gt;

&lt;p&gt;Understand vertical scaling (adding more power to existing machines) vs. horizontal scaling (adding more machines). For instance, if you're designing a social media platform, horizontal scaling might be preferred for the ability to handle millions of concurrent users.&lt;/p&gt;
&lt;h3&gt;
  
  
  2. Learn System Components
&lt;/h3&gt;

&lt;p&gt;Familiarize yourself with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Load Balancers (e.g., Nginx, HAProxy)&lt;/li&gt;
&lt;li&gt;Caching systems (e.g., Redis, Memcached)&lt;/li&gt;
&lt;li&gt;Databases (SQL vs. NoSQL, specific products like PostgreSQL, MongoDB)&lt;/li&gt;
&lt;li&gt;Message queues (e.g., RabbitMQ, Apache Kafka)&lt;/li&gt;
&lt;li&gt;Content Delivery Networks (CDNs)&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  Example: Caching
&lt;/h4&gt;

&lt;p&gt;Understand different caching strategies:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cache-aside&lt;/li&gt;
&lt;li&gt;Write-through&lt;/li&gt;
&lt;li&gt;Write-back&lt;/li&gt;
&lt;li&gt;Read-through&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a news website, you might use a cache-aside strategy for article content, updating the cache when the article is modified in the database.&lt;/p&gt;
&lt;h3&gt;
  
  
  3. Study Existing System Designs
&lt;/h3&gt;

&lt;p&gt;Analyze designs of popular systems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Twitter's timeline&lt;/li&gt;
&lt;li&gt;Facebook's news feed&lt;/li&gt;
&lt;li&gt;Google's search engine&lt;/li&gt;
&lt;li&gt;Netflix's video streaming service&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  4. Practice Estimations
&lt;/h3&gt;

&lt;p&gt;Learn to estimate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Traffic (requests per second)&lt;/li&gt;
&lt;li&gt;Storage requirements&lt;/li&gt;
&lt;li&gt;Bandwidth usage&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  Example: Storage Estimation
&lt;/h4&gt;

&lt;p&gt;For a photo-sharing app:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Assume 1 million daily active users&lt;/li&gt;
&lt;li&gt;Each user uploads 2 photos per day&lt;/li&gt;
&lt;li&gt;Average photo size is 5 MB&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Daily storage requirement:&lt;br&gt;
1,000,000 * 2 * 5 MB = 10 TB per day&lt;/p&gt;
&lt;h3&gt;
  
  
  5. Understand Non-Functional Requirements
&lt;/h3&gt;

&lt;p&gt;Be familiar with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reliability&lt;/li&gt;
&lt;li&gt;Availability&lt;/li&gt;
&lt;li&gt;Scalability&lt;/li&gt;
&lt;li&gt;Performance&lt;/li&gt;
&lt;li&gt;Security&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  What to Expect in the Interview
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Problem statement&lt;/li&gt;
&lt;li&gt;Requirements clarification&lt;/li&gt;
&lt;li&gt;High-level design&lt;/li&gt;
&lt;li&gt;Detailed component design&lt;/li&gt;
&lt;li&gt;Bottleneck identification and mitigation&lt;/li&gt;
&lt;li&gt;Follow-up questions and trade-offs&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Key Questions and Answers
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Q1: Design a URL shortener (like bit.ly)
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Functional Requirements:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Shorten long URLs&lt;/li&gt;
&lt;li&gt;Redirect users to original URL&lt;/li&gt;
&lt;li&gt;Custom short URLs (optional)&lt;/li&gt;
&lt;li&gt;Analytics (optional)&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  Non-Functional Requirements:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;High availability&lt;/li&gt;
&lt;li&gt;Low latency for redirections&lt;/li&gt;
&lt;li&gt;Scalable to handle high traffic&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  High-Level Design:
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Client] &amp;lt;-&amp;gt; [Load Balancer] &amp;lt;-&amp;gt; [Application Servers]
                                        |
                            [Database (URL mappings)]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h4&gt;
  
  
  Key Considerations:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;URL encoding: Use base62 encoding (a-z, A-Z, 0-9) for short URLs&lt;/li&gt;
&lt;li&gt;Database choice: NoSQL (e.g., Cassandra) for better scalability&lt;/li&gt;
&lt;li&gt;Caching: Use Redis to cache frequent URL mappings&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Q2: Design a distributed cache
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Functional Requirements:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Get/Set operations&lt;/li&gt;
&lt;li&gt;TTL (Time to Live) for entries&lt;/li&gt;
&lt;li&gt;Eviction policy&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  Non-Functional Requirements:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Low latency&lt;/li&gt;
&lt;li&gt;High availability&lt;/li&gt;
&lt;li&gt;Scalability&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  High-Level Design:
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Clients] &amp;lt;-&amp;gt; [Cache Servers (Sharded)] &amp;lt;-&amp;gt; [Consistent Hashing Ring]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h4&gt;
  
  
  Key Considerations:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Sharding strategy: Use consistent hashing&lt;/li&gt;
&lt;li&gt;Replication: Implement master-slave replication for fault tolerance&lt;/li&gt;
&lt;li&gt;Eviction policy: LRU (Least Recently Used) or LFU (Least Frequently Used)&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Best Practices
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Clarify requirements thoroughly&lt;/li&gt;
&lt;li&gt;Start with a high-level design&lt;/li&gt;
&lt;li&gt;Dive into details of important components&lt;/li&gt;
&lt;li&gt;Discuss trade-offs explicitly&lt;/li&gt;
&lt;li&gt;Consider scalability from the start&lt;/li&gt;
&lt;li&gt;Address potential bottlenecks&lt;/li&gt;
&lt;li&gt;Mention monitoring and logging&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Key Considerations
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;CAP Theorem: Understand the trade-offs between Consistency, Availability, and Partition Tolerance&lt;/li&gt;
&lt;li&gt;Eventual Consistency: Know when it's acceptable&lt;/li&gt;
&lt;li&gt;Data Partitioning: Understand strategies like range-based, hash-based, and directory-based partitioning&lt;/li&gt;
&lt;li&gt;Load Balancing: Round-robin, least connections, IP hash&lt;/li&gt;
&lt;li&gt;Caching: Cache invalidation strategies, cache eviction policies&lt;/li&gt;
&lt;li&gt;Database Indexing: Understand its impact on read/write performance&lt;/li&gt;
&lt;li&gt;API Design: RESTful principles, versioning strategies&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Technical Deep Dive: Designing a Social Media Platform
&lt;/h2&gt;

&lt;p&gt;Let's design a simplified version of a social media platform focusing on the news feed feature.&lt;/p&gt;
&lt;h3&gt;
  
  
  Functional Requirements:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Users can post status updates&lt;/li&gt;
&lt;li&gt;Users can follow other users&lt;/li&gt;
&lt;li&gt;Users can view a personalized news feed&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Non-Functional Requirements:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;High availability (99.99% uptime)&lt;/li&gt;
&lt;li&gt;Low latency for feed generation (&amp;lt;100ms)&lt;/li&gt;
&lt;li&gt;Scalable to millions of users&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  High-Level Design:
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Clients] &amp;lt;-&amp;gt; [Load Balancer]
                    |
    +---------------+---------------+
    |               |               |
[Web Servers] [App Servers]  [Feed Generation Service]
    |               |               |
    +-------+-------+-------+-------+
            |               |
    [User Service DB]  [Post Service DB]
    (Sharded PostgreSQL) (Sharded PostgreSQL)
            |               |
    [Follow Graph Cache] [Post Cache]
    (Redis Cluster)     (Redis Cluster)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Detailed Component Design:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;User Service:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Handles user registration, authentication&lt;/li&gt;
&lt;li&gt;Database: Sharded PostgreSQL&lt;/li&gt;
&lt;li&gt;Sharding key: user_id&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Post Service:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Handles creating and retrieving posts&lt;/li&gt;
&lt;li&gt;Database: Sharded PostgreSQL&lt;/li&gt;
&lt;li&gt;Sharding key: post_id&lt;/li&gt;
&lt;li&gt;Use a distributed ID generator (e.g., Twitter's Snowflake) for post_id&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Follow Graph Service:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Manages user follow relationships&lt;/li&gt;
&lt;li&gt;Store in Redis for fast lookups&lt;/li&gt;
&lt;li&gt;Format: SET for each user's followers&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Feed Generation Service:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Generates personalized news feeds&lt;/li&gt;
&lt;li&gt;Uses a pull-based model for inactive users and push-based for active users&lt;/li&gt;
&lt;li&gt;Algorithm:

&lt;ol&gt;
&lt;li&gt;Get user's followees&lt;/li&gt;
&lt;li&gt;Fetch recent posts from these followees&lt;/li&gt;
&lt;li&gt;Sort posts by time&lt;/li&gt;
&lt;li&gt;Apply content ranking algorithm (optional)&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Caching Layer:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use Redis clusters for caching&lt;/li&gt;
&lt;li&gt;Cache user data, post data, and pre-generated feeds&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Scalability Considerations:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Database Sharding:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Shard user and post data across multiple PostgreSQL instances&lt;/li&gt;
&lt;li&gt;Use consistent hashing for shard allocation&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Caching:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Implement multi-level caching (application server cache, distributed cache)&lt;/li&gt;
&lt;li&gt;Use write-through caching for user and post data&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Feed Generation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pre-generate feeds for active users and store in cache&lt;/li&gt;
&lt;li&gt;Use a message queue (e.g., Apache Kafka) to handle feed updates asynchronously&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;CDN:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use a CDN to serve static content (images, videos)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Performance Optimizations:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;News Feed:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Implement cursor-based pagination for feed retrieval&lt;/li&gt;
&lt;li&gt;Use a separate service for feed ranking and personalization&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Database:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use database connection pooling&lt;/li&gt;
&lt;li&gt;Implement read replicas for read-heavy operations&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Caching:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Implement cache warming for predicted high-traffic events&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Monitoring and Logging:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Use distributed tracing (e.g., Jaeger) for request flow tracking&lt;/li&gt;
&lt;li&gt;Implement centralized logging (e.g., ELK stack)&lt;/li&gt;
&lt;li&gt;Set up alerts for system metrics (CPU, memory, disk I/O)&lt;/li&gt;
&lt;li&gt;Monitor application-specific metrics (e.g., feed generation time, cache hit ratio)&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Now let's see some examples:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;High-Level Architecture with Communication Flow
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                  +----------------+
                  |   Client Apps  |
                  | (Web, Mobile)  |
                  +--------+-------+
                           |
                           | HTTPS
                           v
             +-------------+--------------+
             |        API Gateway         |
             |     (Kong, AWS API GW)     |
             +-------------+--------------+
                           |
         +--------+--------+--------+--------+
         |        |        |        |        |
         v        v        v        v        v
 +-------+--+ +---+----+ +-+-----+ ++------+ +-----+--+
 |  Auth   | | User   | | Post  | | Feed  | | Search |
 | Service | | Service| |Service| |Service| | Service|
 +----+----+ +---+----+ +-+-----+ ++------+ +-----+--+
      |          |        |        |              |
      |          |        |        |              |
 +----v----------v--------v--------v--------------v----+
 |                  Message Queue                      |
 |              (Kafka, RabbitMQ)                      |
 +----+----------+--------+--------+--------+----------+
      |          |        |        |        |
      v          v        v        v        v
 +----+----+ +---+----+ +-+-----+ ++------+ +--------+
 | User DB | |Post DB | |Feed DB| |Search | |Analytics|
 | (Shard) | |(Shard) | |       | |Engine | | Service |
 +---------+ +--------+ +-------+ +-------+ +--------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Arrows indicate the direction of communication. Most interactions are bidirectional, but some (like event publishing to the message queue) are unidirectional.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Detailed User Service Flow
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   +----------------+
   |  API Gateway   |
   +--------+-------+
            |
    +-------v-------+
    |  User Service |
    +-------+-------+
            |
     +------v------+    +----------------+
     | User Cache  |&amp;lt;--&amp;gt;|   User DB      |
     | (Redis)     |    | (PostgreSQL)   |
     +------+------+    +----------------+
            |
     +------v------+
     |Message Queue|
     |(Kafka Topic)|
     +-------------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;API Gateway to User Service: Bidirectional (HTTP/gRPC)&lt;/li&gt;
&lt;li&gt;User Service to Cache: Bidirectional (Read/Write)&lt;/li&gt;
&lt;li&gt;User Service to DB: Bidirectional (CRUD operations)&lt;/li&gt;
&lt;li&gt;User Service to Message Queue: Unidirectional (Publish events)&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Post Creation and Feed Update Flow
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   +----------------+
   |  API Gateway   |
   +--------+-------+
            |
    +-------v-------+
    |  Post Service |
    +-------+-------+
            |
     +------v------+    +----------------+
     | Post Cache  |&amp;lt;--&amp;gt;|   Post DB      |
     | (Redis)     |    | (PostgreSQL)   |
     +------+------+    +----------------+
            |
     +------v------+
     |Message Queue|
     |(Kafka Topic)|
     +------+------+
            |
    +-------v-------+
    | Feed Service  |
    +-------+-------+
            |
     +------v------+
     | Feed Cache  |
     | (Redis)     |
     +-------------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Post Service to Message Queue: Unidirectional (Publish new post event)&lt;/li&gt;
&lt;li&gt;Message Queue to Feed Service: Unidirectional (Consume new post event)&lt;/li&gt;
&lt;li&gt;Feed Service to Feed Cache: Bidirectional (Update feeds)&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Search Service Interaction
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   +----------------+
   |  API Gateway   |
   +--------+-------+
            |
    +-------v-------+
    |Search Service |
    +-------+-------+
            |
     +------v------+
     |Search Engine|
     |  (Elastic-  |
     |   search)   |
     +------+------+
            |
     +------v------+
     |Message Queue|
     |(Kafka Topic)|
     +-------------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Search Service to Search Engine: Bidirectional (Index and search operations)&lt;/li&gt;
&lt;li&gt;Search Service to Message Queue: Bidirectional (Consume index updates, publish search events)&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Authentication Flow
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   +----------------+
   |  API Gateway   |
   +--------+-------+
            |
    +-------v-------+
    | Auth Service  |
    +-------+-------+
            |
     +------v------+    +----------------+
     | Token Cache |&amp;lt;--&amp;gt;|   User DB      |
     | (Redis)     |    | (PostgreSQL)   |
     +-------------+    +----------------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;API Gateway to Auth Service: Bidirectional (Authenticate requests)&lt;/li&gt;
&lt;li&gt;Auth Service to Token Cache: Bidirectional (Store/retrieve tokens)&lt;/li&gt;
&lt;li&gt;Auth Service to User DB: Bidirectional (Verify credentials)&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Analytics Data Flow
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   +----------------+
   |  API Gateway   |
   +--------+-------+
            |
     +------v------+
     |Message Queue|
     |(Kafka Topic)|
     +------+------+
            |
    +-------v-------+
    |Analytics Svc  |
    +-------+-------+
            |
     +------v------+
     |  Time-series|
     |     DB      |
     | (InfluxDB)  |
     +-------------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;All Services to Message Queue: Unidirectional (Publish events)&lt;/li&gt;
&lt;li&gt;Message Queue to Analytics Service: Unidirectional (Consume events)&lt;/li&gt;
&lt;li&gt;Analytics Service to Time-series DB: Bidirectional (Store and query analytics data)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These diagrams illustrate the complex interactions between different components in a microservices architecture. Key points to note:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The API Gateway acts as the single entry point for all client requests, providing a unified interface to the microservices.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Most service-to-service communication is done asynchronously through the message queue, promoting loose coupling.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Each service has its own database, following the database-per-service pattern.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Caching is used extensively to reduce database load and improve response times.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The search service uses a specialized search engine (Elasticsearch) for efficient text search operations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The analytics service consumes events from all other services to provide system-wide insights.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Authentication is centralized in the Auth Service, which other services rely on for user verification.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Remember&lt;/strong&gt; that in a &lt;strong&gt;real-world scenario&lt;/strong&gt;, you might need to add more components like &lt;code&gt;circuit breakers&lt;/code&gt;, &lt;code&gt;service discovery&lt;/code&gt;, and a &lt;code&gt;configuration server&lt;/code&gt; to enhance reliability and manageability.&lt;/p&gt;
&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Designing and implementing a microservices-based architecture for large-scale web applications is a complex but rewarding. It requires a deep understanding of distributed systems, careful consideration of various components, and a strategic approach to system design.&lt;/p&gt;

&lt;p&gt;Key takeaways from our discussion include:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Importance of Preparation&lt;/strong&gt;: Success in system design interviews and real-world implementations hinges on thorough preparation. This includes studying fundamental concepts, understanding system components, and practicing with real-world scenarios.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Holistic Approach&lt;/strong&gt;: Effective system design goes beyond just functional requirements. It necessitates careful consideration of non-functional requirements such as scalability, reliability, and performance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Component Interaction&lt;/strong&gt;: The diagrams and flows we've examined highlight the intricate interactions between various components in a microservices architecture. Understanding these interactions is crucial for designing robust, scalable systems.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Communication Patterns&lt;/strong&gt;: Both unidirectional and bidirectional communication patterns play vital roles in microservices architectures. Asynchronous communication through message queues promotes loose coupling, while synchronous communication is sometimes necessary for immediate consistency.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Data Management&lt;/strong&gt;: Proper data management, including strategic use of caching, database sharding, and specialized data stores (like search engines and time-series databases), is fundamental to system performance and scalability.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Scalability and Performance&lt;/strong&gt;: These are not afterthoughts but core considerations that should inform every aspect of the design, from the high-level architecture to the choice of specific technologies.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Continuous Evolution&lt;/strong&gt;: System design is not a one-time activity. As requirements change and systems grow, architects must be prepared to evolve their designs, always considering trade-offs and potential impacts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Best Practices&lt;/strong&gt;: Adhering to best practices such as the use of API gateways, implementation of proper authentication and authorization, and employing monitoring and logging, ensures the creation of robust and maintainable systems.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In conclusion, mastering system design for microservices-based web applications is a journey that requires continuous learning and adaptation. It demands a balance between theoretical knowledge and practical experience. As technology evolves and new challenges emerge, the principles of good system design - scalability, reliability, and maintainability - remain constant guideposts.&lt;/p&gt;

&lt;p&gt;Whether preparing for a system design interview or architecting real-world systems, the key is to approach each problem methodically, communicate clearly, and always be ready to dive into the details while maintaining a view of the bigger picture. By doing so, you'll be well-equipped to design systems that can stand up to the demands of modern web applications and provide value to users and businesses alike.&lt;/p&gt;
&lt;h3&gt;
  
  
  Important tip:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;If you don't know in-depth some topic, scope the question or the use case to a high-level solution. Don't be afraid to express your lack of knowledge, that you're not sure or it's not your domain, and let the interviewer help you getting there.
&lt;/li&gt;
&lt;li&gt;have in mind that this interview it's kinda bidirectional between you and the interviewer. Keep an open dialogue and check regularly if you're being clear and if the interviewer is understanding your point of view.&lt;/li&gt;
&lt;li&gt;There is no right or wrong(most of the time), it's more like how is your approach for each requirement and how effective and efficient it is.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hope this was insightful, helpful and you got an overview of what you have to learn, where and how. Also what you should prioritize and focus.&lt;br&gt;
It's also a good idea to practice on a whiteboard kind of software like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Whiteboard (by HackerRank)&lt;/li&gt;
&lt;li&gt;CoderPad&lt;/li&gt;
&lt;li&gt;Repl.it&lt;/li&gt;
&lt;li&gt;Diagrams.net&lt;/li&gt;
&lt;li&gt;Figma &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Happy coding, and good luck for your interviews.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Have a look on my website at &lt;a href="https://www.ricardogesteves.com/" rel="noopener noreferrer"&gt;https://www.ricardogesteves.com&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Follow me &lt;strong&gt;&lt;a class="mentioned-user" href="https://dev.to/ricardogesteves"&gt;@ricardogesteves&lt;/a&gt;&lt;/strong&gt; &lt;br&gt;
&lt;a href="https://twitter.com/ricardogesteves" rel="noopener noreferrer"&gt;X(twitter)&lt;/a&gt;&lt;/p&gt;


&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
      &lt;div class="c-embed__cover"&gt;
        &lt;a href="https://github.com/RicardoGEsteves" class="c-link s:max-w-50 align-middle" rel="noopener noreferrer"&gt;
          &lt;img alt="" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Favatars.githubusercontent.com%2Fu%2F30535937%3Fv%3D4%3Fs%3D400" height="auto" class="m-0"&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;div class="c-embed__body"&gt;
      &lt;h2 class="fs-xl lh-tight"&gt;
        &lt;a href="https://github.com/RicardoGEsteves" rel="noopener noreferrer" class="c-link"&gt;
          RicardoGEsteves (Ricardo Esteves) · GitHub
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;p class="truncate-at-3"&gt;
          Full-Stack Developer | Passionate about creating intuitive and impactful user experiences | Based in Lisbon, Portugal 🇵🇹 - RicardoGEsteves
        &lt;/p&gt;
      &lt;div class="color-secondary fs-s flex items-center"&gt;
          &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.githubassets.com%2Ffavicons%2Ffavicon.svg"&gt;
        github.com
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;


</description>
      <category>programming</category>
      <category>architecture</category>
      <category>systemdesign</category>
      <category>webdev</category>
    </item>
    <item>
      <title>React with Vite On Steroids</title>
      <dc:creator>Ricardo Esteves</dc:creator>
      <pubDate>Tue, 13 Aug 2024 18:42:18 +0000</pubDate>
      <link>https://dev.to/ricardogesteves/react-with-vite-on-steroids-4nh0</link>
      <guid>https://dev.to/ricardogesteves/react-with-vite-on-steroids-4nh0</guid>
      <description>&lt;p&gt;A Powerful Starter Template for Modern Web Development&lt;/p&gt;

&lt;p&gt;Building React applications made easy with &lt;strong&gt;React with Vite On Steroids&lt;/strong&gt; – A starter template for creating high-performance React applications with ease.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Inside?
&lt;/h2&gt;

&lt;p&gt;This template is packed with features designed to streamline your development process:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://vitejs.dev/" rel="noopener noreferrer"&gt;Vite&lt;/a&gt;&lt;/strong&gt;: The lightning-fast build tool that ensures rapid development and optimized production builds.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://reactjs.org/" rel="noopener noreferrer"&gt;React&lt;/a&gt;&lt;/strong&gt;: The popular JavaScript library for building user interfaces.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://www.typescriptlang.org/" rel="noopener noreferrer"&gt;TypeScript&lt;/a&gt;&lt;/strong&gt;: Add type safety and enhanced tooling to your JavaScript.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://tailwindcss.com/" rel="noopener noreferrer"&gt;Tailwind CSS&lt;/a&gt;&lt;/strong&gt;: A utility-first CSS framework for creating stunning designs without writing custom CSS.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://eslint.org/" rel="noopener noreferrer"&gt;ESLint&lt;/a&gt;&lt;/strong&gt;: Keep your codebase clean and consistent with pluggable linting rules.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://prettier.io/" rel="noopener noreferrer"&gt;Prettier&lt;/a&gt;&lt;/strong&gt;: An opinionated code formatter that enforces consistent styling across your project.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://vitest.dev/" rel="noopener noreferrer"&gt;Vitest&lt;/a&gt;&lt;/strong&gt;: A blazing-fast unit testing framework with a Vite-native approach.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://testing-library.com/" rel="noopener noreferrer"&gt;Testing Library&lt;/a&gt;&lt;/strong&gt;: Simple and complete testing utilities that encourage good testing practices.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://playwright.dev/" rel="noopener noreferrer"&gt;Playwright&lt;/a&gt;&lt;/strong&gt;: A versatile end-to-end testing framework that supports multiple browsers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://typicode.github.io/husky/" rel="noopener noreferrer"&gt;Husky&lt;/a&gt;&lt;/strong&gt;: Automate your Git hooks, such as pre-commit hooks, to ensure quality code before it hits the repository.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;p&gt;Before diving in, make sure you have the following installed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://nodejs.org/" rel="noopener noreferrer"&gt;Node.js&lt;/a&gt; (version 20.x or higher)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://yarnpkg.com/" rel="noopener noreferrer"&gt;Yarn&lt;/a&gt; (or npm or pnpm)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;

&lt;p&gt;Kickstart your project with these simple steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Clone the repository:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   git clone https://github.com/RicardoGEsteves/react-with-vite-on-steroids.git
   &lt;span class="nb"&gt;cd &lt;/span&gt;react-with-vite-on-steroids
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Install dependencies:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   yarn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Running the Development Server
&lt;/h3&gt;

&lt;p&gt;Ready to start coding? Spin up the development server with:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Building for Production
&lt;/h3&gt;

&lt;p&gt;When you're ready to deploy, create a production build with:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Running Tests
&lt;/h3&gt;

&lt;p&gt;This template comes with built-in testing utilities to ensure your code works as expected.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Unit Tests with Vitest:&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  yarn &lt;span class="nb"&gt;test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Check Test Coverage:&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  yarn coverage
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;End-to-End Tests with Playwright:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run all tests:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn playwright &lt;span class="nb"&gt;test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Interactive UI mode:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn playwright &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="nt"&gt;--ui&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Run tests only on Desktop Chrome:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn playwright &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="nt"&gt;--project&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;chromium
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Run tests in a specific file:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn playwright &lt;span class="nb"&gt;test &lt;/span&gt;example
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Debug mode:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn playwright &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="nt"&gt;--debug&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Auto-generate tests with Codegen:&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn playwright codegen
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Linting and Formatting
&lt;/h3&gt;

&lt;p&gt;Maintain code quality and consistency with these commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Lint the code:&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  yarn lint
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Fix linting errors:&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  yarn lint:fix
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Format the code:&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  yarn format
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  License
&lt;/h2&gt;

&lt;p&gt;This project is licensed under the MIT License. For more details, see the &lt;a href="//./LICENSE"&gt;LICENSE&lt;/a&gt; file.&lt;/p&gt;
&lt;h2&gt;
  
  
  Acknowledgements
&lt;/h2&gt;

&lt;p&gt;A huge thanks to the developers and communities behind these amazing tools:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://vitejs.dev/" rel="noopener noreferrer"&gt;Vite&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://reactjs.org/" rel="noopener noreferrer"&gt;React&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.typescriptlang.org/" rel="noopener noreferrer"&gt;TypeScript&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://tailwindcss.com/" rel="noopener noreferrer"&gt;Tailwind CSS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://eslint.org/" rel="noopener noreferrer"&gt;ESLint&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://prettier.io/" rel="noopener noreferrer"&gt;Prettier&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://vitest.dev/" rel="noopener noreferrer"&gt;Vitest&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://testing-library.com/" rel="noopener noreferrer"&gt;Testing Library&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://playwright.dev/" rel="noopener noreferrer"&gt;Playwright&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://typicode.github.io/husky/" rel="noopener noreferrer"&gt;Husky&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Check out the template @&lt;a href="https://github.com/RicardoGEsteves/react-with-vite-on-steroids" rel="noopener noreferrer"&gt;RicardoGEsteves&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have a lot on my website at &lt;a href="https://www.ricardogesteves.com/" rel="noopener noreferrer"&gt;https://www.ricardogesteves.com&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Follow me &lt;strong&gt;&lt;a class="mentioned-user" href="https://dev.to/ricardogesteves"&gt;@ricardogesteves&lt;/a&gt;&lt;/strong&gt; &lt;br&gt;
&lt;a href="https://twitter.com/ricardogesteves" rel="noopener noreferrer"&gt;X(twitter)&lt;/a&gt;&lt;/p&gt;


&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
      &lt;div class="c-embed__cover"&gt;
        &lt;a href="https://github.com/RicardoGEsteves" class="c-link s:max-w-50 align-middle" rel="noopener noreferrer"&gt;
          &lt;img alt="" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Favatars.githubusercontent.com%2Fu%2F30535937%3Fv%3D4%3Fs%3D400" height="auto" class="m-0"&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;div class="c-embed__body"&gt;
      &lt;h2 class="fs-xl lh-tight"&gt;
        &lt;a href="https://github.com/RicardoGEsteves" rel="noopener noreferrer" class="c-link"&gt;
          RicardoGEsteves (Ricardo Esteves) · GitHub
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;p class="truncate-at-3"&gt;
          Full-Stack Developer | Passionate about creating intuitive and impactful user experiences | Based in Lisbon, Portugal 🇵🇹 - RicardoGEsteves
        &lt;/p&gt;
      &lt;div class="color-secondary fs-s flex items-center"&gt;
          &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.githubassets.com%2Ffavicons%2Ffavicon.svg"&gt;
        github.com
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;



</description>
      <category>webdev</category>
      <category>react</category>
      <category>typescript</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Open to work</title>
      <dc:creator>Ricardo Esteves</dc:creator>
      <pubDate>Tue, 06 Aug 2024 14:54:24 +0000</pubDate>
      <link>https://dev.to/ricardogesteves/open-to-work-3abh</link>
      <guid>https://dev.to/ricardogesteves/open-to-work-3abh</guid>
      <description>&lt;p&gt;Excited to share my passion for crafting exceptional digital experiences! I'm a full-stack developer with a strong focus on frontend development, and I'm seeking new challenges and opportunities.&lt;/p&gt;

&lt;p&gt;My tech stack includes TypeScript, React, Next.js, Node.js, TailwindCSS, Zustand/Redux, Prisma/Drizzle, PostgreSQL/MySQL/MongoDB, REST APIs/GraphQL, React Query and Server Actions and a lot more.&lt;/p&gt;

&lt;p&gt;Check out my portfolio to see my work:&lt;br&gt;
&lt;/p&gt;
&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
      &lt;div class="c-embed__cover"&gt;
        &lt;a href="https://www.ricardogesteves.com/" class="c-link s:max-w-50 align-middle" rel="noopener noreferrer"&gt;
          &lt;img alt="" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fricardogesteves.com%2Fog-image.png" height="auto" class="m-0"&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;div class="c-embed__body"&gt;
      &lt;h2 class="fs-xl lh-tight"&gt;
        &lt;a href="https://www.ricardogesteves.com/" rel="noopener noreferrer" class="c-link"&gt;
          Ricardo Esteves Portfolio Website
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;p class="truncate-at-3"&gt;
          Ricardo Esteves portfolio website with custom CMS and blog. Built using TypeScript, React, Next.js, Convex, Zustand, Zod, Clerk, Axios, Framer Motion, and Tailwind CSS.
        &lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  &amp;lt;div class="color-secondary fs-s flex items-center"&amp;gt;
      &amp;lt;img
        alt="favicon"
        class="c-embed__favicon m-0 mr-2 radius-0"
        src="https://www.ricardogesteves.com/favicon.ico"
        loading="lazy" /&amp;gt;
    ricardogesteves.com
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;/div&gt;
&lt;br&gt;
 

&lt;p&gt;I'm currently open to new projects, so feel free to reach out if you're looking for a dedicated developer to join your team! Let's build something amazing together!&lt;/p&gt;
&lt;/div&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>nextjs</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Exciting News, my brand-new website is live</title>
      <dc:creator>Ricardo Esteves</dc:creator>
      <pubDate>Tue, 18 Jun 2024 10:22:10 +0000</pubDate>
      <link>https://dev.to/ricardogesteves/exciting-news-my-brand-new-website-is-live-22ie</link>
      <guid>https://dev.to/ricardogesteves/exciting-news-my-brand-new-website-is-live-22ie</guid>
      <description>&lt;p&gt;Hey DEV's! 👋&lt;/p&gt;

&lt;p&gt;I’m thrilled to announce the launch of my brand-new website, built with the latest technologies. As a full-stack developer, I’ve poured my experience and creativity into building a site that reflects my dedication to code quality and user experience.&lt;/p&gt;

&lt;h3&gt;
  
  
  Explore it live at:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.ricardogesteves.com" rel="noopener noreferrer"&gt;https://www.ricardogesteves.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'm looking for constructive criticism, cool ideas for improvements and disruptive new features.&lt;/p&gt;

&lt;p&gt;Follow me &lt;strong&gt;&lt;a class="mentioned-user" href="https://dev.to/ricardogesteves"&gt;@ricardogesteves&lt;/a&gt;&lt;/strong&gt; &lt;br&gt;
&lt;a href="https://twitter.com/ricardogesteves" rel="noopener noreferrer"&gt;X(twitter)&lt;/a&gt;&lt;/p&gt;


&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
      &lt;div class="c-embed__cover"&gt;
        &lt;a href="https://github.com/RicardoGEsteves" class="c-link s:max-w-50 align-middle" rel="noopener noreferrer"&gt;
          &lt;img alt="" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Favatars.githubusercontent.com%2Fu%2F30535937%3Fv%3D4%3Fs%3D400" height="auto" class="m-0"&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;div class="c-embed__body"&gt;
      &lt;h2 class="fs-xl lh-tight"&gt;
        &lt;a href="https://github.com/RicardoGEsteves" rel="noopener noreferrer" class="c-link"&gt;
          RicardoGEsteves (Ricardo Esteves) · GitHub
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;p class="truncate-at-3"&gt;
          Full-Stack Developer | Passionate about creating intuitive and impactful user experiences | Based in Lisbon, Portugal 🇵🇹 - RicardoGEsteves
        &lt;/p&gt;
      &lt;div class="color-secondary fs-s flex items-center"&gt;
          &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.githubassets.com%2Ffavicons%2Ffavicon.svg"&gt;
        github.com
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;


</description>
      <category>webdev</category>
      <category>typescript</category>
      <category>nextjs</category>
      <category>react</category>
    </item>
    <item>
      <title>React 19 new features and improvements</title>
      <dc:creator>Ricardo Esteves</dc:creator>
      <pubDate>Fri, 17 May 2024 09:42:04 +0000</pubDate>
      <link>https://dev.to/ricardogesteves/react-19-new-features-and-improvements-2fk6</link>
      <guid>https://dev.to/ricardogesteves/react-19-new-features-and-improvements-2fk6</guid>
      <description>&lt;h2&gt;
  
  
  Hi DEVs,
&lt;/h2&gt;

&lt;h3&gt;
  
  
  let's check what the React team have been doing and what will be provided in react 19.
&lt;/h3&gt;

&lt;p&gt;Following the exciting announcements at React Conf 2024, it's clear that the future of React is bright. The new features and improvements unveiled are set to be released soon and will be generally available to all. Among these advancements, the React Compiler stands out as a game-changer. In a move that underscores React's commitment to the open-source community, the React Compiler will be open source, allowing developers worldwide to contribute to its evolution.&lt;/p&gt;




&lt;h3&gt;
  
  
  New/Extended Features in React 19
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Some of them already stable and available on Next.js&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;1. React Compiler&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The React Compiler is a significant feature in React 19. It takes your React code and converts it into regular JavaScript. This process can potentially double the performance of your application.&lt;br&gt;
The need for a compiler arises from the challenges with memoization and multiple re-renders. Traditionally, React uses a process called bundling to transform the JSX code into optimized JavaScript files for the browser. The new compiler takes this concept a step further. It analyzes your code at a deeper level, understanding the structure and dependencies between components.&lt;br&gt;
React operates on a core principle: re-rendering of UI triggered by changes in application state. This allows us to describe the desired end state of the UI, rather than implicitly writing step-by-step instructions on how to manipulate the DOM. However, this can sometimes lead to excessive re-renders.&lt;/p&gt;

&lt;p&gt;To prevent this, we had to intentionally optimize our components using memoization techniques. Memoization in React is a performance optimization technique that involves storing and reusing the results of expensive computations or component output based on the input parameters.&lt;br&gt;
The React Compiler aims to simplify this process by automatically handling memoization and re-rendering. It allows compiled React code to automatically render only the right parts of the UI when the state changes. This removes the need of &lt;code&gt;useMemo&lt;/code&gt;, &lt;code&gt;useCallback&lt;/code&gt;, and &lt;code&gt;memo&lt;/code&gt;. (If you follow the &lt;a href="https://19.react.dev/reference/react#rules-of-react" rel="noopener noreferrer"&gt;rules of react&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Server Components&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Server Components in React 19 allow components to be processed on the server before delivering the page to users. This results in faster page loading and better SEO. It's a significant improvement as it reduces the amount of JavaScript that needs to be sent to the client, improving performance, particularly on slower networks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Actions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Actions in React 19 simplify the management of data and interactions within web pages. They provide a pending state that starts at the beginning of a request and automatically resets when the final state update is committed. This allows you to keep the current UI responsive and interactive while the data is changing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Document Metadata&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Document Metadata in React 19 allowing us to accomplish more with less code. It provides a way to manage the metadata of a document, such as the title, meta tags, and other head elements. This is particularly useful for SEO and user experience, as it allows to dynamically change the metadata based on the application state.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Asset Loading&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Asset Loading in React 19 enables assets to load in the background. This improves both the application's load time and the user experience. It's a significant improvement as it allows for better control over how and when assets are loaded, which can have a big impact on performance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Web Components&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Web Components in React 19 introduce improved compatibility with the Web Components standard. This allows for more flexible and compatible frontend development. It's a significant improvement as it allows us to use custom elements, shadow DOM, and HTML templates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. Enhanced/New Hooks&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Introduces four new hooks: &lt;code&gt;useOptimistic&lt;/code&gt;, &lt;code&gt;useFormStatus&lt;/code&gt;, &lt;code&gt;useFormState&lt;/code&gt;, and &lt;code&gt;use&lt;/code&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. useOptimistic&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;useOptimistic&lt;/code&gt; hook allows you to update the UI optimistically before receiving confirmation from the server². This provides a seamless user experience by ensuring that users don't have to wait for feedback. It's particularly useful in scenarios where you want to give immediate feedback to the user, even before the server has responded.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. useFormStatus&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;useFormStatus&lt;/code&gt; hook manages the status of form fields, handling validation logic and submission state. It gives you status information of the last form submission. This simplifies form management by providing a centralized mechanism to monitor and modify the status of form fields.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. useFormState&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;useFormState&lt;/code&gt; hook serves as a manager for form input states. It offers a centralized mechanism to monitor and modify their values efficiently. It allows you to update state based on the outcome of form actions. This hook requires two arguments:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;fn&lt;/code&gt;: This parameter represents the function to execute when the form is submitted or a button is pressed. Upon invocation, this function receives the previous state of the form (initially the &lt;code&gt;initialState&lt;/code&gt; that you pass, subsequently its previous return value) as its initial argument, followed by the arguments that a form action normally receives.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;initialState&lt;/code&gt;: This argument denotes the initial state value desired for the form. It can be any serializable value. Once the action is initially invoked, this parameter becomes irrelevant.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4. use&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;use&lt;/code&gt; hook is a versatile React Hook designed to fetch and utilize the value of a resource, such as a Promise or context, within your components or custom hooks. What sets &lt;code&gt;use&lt;/code&gt; apart from other React Hooks is its unique ability to be invoked within loops and conditional statements, such as if blocks. However, it still adheres to the standard requirement that the function utilizing &lt;code&gt;use&lt;/code&gt; must be either a Component or another Hook.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Check out:&lt;/strong&gt; &lt;a href="https://react.dev/blog/2024/04/25/react-19" rel="noopener noreferrer"&gt;React19 beta API docs&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In conclusion&lt;/strong&gt;&lt;br&gt;
This will be an overall improvement not just on user &lt;br&gt;
experience but also for developers.&lt;/p&gt;

&lt;p&gt;The React Compiler stands out as a game-changer. It takes your React code and converts it into optimized JavaScript, improving performance. This is a significant step forward as it not only enhances the performance but also simplifies the development process by automatically handling memoization and re-rendering. This means that we can focus more on building great user experiences rather than worrying about performance optimization.&lt;/p&gt;

&lt;p&gt;On my opinion the use hook is another powerful addition that is set to revolutionize how we write and manage state in our React applications. The use hook provides a more flexible and efficient way to fetch and utilize the value of a resource, such as a Promise or context, within your components or custom hooks. What sets it apart from other React Hooks is its unique ability to be invoked within loops and conditional statements, such as if blocks. This brings a new level of dynamism and control to state management in React.&lt;/p&gt;

&lt;p&gt;Follow me &lt;strong&gt;&lt;a class="mentioned-user" href="https://dev.to/ricardogesteves"&gt;@ricardogesteves&lt;/a&gt;&lt;/strong&gt; &lt;br&gt;
&lt;a href="https://twitter.com/ricardogesteves" rel="noopener noreferrer"&gt;X(twitter)&lt;/a&gt;&lt;/p&gt;


&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
      &lt;div class="c-embed__cover"&gt;
        &lt;a href="https://github.com/RicardoGEsteves" class="c-link s:max-w-50 align-middle" rel="noopener noreferrer"&gt;
          &lt;img alt="" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Favatars.githubusercontent.com%2Fu%2F30535937%3Fv%3D4%3Fs%3D400" height="auto" class="m-0"&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;div class="c-embed__body"&gt;
      &lt;h2 class="fs-xl lh-tight"&gt;
        &lt;a href="https://github.com/RicardoGEsteves" rel="noopener noreferrer" class="c-link"&gt;
          RicardoGEsteves (Ricardo Esteves) · GitHub
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;p class="truncate-at-3"&gt;
          Full-Stack Developer | Passionate about creating intuitive and impactful user experiences | Based in Lisbon, Portugal 🇵🇹 - RicardoGEsteves
        &lt;/p&gt;
      &lt;div class="color-secondary fs-s flex items-center"&gt;
          &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.githubassets.com%2Ffavicons%2Ffavicon.svg"&gt;
        github.com
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;


</description>
      <category>webdev</category>
      <category>react</category>
      <category>javascript</category>
      <category>nextjs</category>
    </item>
    <item>
      <title>Webhooks and WebSockets</title>
      <dc:creator>Ricardo Esteves</dc:creator>
      <pubDate>Wed, 17 Apr 2024 13:46:20 +0000</pubDate>
      <link>https://dev.to/ricardogesteves/webhooks-and-websockets-3p53</link>
      <guid>https://dev.to/ricardogesteves/webhooks-and-websockets-3p53</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In the world of web development, there are numerous technologies and terminologies that developers come across, two of which are &lt;strong&gt;Webhooks&lt;/strong&gt; and &lt;strong&gt;WebSockets&lt;/strong&gt;. Both are used for communication over the web, but they serve different purposes and work in different ways. This article aims to provide an in-depth understanding of both these technologies, their differences, and when to use each.&lt;/p&gt;

&lt;h2&gt;
  
  
  Webhooks
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  What are Webhooks?
&lt;/h3&gt;
&lt;/blockquote&gt;

&lt;p&gt;Webhooks are essentially "event-triggered HTTP requests". They are a server-to-server means of communication. A webhook is triggered by an event in a server and sends data via a pre-configured URL to another server. &lt;/p&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  How do Webhooks Work?
&lt;/h3&gt;
&lt;/blockquote&gt;

&lt;p&gt;When a specific event occurs on a server, the server sends an HTTP request (POST is common) to the URL configured for the webhook. The request will contain information about the event that can be used by the receiving server.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  When to Use Webhooks?
&lt;/h3&gt;
&lt;/blockquote&gt;

&lt;p&gt;Webhooks are efficient for receiving real-time updates and can be tailored to specific events and needs. They are commonly used in scenarios such as updating a customer database when a new user signs up, notifying a mail server to send a welcome email after sign up, or even triggering a new build in a continuous integration pipeline when a change is pushed to a version control system.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  Webhooks: The Pub-Sub Approach
&lt;/h3&gt;
&lt;/blockquote&gt;

&lt;p&gt;Imagine you're at a restaurant waiting for your order. A waiter walks around announcing completed orders. This "shout-out" system is similar to how webhooks operate. Webhooks are a lightweight method for one application (the publisher) to notify another application (the subscriber) about specific events. &lt;/p&gt;

&lt;p&gt;Here's the breakdown:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Setting Up:&lt;/strong&gt; The subscriber provides the publisher with a URL, their "listening address."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Event Triggers:&lt;/strong&gt; When a pre-defined event occurs in the publisher's application (e.g., a new user signs up), it triggers a webhook notification.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Delivery:&lt;/strong&gt; The publisher sends an HTTP request (usually a POST) to the subscriber's URL, carrying relevant information about the event in the request body.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Processing:&lt;/strong&gt; The subscriber receives the notification and processes the information accordingly, potentially triggering actions within its own application.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Think of webhooks as a push notification system – the publisher pushes updates to the subscriber when something noteworthy happens. This one-way communication makes webhooks simple and scalable, ideal for situations where the subscriber only needs to react to events and doesn't require constant back-and-forth communication. &lt;/p&gt;

&lt;h2&gt;
  
  
  WebSockets
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  What are WebSockets?
&lt;/h3&gt;
&lt;/blockquote&gt;

&lt;p&gt;WebSockets establish a two-way, persistent, bidirectional communication channel over a single connection made between two TCP ports from a client (browser) to a server.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  How do WebSockets Work?
&lt;/h3&gt;
&lt;/blockquote&gt;

&lt;p&gt;Unlike default HTTP, a WebSocket connection stays open between transactions, allowing data to flow seamlessly between both parties. Either end of a WebSocket connection can send data to the other, making it ideal for real-time data transfer.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  When to Use WebSockets?
&lt;/h3&gt;
&lt;/blockquote&gt;

&lt;p&gt;WebSockets are very beneficial when working on low-latency server-client data streaming applications. They offer a huge speed advantage, especially when data is being sent from the server to the client. They are commonly used in real-time applications such as live chat, real-time analytics, multiplayer games, and collaborative editing environments like Google Docs.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  WebSockets: The Open Channel
&lt;/h3&gt;
&lt;/blockquote&gt;

&lt;p&gt;WebSockets, on the other hand, establish a persistent, two-way communication channel between a client (like a web browser) and a server. This connection remains open for as long as both parties require it, enabling real-time data exchange in both directions – a more like a dedicated phone line for continuous conversation.&lt;/p&gt;

&lt;p&gt;Here's a glimpse into how WebSockets work:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Handshake:&lt;/strong&gt; The client initiates a connection by sending a special handshake request to the server.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Upgrade:&lt;/strong&gt;  The server acknowledges the request and upgrades the connection from HTTP to a WebSocket connection. This creates a persistent, bidirectional channel.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Flow:&lt;/strong&gt; Once connected, both client and server can send and receive data messages at any time. Messages are typically sent in a format like JSON for easy parsing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Closing:&lt;/strong&gt; When communication is no longer needed, either party can initiate a closing handshake to gracefully terminate the connection.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;WebSockets provide a real-time communication stream, making them perfect for applications where continuous data exchange is essential. For instance, chat applications leverage WebSockets to ensure messages appear on the recipient's screen almost instantly after sending.&lt;/p&gt;

&lt;h2&gt;
  
  
  Differences Between Webhooks and WebSockets
&lt;/h2&gt;

&lt;p&gt;While both Webhooks and WebSockets are used for communication over the web, they serve different purposes and work in different ways. Here are some key differences:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Communication&lt;/strong&gt;: Webhooks are a one-way communication method (from the server to the client), while WebSockets are a two-way communication method.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Connection&lt;/strong&gt;: Webhooks use a new HTTP request for each message, while WebSockets use a single persistent connection for multiple messages.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use Case&lt;/strong&gt;: Webhooks are ideal for event notifications, while WebSockets are ideal for real-time applications.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  Use cases: Webhooks vs WebSockets
&lt;/h3&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now that you understand both webhooks and WebSockets, it's crucial to know when to use each:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Use Webhooks When:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;You need a simple, scalable solution for one-way notifications.&lt;/li&gt;
&lt;li&gt;The subscriber only needs to react to events and doesn't require constant updates.&lt;/li&gt;
&lt;li&gt;Brief bursts of data exchange are sufficient. &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Use WebSockets When:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;You require real-time, two-way communication between client and server.&lt;/li&gt;
&lt;li&gt;Constant data exchange is necessary for the application to function (e.g., chat, collaborative editing).&lt;/li&gt;
&lt;li&gt;Low latency (minimal delay) is critical.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

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

&lt;p&gt;In summary, while &lt;strong&gt;Webhooks&lt;/strong&gt; are great for one-way, event-driven communication, &lt;strong&gt;WebSockets&lt;/strong&gt; excel at providing real-time, two-way communication. The choice between the two will depend on the specific needs of your application. It's not uncommon for modern applications to use both technologies, each for what they do best.&lt;/p&gt;

&lt;p&gt;Follow me &lt;strong&gt;&lt;a class="mentioned-user" href="https://dev.to/ricardogesteves"&gt;@ricardogesteves&lt;/a&gt;&lt;/strong&gt; &lt;br&gt;
&lt;a href="https://twitter.com/ricardogesteves" rel="noopener noreferrer"&gt;X(twitter)&lt;/a&gt;&lt;/p&gt;


&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
      &lt;div class="c-embed__cover"&gt;
        &lt;a href="https://github.com/RicardoGEsteves" class="c-link s:max-w-50 align-middle" rel="noopener noreferrer"&gt;
          &lt;img alt="" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Favatars.githubusercontent.com%2Fu%2F30535937%3Fv%3D4%3Fs%3D400" height="auto" class="m-0"&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;div class="c-embed__body"&gt;
      &lt;h2 class="fs-xl lh-tight"&gt;
        &lt;a href="https://github.com/RicardoGEsteves" rel="noopener noreferrer" class="c-link"&gt;
          RicardoGEsteves (Ricardo Esteves) · GitHub
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;p class="truncate-at-3"&gt;
          Full-Stack Developer | Passionate about creating intuitive and impactful user experiences | Based in Lisbon, Portugal 🇵🇹 - RicardoGEsteves
        &lt;/p&gt;
      &lt;div class="color-secondary fs-s flex items-center"&gt;
          &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.githubassets.com%2Ffavicons%2Ffavicon.svg"&gt;
        github.com
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;


</description>
      <category>webdev</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>React Strict DOM package</title>
      <dc:creator>Ricardo Esteves</dc:creator>
      <pubDate>Sat, 02 Mar 2024 18:49:44 +0000</pubDate>
      <link>https://dev.to/ricardogesteves/react-strict-dom-package-1og1</link>
      <guid>https://dev.to/ricardogesteves/react-strict-dom-package-1og1</guid>
      <description>&lt;p&gt;Hi Dev's&lt;/p&gt;

&lt;p&gt;After the React team announcement to all the improvements that React v19 will bring, including the awesome introduction of a compiler. The React team is working on a truly exciting package that I believe is worth your time.&lt;/p&gt;

&lt;p&gt;In the dynamic landscape of web and native application development, achieving cross-platform consistency while preserving performance and reliability remains a formidable challenge. Meta's recent release of React Strict DOM introduces a paradigm shift in this realm. In this expansive exploration, we embark on a journey to uncover the depths of React Strict DOM, elucidating its novel features, advantages, disadvantages, and the transformative potential it holds for universal React component development.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Genesis of React Strict DOM: A New Era in Universal Components&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;React Strict DOM emerges as a revolutionary addition to the React ecosystem, poised to redefine the way developers create and deploy universal components for web and native platforms. By leveraging a novel integration of React DOM and StyleX, React Strict DOM empowers developers to seamlessly craft styled React components that transcend platform boundaries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Understanding the New React Strict DOM Package: Features and Purpose&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;At its core, React Strict DOM serves as an experimental integration of React DOM and StyleX, offering a subset of imperative DOM and CSS functionalities tailored to support both web and native targets. The primary goal of React Strict DOM is to streamline and standardize the development of styled React components, enhancing development speed, efficiency, and code maintainability across diverse platforms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantages of React Strict DOM: Accelerating Development Efficiency&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Speed and Efficiency&lt;/strong&gt;: React Strict DOM enhances the speed and efficiency of React development by providing a unified platform-agnostic API for creating styled components.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Performance and Quality&lt;/strong&gt;: Despite its experimental nature, React Strict DOM does not compromise on performance, reliability, or code quality, ensuring optimal user experiences across platforms.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Standardization&lt;/strong&gt;: By standardizing the development process, React Strict DOM promotes consistency and code maintainability, facilitating collaboration and code reuse across projects.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Disadvantages of React Strict DOM: Addressing Limitations and Challenges&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Experimental Nature&lt;/strong&gt;: As an experimental integration, React Strict DOM may entail potential issues or limitations that are yet to be fully explored or documented, necessitating careful consideration and testing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compatibility Challenges&lt;/strong&gt;: While React Strict DOM aims to support both web and native platforms, compatibility with React Native remains a work in progress, presenting challenges for developers seeking seamless integration across diverse environments.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Solving the Development Dilemma: Addressing Cross-Platform Challenges&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;React Strict DOM addresses the perennial challenge of developing styled React components for both web and native platforms in a standardized, efficient, and performant manner. By leveraging the strengths of React DOM and StyleX, React Strict DOM bridges the gap between web and native development paradigms, empowering developers to create universal components with ease.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Concept Behind React Strict DOM: Polyfills and Web API Integration&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;At its conceptual core, React Strict DOM builds upon the design goals of the "React DOM for Native proposal" by polyfilling a myriad of standard APIs and leveraging emerging web capabilities in React Native, such as DOM traversal and layout APIs. By integrating these capabilities with a well-defined event loop processing model, React Strict DOM paves the way for seamless cross-platform development experiences.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exploring React Strict DOM Through Code: A Technical Deep Dive&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Creating components with react-strict-dom&lt;br&gt;
react-strict-dom is powered by stylex which is a new styling solution created by Meta that is already powering facebook.com in production. It comes with the package under css module. All the building blocks with which we can build our app are available under html. This is how building UI with RSD looks like:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;css&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react-strict-dom&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;styles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;testid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;testid&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;span&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;span&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.span&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;paragraph&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;

      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;span&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://google.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;anchor&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.a&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;,
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;code&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;code&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.code&amp;gt;,&amp;lt;html.em&amp;gt;em&amp;lt;/&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;em&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;strong&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;strong&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.strong&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;,
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;span&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nx"&gt;H&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sub&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.sub&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;0
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.span&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;span&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nx"&gt;E&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;mc&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sup&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.sup&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.span&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.span&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;styles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;css&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;div&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;paddingBottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;paddingTop&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;white&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;


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

&lt;/div&gt;
&lt;p&gt;react-strict-dom is leveraging APIs that we know from the Web to build universal apps.&lt;/p&gt;

&lt;p&gt;Is &lt;code&gt;&amp;lt;html.div&amp;gt;&lt;/code&gt; a native component?&lt;br&gt;
Yes, it is! The role of react-strict-dom is to translate one universal API to platforms' primitives.&lt;/p&gt;

&lt;p&gt;Let's delve into a series of intricate code examples that showcase the power and versatility of React Strict DOM:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1. &lt;strong&gt;Defining Styles with StyleX&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;css&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-strict-dom&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;styles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;css&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;container&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;flexDirection&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;row&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;justifyContent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;center&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;alignItems&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;center&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lightblue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;borderRadius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;fontSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;fontWeight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;bold&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;white&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;


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

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;2. &lt;strong&gt;Creating a Styled Component&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-strict-dom&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;StyledComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;styles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;container&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;span&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;styles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Styled&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.span&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;StyledComponent&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


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

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;3. &lt;strong&gt;Rendering Text Elements&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;TextComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;This&lt;/span&gt; &lt;span class="nx"&gt;is&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;paragraph&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;span&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;This&lt;/span&gt; &lt;span class="nx"&gt;is&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;span&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.span&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;This&lt;/span&gt; &lt;span class="nx"&gt;is&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;heading&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;


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

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;4. &lt;strong&gt;Working with Lists&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ListComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Item 1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Item 2&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Item 3&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ul&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;li&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.li&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="p"&gt;))}&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.ul&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;


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

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;5. &lt;strong&gt;Handling Events&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ButtonComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleClick&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Button clicked&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleClick&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Click&lt;/span&gt; &lt;span class="nx"&gt;Me&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;


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

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;6. &lt;strong&gt;Conditionally Rendering Components&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ConditionalComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;condition&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;condition&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Condition&lt;/span&gt; &lt;span class="nx"&gt;is&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.div&amp;gt; : &amp;lt;html.div&amp;gt;Condition is false&amp;lt;/&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;


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

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;7. &lt;strong&gt;Passing Props to Components&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;PropsComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Hello&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;!&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.div&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;


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

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;8. &lt;strong&gt;Using Fragments&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;FragmentComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Fragment&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Another&lt;/span&gt; &lt;span class="nx"&gt;Fragment&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;


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

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;9. &lt;strong&gt;Styling Components Inline&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;InlineStyleComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;inlineStyle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;red&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;fontSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;18px&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;inlineStyle&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Inline&lt;/span&gt; &lt;span class="nx"&gt;Style&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.div&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;


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

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;10. &lt;strong&gt;Implementing Component Lifecycle Methods&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;LifecycleComponent&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;componentDidMount&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Component mounted&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;componentWillUnmount&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Component will unmount&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Lifecycle&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.div&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


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

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;11. &lt;strong&gt;Using Hooks&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-strict-dom&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;HooksComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;Count&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Increment&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;


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

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;12. &lt;strong&gt;Handling Form Inputs&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;FormComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setValue&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleChange&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;setValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleChange&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Typed&lt;/span&gt; &lt;span class="na"&gt;Value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;


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

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;13. &lt;strong&gt;Using Context API&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;createContext&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useContext&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-strict-dom&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ThemeContext&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;light&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ThemeComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;theme&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ThemeContext&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;



  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Current&lt;/span&gt; &lt;span class="na"&gt;Theme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.div&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;


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

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;14. &lt;strong&gt;Implementing Error Boundaries&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ErrorBoundary&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;hasError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;componentDidCatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;errorInfo&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Error caught:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;hasError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hasError&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nb"&gt;Error&lt;/span&gt; &lt;span class="nx"&gt;Encountered&lt;/span&gt;&lt;span class="o"&gt;!&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/html.div&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


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

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;15. &lt;strong&gt;Implementing Higher-Order Components&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;withLogger&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;componentDidMount&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Component mounted:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{...&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;EnhancedComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;withLogger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;MyComponent&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;


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

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Conclusion: Embracing the Future of Cross-Platform Development&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In conclusion, React Strict DOM emerges as a game-changing innovation in the realm of universal React component development. By offering a standardized, efficient, and performant solution for crafting styled components across web and native platforms, React Strict DOM heralds a new era of cross-platform development. As developers embrace the transformative potential of React Strict DOM, they unlock new possibilities for creating immersive, platform-agnostic user experiences that transcend traditional boundaries. Welcome to the future of cross-platform development with React Strict DOM.&lt;/p&gt;

&lt;p&gt;It's still in experimental faze but it looks really promising.&lt;/p&gt;

&lt;p&gt;Follow me &lt;strong&gt;&lt;a class="mentioned-user" href="https://dev.to/ricardogesteves"&gt;@ricardogesteves&lt;/a&gt;&lt;/strong&gt; &lt;br&gt;
&lt;a href="https://twitter.com/ricardogesteves" rel="noopener noreferrer"&gt;X(twitter)&lt;/a&gt;&lt;/p&gt;


&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
      &lt;div class="c-embed__cover"&gt;
        &lt;a href="https://github.com/RicardoGEsteves" class="c-link s:max-w-50 align-middle" rel="noopener noreferrer"&gt;
          &lt;img alt="" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Favatars.githubusercontent.com%2Fu%2F30535937%3Fv%3D4%3Fs%3D400" height="auto" class="m-0"&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;div class="c-embed__body"&gt;
      &lt;h2 class="fs-xl lh-tight"&gt;
        &lt;a href="https://github.com/RicardoGEsteves" rel="noopener noreferrer" class="c-link"&gt;
          RicardoGEsteves (Ricardo Esteves) · GitHub
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;p class="truncate-at-3"&gt;
          Full-Stack Developer | Passionate about creating intuitive and impactful user experiences | Based in Lisbon, Portugal 🇵🇹 - RicardoGEsteves
        &lt;/p&gt;
      &lt;div class="color-secondary fs-s flex items-center"&gt;
          &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.githubassets.com%2Ffavicons%2Ffavicon.svg"&gt;
        github.com
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;


</description>
      <category>webdev</category>
      <category>react</category>
      <category>javascript</category>
      <category>news</category>
    </item>
    <item>
      <title>Migrating from Supabase and Prisma Accelerate to Convex</title>
      <dc:creator>Ricardo Esteves</dc:creator>
      <pubDate>Fri, 02 Feb 2024 12:20:35 +0000</pubDate>
      <link>https://dev.to/ricardogesteves/migrating-from-supabase-and-prisma-accelerate-to-convex-jdk</link>
      <guid>https://dev.to/ricardogesteves/migrating-from-supabase-and-prisma-accelerate-to-convex-jdk</guid>
      <description>&lt;p&gt;Hello DEV Community,&lt;/p&gt;

&lt;p&gt;I'm Ricardo Esteves, I love to constantly explore and adopt new technologies and tools within my preferred stack ecosystem.&lt;/p&gt;

&lt;p&gt;The Tech stack that I work most with is TypeScript, React, Next.js, Node.js, Bun, Express, Hono, Prisma, PostgreSQL, MySQL, MongoDB, etc... I like to crafted a versatile skill set that encompasses both front-end and back-end development. The joy of experimentation and discovery is palpable and not always possible at my work so I apply It on my personal projects. The freedom to explore and implement the chosen technologies brings a sense of fulfillment that is not always possible within the constraints of the workplace.&lt;/p&gt;

&lt;h3&gt;
  
  
  About Supabase, Prisma And Convex
&lt;/h3&gt;

&lt;p&gt;In the rapidly evolving landscape of web development, the tools and technologies we use play a crucial role in shaping the efficiency and performance of our projects. Two popular technologies that have gained significant traction in recent years are Supabase and Prisma Accelerate. Supabase is an open-source Firebase alternative that provides real-time database capabilities using PostgreSQL, while Prisma Accelerate is an extension of the Prisma ORM (Object-Relational Mapping) designed to boost database query performance.&lt;/p&gt;

&lt;p&gt;However, as the tech world never stands still, developers are constantly on the lookout for newer, more performant solutions. One such emerging player in the realm of databases is Convex. In this article, we will explore the journey of migrating from Supabase and Prisma Accelerate to Convex, evaluating the advantages, use cases, challenges, and steps involved in the migration process.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Existing Stack: TypeScript, Next.js, Supabase, Prisma
&lt;/h2&gt;

&lt;p&gt;Before delving into the migration journey, it's essential to understand the existing technology stack. The stack in question comprises TypeScript as the programming language, Next.js as the React framework for building web applications, Supabase with real-time database capabilities using PostgreSQL, and Prisma as the ORM for database interactions.&lt;/p&gt;

&lt;p&gt;This stack has proven to be robust and reliable, but as development practices evolve, exploring new alternatives becomes imperative for staying ahead of the curve.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Quest for Something New and Performant
&lt;/h2&gt;

&lt;p&gt;In the pursuit of innovation and performance improvements, developers often find themselves exploring newer technologies. This yearning for something new led to the discovery of Convex, a promising database solution that aims to simplify database interactions and enhance performance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use Cases for Migrating to Convex
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Performance Optimization&lt;/strong&gt;: Convex boasts impressive performance gains compared to traditional databases. Its optimized query execution and data retrieval mechanisms make it a compelling choice for projects with stringent performance requirements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Simplified Query Language&lt;/strong&gt;: Convex introduces a simplified query language that can lead to more concise and readable code. This can be particularly beneficial for developers seeking a more intuitive and expressive way to interact with databases.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Real-time Capabilities&lt;/strong&gt;: Similar to Supabase, Convex provides real-time capabilities, allowing developers to build applications with dynamic, live-updating content without the need for complex configurations.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Advantages of Migrating to Convex
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Performance Boost&lt;/strong&gt;: Convex is designed for speed, offering significantly improved query execution times compared to traditional database solutions. This can result in faster response times for applications.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Simplified Syntax&lt;/strong&gt;: Convex introduces a clean and straightforward syntax for database queries, reducing the learning curve for developers transitioning from other database management systems.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Real-time Data Updates&lt;/strong&gt;: The real-time capabilities of Convex enable seamless integration of live updates into applications, enhancing the user experience for dynamic content.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Disadvantages of Migrating to Convex
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Learning Curve&lt;/strong&gt;: Developers accustomed to Prisma's syntax and structure may face a learning curve when adapting to Convex's approach to queries and mutations. This includes differences in schema definitions, syntax, and migration strategies.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Integration Challenges&lt;/strong&gt;: Projects heavily reliant on Prisma may face integration challenges during migration. Adapting existing code and ensuring a smooth transition can be time-consuming.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Limited Ecosystem&lt;/strong&gt;: As a relatively new player, Convex have a smaller ecosystem compared to established solutions like Prisma. This could mean fewer community-contributed plugins and integrations.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Challenges of Migration
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Data Migration&lt;/strong&gt;: Moving data from the existing database to Convex requires careful planning and execution to ensure data integrity and consistency during the transition.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Code Refactoring&lt;/strong&gt;: Adapting existing code, especially if it heavily relies on Prisma-specific features, may require substantial refactoring to align with Convex's syntax and structure.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Testing and QA&lt;/strong&gt;: Thorough testing is essential to identify and address any compatibility issues or unexpected behaviors that may arise post-migration.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  How to Set Up Convex and Steps to Take
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Installation&lt;/strong&gt;: Begin by installing Convex in your project using the recommended installation method for your development environment.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Configuration&lt;/strong&gt;: Configure Convex with the necessary connection details, such as database URL and authentication credentials.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Schema Definition&lt;/strong&gt;: Define your database schema using Convex's schema definition, which differ from Prisma's schema syntax.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Data Migration&lt;/strong&gt;: Develop a strategy for migrating data from the existing database to Convex, ensuring data consistency throughout the process.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Code Adaptation&lt;/strong&gt;: Refactor your application code to align with Convex's query and mutation syntax. Pay special attention to areas where Prisma-specific features were heavily utilized.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Testing&lt;/strong&gt;: Conduct comprehensive testing to identify and resolve any issues that may arise from the migration. This includes unit testing, integration testing, and end-to-end testing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Deployment&lt;/strong&gt;: Once satisfied with the testing results, deploy the updated application with Convex as the database backend.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;Migrating from Supabase and Prisma Accelerate to Convex is a strategic decision that comes with its set of challenges and advantages. While Convex offers impressive performance improvements and a simplified query language, developers must navigate the learning curve and potential integration challenges.&lt;/p&gt;

&lt;p&gt;As technology continues to evolve, staying abreast of new developments and exploring alternative solutions is essential for ensuring the longevity and efficiency of your projects. The migration process outlined here provides a roadmap for developers considering the shift to Convex, offering insights into the considerations, advantages, and challenges associated with this transition.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Follow me&lt;/strong&gt;: &lt;a href="https://dev.to/ricardogesteves" class="ltag_cta ltag_cta--branded"&gt;@ricardogesteves&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;On Twitter&lt;/strong&gt;: &lt;a href="https://twitter.com/ricardogesteves" class="ltag_cta ltag_cta--branded" rel="noopener noreferrer"&gt;@RicardoGEsteves&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;On GitHub&lt;/strong&gt;:  &lt;/p&gt;
&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
      &lt;div class="c-embed__cover"&gt;
        &lt;a href="https://github.com/RicardoGEsteves" class="c-link s:max-w-50 align-middle" rel="noopener noreferrer"&gt;
          &lt;img alt="" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Favatars.githubusercontent.com%2Fu%2F30535937%3Fv%3D4%3Fs%3D400" height="auto" class="m-0"&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;div class="c-embed__body"&gt;
      &lt;h2 class="fs-xl lh-tight"&gt;
        &lt;a href="https://github.com/RicardoGEsteves" rel="noopener noreferrer" class="c-link"&gt;
          RicardoGEsteves (Ricardo Esteves) · GitHub
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;p class="truncate-at-3"&gt;
          Full-Stack Developer | Passionate about creating intuitive and impactful user experiences | Based in Lisbon, Portugal 🇵🇹 - RicardoGEsteves
        &lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  &amp;lt;div class="color-secondary fs-s flex items-center"&amp;gt;
      &amp;lt;img
        alt="favicon"
        class="c-embed__favicon m-0 mr-2 radius-0"
        src="https://github.githubassets.com/favicons/favicon.svg"
        loading="lazy" /&amp;gt;
    github.com
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;/div&gt;
&lt;br&gt;
 

&lt;p&gt;&lt;code&gt;Happy coding!&lt;/code&gt;&lt;/p&gt;
&lt;/div&gt;

</description>
      <category>webdev</category>
      <category>typescript</category>
      <category>nextjs</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>React Query, why is an awesome tool to manage Remote State</title>
      <dc:creator>Ricardo Esteves</dc:creator>
      <pubDate>Wed, 31 Jan 2024 00:05:45 +0000</pubDate>
      <link>https://dev.to/ricardogesteves/why-react-query-is-an-awesome-tool-to-manage-remote-state-in-your-applications-4l6a</link>
      <guid>https://dev.to/ricardogesteves/why-react-query-is-an-awesome-tool-to-manage-remote-state-in-your-applications-4l6a</guid>
      <description>&lt;p&gt;&lt;strong&gt;The Power of React Query for Efficient Remote State Management&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;In the ever-evolving landscape of frontend development, managing remote state efficiently is a crucial aspect of building performant and scalable React applications. While &lt;code&gt;useEffect&lt;/code&gt; has been a workhorse for side effects, it falls short when it comes to handling complex scenarios like caching, optimistic updates, and real-time synchronization. Enter React Query – a game-changing library that provides a comprehensive solution for managing remote state. In this post, we'll delve into the technical nuances of why React Query stands out and why it should be your go-to tool.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Declarative Querying:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;React Query introduces a declarative approach to fetching and managing remote data. The &lt;code&gt;useQuery&lt;/code&gt; hook simplifies expressing data requirements, resulting in a cleaner and more maintainable codebase. Let's compare it with a basic example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Using useEffect&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setData&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;isLoading&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setIsLoading&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;fetchData&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;setData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nf"&gt;setIsLoading&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[]);&lt;/span&gt;

&lt;span class="c1"&gt;// Using React Query&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;isLoading&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useQuery&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;todos&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fetchTodos&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The React Query version significantly reduces boilerplate and clearly articulates the intention of fetching 'todos'.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Automatic Caching:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;React Query's intelligent caching mechanism is a standout feature. Once data is fetched, it's automatically cached, eliminating redundant network requests. This not only improves performance by leveraging stored data but also enhances the user experience by reducing load times.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Automatic caching with React Query&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;isLoading&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useQuery&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;todos&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fetchTodos&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In contrast, implementing such caching with &lt;code&gt;useEffect&lt;/code&gt; involves manual handling of cached data, leading to increased complexity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Mutation Management:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Handling mutations is streamlined with React Query's &lt;code&gt;useMutation&lt;/code&gt; hook. It takes care of the entire lifecycle, including optimistic updates, automatic re-fetching of data, and error handling.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Using useMutation with React Query&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;queryClient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useQueryClient&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;mutate&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useMutation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;updateTodo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;onSuccess&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;queryClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;invalidateQueries&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;todos&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Usage&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;updateTodoHandler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;mutate&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This approach is more elegant and less error-prone compared to manually managing mutations with &lt;code&gt;useEffect&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Real-time Updates:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;React Query seamlessly integrates with WebSocket libraries, offering real-time updates through tools like &lt;code&gt;react-query/devtools&lt;/code&gt;. This ensures that your application stays in sync with remote data changes, providing a dynamic and real-time user experience.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Real-time updates with React Query&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ReactQueryDevtools&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-query/devtools&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* Your App Components */&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ReactQueryDevtools&lt;/span&gt; &lt;span class="na"&gt;initialIsOpen&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Real-time capabilities are challenging to achieve with &lt;code&gt;useEffect&lt;/code&gt; and often require additional state management complexity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Consistent Error Handling:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;React Query promotes a unified approach to error handling across queries and mutations. The &lt;code&gt;onError&lt;/code&gt; callback ensures consistent error management, simplifying the process of handling errors and providing meaningful feedback to users.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Consistent error handling with React Query&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;isLoading&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useQuery&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;todos&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fetchTodos&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;onError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Handle errors consistently&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Achieving such consistency with &lt;code&gt;useEffect&lt;/code&gt; involves scattered error handling logic throughout the component.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Integration with DevTools:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;React Query's built-in development tools offer deep insights into the state of queries, mutations, and cache. This significantly aids in debugging and optimizing your application, providing a smoother development experience.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// DevTools integration&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ReactQueryDevtools&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-query/devtools&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* Your App Components */&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ReactQueryDevtools&lt;/span&gt; &lt;span class="na"&gt;initialIsOpen&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Debugging becomes more straightforward, allowing developers to identify and resolve issues efficiently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. Optimistic Updates:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;React Query's support for optimistic updates simplifies the process of updating the UI before a mutation is confirmed by the server. This instant feedback enhances the user experience, making the application feel more responsive.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Optimistic updates with React Query&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;queryClient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useQueryClient&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;mutate&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useMutation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;createTodo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;onSuccess&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;queryClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setQueryData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;todos&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;oldData&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;oldData&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Usage&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;createTodoHandler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;mutate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Implementing optimistic updates with &lt;code&gt;useEffect&lt;/code&gt; requires meticulous handling of temporary UI states, leading to increased complexity.&lt;/p&gt;

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

&lt;p&gt;In conclusion, React Query emerges as an indispensable tool for managing remote state in React applications. Its features such as declarative querying, automatic caching, built-in mutation management, real-time updates, consistent error handling, integration with development tools, and support for optimistic updates collectively make it a superior choice over using &lt;code&gt;useEffect&lt;/code&gt; for remote state management.&lt;/p&gt;

&lt;p&gt;By adopting React Query, developers can streamline their codebase, enhance performance, and build more robust and scalable applications. The library's focus on simplicity, efficiency, and developer experience makes it a must-have in the toolkit of any modern React developer. Embrace React Query and elevate your remote state management to new heights!&lt;/p&gt;

&lt;p&gt;Follow me &lt;a class="mentioned-user" href="https://dev.to/ricardogesteves"&gt;@ricardogesteves&lt;/a&gt; &lt;br&gt;
&lt;a href="https://github.com/RicardoGEsteves"&gt;on GitHub&lt;/a&gt;&lt;br&gt;
&lt;a href="https://twitter.com/ricardogesteves"&gt;on Twitter&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>frontend</category>
      <category>javascript</category>
      <category>typescript</category>
    </item>
    <item>
      <title>2024 Web Development Roadmap: A Comprehensive Guide</title>
      <dc:creator>Ricardo Esteves</dc:creator>
      <pubDate>Thu, 25 Jan 2024 23:00:50 +0000</pubDate>
      <link>https://dev.to/ricardogesteves/navigating-the-2024-web-development-roadmap-a-comprehensive-guide-4402</link>
      <guid>https://dev.to/ricardogesteves/navigating-the-2024-web-development-roadmap-a-comprehensive-guide-4402</guid>
      <description>&lt;p&gt;Hey DEV Community!&lt;/p&gt;

&lt;p&gt;As we step into 2024, the landscape of web development continues to evolve at a rapid pace. Whether you're a seasoned developer or just starting out, having a roadmap can greatly assist in charting your course through the vast sea of technologies and frameworks. In this article, we'll delve into a comprehensive roadmap for both frontend and backend development, equipping you with the knowledge and resources needed to thrive in the ever-changing world of web development.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h2&gt;
  
  
  2024 Frontend Roadmap
&lt;/h2&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;u&gt;HTML&lt;/u&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Basics&lt;/li&gt;
&lt;li&gt;Forms&lt;/li&gt;
&lt;li&gt;Emmet&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;u&gt;CSS&lt;/u&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Selectors&lt;/li&gt;
&lt;li&gt;Inheritance&lt;/li&gt;
&lt;li&gt;Specificity&lt;/li&gt;
&lt;li&gt;Box Model&lt;/li&gt;
&lt;li&gt;Position&lt;/li&gt;
&lt;li&gt;Display&lt;/li&gt;
&lt;li&gt;Flexbox&lt;/li&gt;
&lt;li&gt;Grid&lt;/li&gt;
&lt;li&gt;Calc&lt;/li&gt;
&lt;li&gt;Pseudo Elements&lt;/li&gt;
&lt;li&gt;Pseudo Classes&lt;/li&gt;
&lt;li&gt;Custom Properties&lt;/li&gt;
&lt;li&gt;Logical Properties&lt;/li&gt;
&lt;li&gt;Media Queries&lt;/li&gt;
&lt;li&gt;Container Queries&lt;/li&gt;
&lt;li&gt;Animation&lt;/li&gt;
&lt;li&gt;Transitions&lt;/li&gt;
&lt;li&gt;Transforms&lt;/li&gt;
&lt;li&gt;Responsive Design&lt;/li&gt;
&lt;li&gt;Accessibility&lt;/li&gt;
&lt;li&gt;BEM&lt;/li&gt;
&lt;li&gt;SMACSS&lt;/li&gt;
&lt;li&gt;CSS Modules&lt;/li&gt;
&lt;li&gt;CSS Frameworks&lt;/li&gt;
&lt;li&gt;CSS Preprocessors&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;u&gt;JavaScript&lt;/u&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Async vs Defer Script Loading&lt;/li&gt;
&lt;li&gt;Var vs Let vs Const&lt;/li&gt;
&lt;li&gt;Function Basics&lt;/li&gt;
&lt;li&gt;Callbacks&lt;/li&gt;
&lt;li&gt;Arrow Functions&lt;/li&gt;
&lt;li&gt;Hoisting&lt;/li&gt;
&lt;li&gt;Scoping&lt;/li&gt;
&lt;li&gt;Closures&lt;/li&gt;
&lt;li&gt;Strict Equality&lt;/li&gt;
&lt;li&gt;Objects/Arrays&lt;/li&gt;
&lt;li&gt;Reference Vs Value&lt;/li&gt;
&lt;li&gt;DOM Traversal&lt;/li&gt;
&lt;li&gt;DOM Manipulation&lt;/li&gt;
&lt;li&gt;Event Listeners&lt;/li&gt;
&lt;li&gt;Control Flow (If, Loops, etc.)&lt;/li&gt;
&lt;li&gt;Promises&lt;/li&gt;
&lt;li&gt;Async Await&lt;/li&gt;
&lt;li&gt;Fetch&lt;/li&gt;
&lt;li&gt;Browser Storage&lt;/li&gt;
&lt;li&gt;Event Loop&lt;/li&gt;
&lt;li&gt;Modules&lt;/li&gt;
&lt;li&gt;Null Vs Undefined&lt;/li&gt;
&lt;li&gt;Recursion&lt;/li&gt;
&lt;li&gt;Bundlers&lt;/li&gt;
&lt;li&gt;Array Methods&lt;/li&gt;
&lt;li&gt;Template Literals&lt;/li&gt;
&lt;li&gt;Destructuring/Spread Operator&lt;/li&gt;
&lt;li&gt;Classes&lt;/li&gt;
&lt;li&gt;Inheritance&lt;/li&gt;
&lt;li&gt;Iterators&lt;/li&gt;
&lt;li&gt;Generators&lt;/li&gt;
&lt;li&gt;Destructuring&lt;/li&gt;
&lt;li&gt;String Methods&lt;/li&gt;
&lt;li&gt;Object Methods&lt;/li&gt;
&lt;li&gt;Map/Set&lt;/li&gt;
&lt;li&gt;WeakMap/WeakSet&lt;/li&gt;
&lt;li&gt;Symbols&lt;/li&gt;
&lt;li&gt;Default Parameters&lt;/li&gt;
&lt;li&gt;Rest Parameters&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;u&gt;Frontend Framework&lt;/u&gt; - (Choose Any)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;React (Recommended)&lt;/li&gt;
&lt;li&gt;Astro (Second Recommendation)&lt;/li&gt;
&lt;li&gt;Svelte (Growing Popularity)&lt;/li&gt;
&lt;li&gt;Angular (Declining Popularity)&lt;/li&gt;
&lt;li&gt;Vue (Declining Popularity)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;u&gt;React&lt;/u&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Component Model&lt;/li&gt;
&lt;li&gt;JSX&lt;/li&gt;
&lt;li&gt;Props&lt;/li&gt;
&lt;li&gt;State&lt;/li&gt;
&lt;li&gt;Events&lt;/li&gt;
&lt;li&gt;useEffect&lt;/li&gt;
&lt;li&gt;StrictMode&lt;/li&gt;
&lt;li&gt;Lists/Conditional Rendering&lt;/li&gt;
&lt;li&gt;Fragments&lt;/li&gt;
&lt;li&gt;Refs&lt;/li&gt;
&lt;li&gt;useMemo&lt;/li&gt;
&lt;li&gt;useCallback&lt;/li&gt;
&lt;li&gt;Custom Hooks&lt;/li&gt;
&lt;li&gt;useReducer&lt;/li&gt;
&lt;li&gt;Context&lt;/li&gt;
&lt;li&gt;Routing&lt;/li&gt;
&lt;li&gt;Portal&lt;/li&gt;
&lt;li&gt;useLayoutEffect&lt;/li&gt;
&lt;li&gt;Suspense&lt;/li&gt;
&lt;li&gt;Hooks in general&lt;/li&gt;
&lt;li&gt;Best Practices&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;u&gt;Meta Framework&lt;/u&gt; - (Optional) (Choose Any)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;React

&lt;ul&gt;
&lt;li&gt;Next.js (Recommended)&lt;/li&gt;
&lt;li&gt;Astro (Second Recommendation)&lt;/li&gt;
&lt;li&gt;Remix&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Astro

&lt;ul&gt;
&lt;li&gt;Astro (Recommended)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Svelte

&lt;ul&gt;
&lt;li&gt;SvelteKit (Recommended)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Angular

&lt;ul&gt;
&lt;li&gt;Analog (Recommended)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Vue

&lt;ul&gt;
&lt;li&gt;Nuxt.js (Recommended)&lt;/li&gt;
&lt;/ul&gt;


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

&lt;h3&gt;
  
  
  &lt;u&gt;Next.js&lt;/u&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;App Router&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Folder Based Routing&lt;/li&gt;
&lt;li&gt;Metadata/SEO&lt;/li&gt;
&lt;li&gt;Server vs Client Components&lt;/li&gt;
&lt;li&gt;Data Fetching&lt;/li&gt;
&lt;li&gt;Loading/Error Pages&lt;/li&gt;
&lt;li&gt;Dynamic Routes&lt;/li&gt;
&lt;li&gt;Data Cache/Request Memoization/Full Route 
Cache/Router Cache&lt;/li&gt;
&lt;li&gt;Dynamic vs Static Pages&lt;/li&gt;
&lt;li&gt;Dynamic Functions&lt;/li&gt;
&lt;li&gt;Server Actions&lt;/li&gt;
&lt;li&gt;useOptimistic/useFormState/useFormStatus&lt;/li&gt;
&lt;li&gt;Parallel Routes/Intercepting Routes&lt;/li&gt;
&lt;li&gt;Route Handlers&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;Pages Directory&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Page Based Routing&lt;/li&gt;
&lt;li&gt;CSR vs SSR vs SSG vs ISR&lt;/li&gt;
&lt;li&gt;getServerSideProps/getStaticProps/getStaticPaths/getInitialProps&lt;/li&gt;
&lt;li&gt;API Routes&lt;/li&gt;
&lt;/ul&gt;


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

&lt;h3&gt;
  
  
  &lt;u&gt;TypeScript&lt;/u&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;TSConfig&lt;/li&gt;
&lt;li&gt;Type Inference&lt;/li&gt;
&lt;li&gt;Array Type&lt;/li&gt;
&lt;li&gt;Any/Unknown Type&lt;/li&gt;
&lt;li&gt;Type vs Interfaces&lt;/li&gt;
&lt;li&gt;Functions&lt;/li&gt;
&lt;li&gt;Unions/Intersections&lt;/li&gt;
&lt;li&gt;readonly/keyof/typeof&lt;/li&gt;
&lt;li&gt;As Const/Enums&lt;/li&gt;
&lt;li&gt;Tuples&lt;/li&gt;
&lt;li&gt;Generics&lt;/li&gt;
&lt;li&gt;Built In Types (Pick, Omit, etc.)&lt;/li&gt;
&lt;li&gt;Type Guards&lt;/li&gt;
&lt;li&gt;Satisfies&lt;/li&gt;
&lt;li&gt;Discriminated Union&lt;/li&gt;
&lt;li&gt;Function Overloads&lt;/li&gt;
&lt;li&gt;Type Predicate Functions&lt;/li&gt;
&lt;li&gt;Declaration Files&lt;/li&gt;
&lt;/ul&gt;




&lt;blockquote&gt;
&lt;h2&gt;
  
  
  2024 Backend Roadmap
&lt;/h2&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;u&gt;Backend Language&lt;/u&gt; - (Choose Any)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;JavaScript (Recommended If Also Learning Frontend)&lt;/li&gt;
&lt;li&gt;Python (Recommended If Also Learning AI)&lt;/li&gt;
&lt;li&gt;PHP (Recommended If Also Learning Wordpress)&lt;/li&gt;
&lt;li&gt;C# (Recommended If Also Learning.NET)&lt;/li&gt;
&lt;li&gt;Rust (Difficult To Learn)&lt;/li&gt;
&lt;li&gt;Ruby (Easier To Learn But Not Used As Much)&lt;/li&gt;
&lt;li&gt;Go (Difficult To Learn)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;u&gt;Backend Framework&lt;/u&gt; - (Choose Any)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;JavaScript

&lt;ul&gt;
&lt;li&gt;Node.js With Express or Hono (Recommended)&lt;/li&gt;
&lt;li&gt;Bun with Hono (Recommended)&lt;/li&gt;
&lt;li&gt;Deno with Hono&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;PHP

&lt;ul&gt;
&lt;li&gt;Laravel (Recommended)&lt;/li&gt;
&lt;li&gt;Wordpress (Also Recommended)&lt;/li&gt;
&lt;li&gt;CodeIgniter&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Python

&lt;ul&gt;
&lt;li&gt;Django (Recommended)&lt;/li&gt;
&lt;li&gt;Flask&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;C#

&lt;ul&gt;
&lt;li&gt;.NET (Recommended)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Rust

&lt;ul&gt;
&lt;li&gt;Rocket (Recommended)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Ruby

&lt;ul&gt;
&lt;li&gt;Rails (Recommended)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Go

&lt;ul&gt;
&lt;li&gt;Gin (Recommended)&lt;/li&gt;
&lt;/ul&gt;


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

&lt;h3&gt;
  
  
  &lt;u&gt;Node.js/Express&lt;/u&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Var vs Let vs Const&lt;/li&gt;
&lt;li&gt;Function Basics&lt;/li&gt;
&lt;li&gt;Callbacks&lt;/li&gt;
&lt;li&gt;Arrow Functions&lt;/li&gt;
&lt;li&gt;Hoisting&lt;/li&gt;
&lt;li&gt;Scoping&lt;/li&gt;
&lt;li&gt;Closures&lt;/li&gt;
&lt;li&gt;Strict Equality&lt;/li&gt;
&lt;li&gt;Objects/Arrays&lt;/li&gt;
&lt;li&gt;Reference Vs Value&lt;/li&gt;
&lt;li&gt;Control Flow (If, Loops, etc.)&lt;/li&gt;
&lt;li&gt;Promises&lt;/li&gt;
&lt;li&gt;Async Await&lt;/li&gt;
&lt;li&gt;Callbacks&lt;/li&gt;
&lt;li&gt;Promises&lt;/li&gt;
&lt;li&gt;Async Await&lt;/li&gt;
&lt;li&gt;Common Modules&lt;/li&gt;
&lt;li&gt;Null Vs Undefined&lt;/li&gt;
&lt;li&gt;Recursion&lt;/li&gt;
&lt;li&gt;Array Methods&lt;/li&gt;
&lt;li&gt;Template Literals&lt;/li&gt;
&lt;li&gt;Destructuring/Spread Operator&lt;/li&gt;
&lt;li&gt;Node.js File System Library&lt;/li&gt;
&lt;li&gt;Express Middleware&lt;/li&gt;
&lt;li&gt;Express Routing&lt;/li&gt;
&lt;li&gt;Templating Language (EJS, Handlebars, Pug, etc.)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;u&gt;Databases&lt;/u&gt; - SQL vs NoSQL
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;SQL

&lt;ul&gt;
&lt;li&gt;PostgreSQL (Recommended)&lt;/li&gt;
&lt;li&gt;MySQL (Also Recommended)&lt;/li&gt;
&lt;li&gt;SQLite&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;NoSQL

&lt;ul&gt;
&lt;li&gt;MongoDB (Recommended)&lt;/li&gt;
&lt;li&gt;Redis (Recommended For Caching)&lt;/li&gt;
&lt;li&gt;Cassandra&lt;/li&gt;
&lt;li&gt;DynamoDB (Recommended If Working With AWS)&lt;/li&gt;
&lt;/ul&gt;


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

&lt;h3&gt;
  
  
  &lt;u&gt;TypeScript&lt;/u&gt;
&lt;/h3&gt;

&lt;p&gt;(Similar to frontend TypeScript)&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;u&gt;Next.js&lt;/u&gt; - (Optional)
&lt;/h3&gt;

&lt;p&gt;(Similar to frontend Next.js list)&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;u&gt;Other Important Topics&lt;/u&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Version Control (Learn As Soon As Possible)&lt;/li&gt;
&lt;li&gt;JSON (Learn Alongside JavaScript)&lt;/li&gt;
&lt;li&gt;Regular Expressions (Optional)&lt;/li&gt;
&lt;li&gt;How To Deploy&lt;/li&gt;
&lt;li&gt;Basic Security&lt;/li&gt;
&lt;li&gt;Testing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With this roadmap in hand, you're well-equipped to navigate the complex and dynamic world of web development in 2024 and beyond. Happy coding!&lt;/p&gt;

&lt;p&gt;Let me know your thoughts and if you have any questions or suggestions in the comments below.&lt;/p&gt;

&lt;p&gt;Follow me &lt;a class="mentioned-user" href="https://dev.to/ricardogesteves"&gt;@ricardogesteves&lt;/a&gt; &lt;br&gt;
&lt;a href="https://github.com/RicardoGEsteves"&gt;GitHub&lt;/a&gt;&lt;br&gt;
&lt;a href="https://twitter.com/ricardogesteves"&gt;Twitter&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cheers,&lt;br&gt;&lt;br&gt;
Ricardo Esteves &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>news</category>
      <category>career</category>
      <category>programming</category>
    </item>
    <item>
      <title>Next.js 14 and Emerging Open Source Projects</title>
      <dc:creator>Ricardo Esteves</dc:creator>
      <pubDate>Tue, 23 Jan 2024 10:05:02 +0000</pubDate>
      <link>https://dev.to/ricardogesteves/delving-into-the-depths-of-reactjs-ecosystem-nextjs-14-and-emerging-open-source-projects-4jga</link>
      <guid>https://dev.to/ricardogesteves/delving-into-the-depths-of-reactjs-ecosystem-nextjs-14-and-emerging-open-source-projects-4jga</guid>
      <description>&lt;p&gt;The React.js ecosystem has witnessed remarkable growth and innovation in recent years, propelling it to the forefront of front-end development. With the introduction of Next.js 14+, the ecosystem has entered a new era of enhanced performance, scalability, and developer experience. Additionally, a wave of exciting open-source projects is emerging, offering developers a plethora of tools and libraries to enhance their development workflow.&lt;/p&gt;

&lt;h3&gt;
  
  
  Next.js 14: A Paradigm Shift in React Development
&lt;/h3&gt;

&lt;p&gt;Next.js 14 marks a significant milestone in the evolution of React development, introducing a range of groundbreaking features that streamline development and elevate user experiences. Let's delve into some of the key advancements:&lt;/p&gt;

&lt;h4&gt;
  
  
  Server-Side Rendering (SSR) Optimizations
&lt;/h4&gt;

&lt;p&gt;Next.js 14 introduces significant improvements in SSR performance, enabling developers to deliver lightning-fast page load times and enhanced SEO.&lt;/p&gt;

&lt;h4&gt;
  
  
  Isomorphic Routing
&lt;/h4&gt;

&lt;p&gt;Next.js 14 empowers developers to build single-page applications (SPAs) with seamless routing capabilities, providing a unified experience across all devices and browsers.&lt;/p&gt;

&lt;h4&gt;
  
  
  Data Fetching with Suspense
&lt;/h4&gt;

&lt;p&gt;Next.js 14 extends the concept of suspense to data fetching, allowing developers to render components without waiting for data to be loaded, ensuring a responsive user experience while data is being fetched.&lt;/p&gt;

&lt;h4&gt;
  
  
  Improved Static Site Generation (SSG)
&lt;/h4&gt;

&lt;p&gt;Next.js 14 streamlines SSG operations, enabling developers to generate static pages with dynamic data, ensuring optimal performance and SEO benefits.&lt;/p&gt;

&lt;h4&gt;
  
  
  Next.js Images
&lt;/h4&gt;

&lt;p&gt;Next.js introduces a new Image component, providing developers with enhanced control over image optimization and serving, ensuring faster loading times and improved user experiences.&lt;/p&gt;

&lt;h4&gt;
  
  
  Server Actions Stability
&lt;/h4&gt;

&lt;p&gt;Server Actions, a new feature in Next.js 14, have reached stable status. This means that Server Actions are now fully supported and recommended for production use. Server Actions allow developers to run server-side code directly from their components, enabling them to perform actions such as form validation, data processing, and API calls, without the need for backend services.&lt;/p&gt;

&lt;h3&gt;
  
  
  Emerging Open Source Gems: Expanding the React Ecosystem
&lt;/h3&gt;

&lt;p&gt;Alongside the advancements in Next.js, a vibrant ecosystem of open-source projects is thriving, offering developers a range of tools and libraries to enhance their React development workflow. Let's explore some of the promising projects:&lt;/p&gt;

&lt;h4&gt;
  
  
  React Query
&lt;/h4&gt;

&lt;p&gt;React Query provides a powerful caching and data fetching solution, simplifying data fetching and reducing the need for manual caching management.&lt;/p&gt;

&lt;h4&gt;
  
  
  SWR (Stale While Revalidate)
&lt;/h4&gt;

&lt;p&gt;SWR offers a lightweight and performant data fetching solution, ensuring that UI components are always displayed with the most up-to-date data.&lt;/p&gt;

&lt;h4&gt;
  
  
  Headless UI
&lt;/h4&gt;

&lt;p&gt;Headless UI provides a set of React components for building user interfaces without the need for a JavaScript bundler, enabling developers to build server-side rendered applications.&lt;/p&gt;

&lt;h4&gt;
  
  
  Tailwind CSS
&lt;/h4&gt;

&lt;p&gt;Tailwind CSS is a utility-first CSS framework that provides a wide range of low-level CSS utilities, empowering developers to build flexible and responsive designs with ease.&lt;/p&gt;

&lt;h4&gt;
  
  
  Framer Motion
&lt;/h4&gt;

&lt;p&gt;Framer Motion is a declarative animation library for React, enabling developers to create smooth and interactive animations without writing complex CSS code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion: Embracing Innovation and Building Modern Web Applications
&lt;/h3&gt;

&lt;p&gt;The React.js ecosystem continues to evolve at a rapid pace, driven by the collective efforts of a passionate community of developers. With the advancements in Next.js 14 and the emergence of innovative open-source projects, developers have access to a powerful toolkit for building modern, performant, and user-friendly web applications. By embracing these advancements and staying abreast of the latest trends, developers can confidently navigate the ever-evolving landscape of web development and create exceptional digital experiences.&lt;/p&gt;

</description>
      <category>react</category>
      <category>nextjs</category>
      <category>webdev</category>
      <category>typescript</category>
    </item>
  </channel>
</rss>
