<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Asim khan</title>
    <description>The latest articles on Forem by Asim khan (@asim_khan_cbe65e41bcbbc65).</description>
    <link>https://forem.com/asim_khan_cbe65e41bcbbc65</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%2F1968096%2F2afb10e0-3abb-4c7e-b577-4302614e2b07.png</url>
      <title>Forem: Asim khan</title>
      <link>https://forem.com/asim_khan_cbe65e41bcbbc65</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/asim_khan_cbe65e41bcbbc65"/>
    <language>en</language>
    <item>
      <title>How to Add 100% Free Support Chat to Your Application with Tawk.to</title>
      <dc:creator>Asim khan</dc:creator>
      <pubDate>Thu, 31 Oct 2024 19:41:14 +0000</pubDate>
      <link>https://forem.com/asim_khan_cbe65e41bcbbc65/how-to-add-100-free-support-chat-to-your-application-with-tawkto-9ja</link>
      <guid>https://forem.com/asim_khan_cbe65e41bcbbc65/how-to-add-100-free-support-chat-to-your-application-with-tawkto-9ja</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Providing support chat on your website or application can greatly enhance user experience by offering real-time assistance and quick answers to customer questions. Tawk.to is a free tool that allows you to easily add support chat functionality to your application or website without any additional costs. This guide walks you through each step to integrate Tawk.to with your site, customize the chat widget, and explore its free and paid features.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhzttj898l9frfjwlssqx.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhzttj898l9frfjwlssqx.jpeg" alt="Image description" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Sign Up on Tawk.to
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Visit Tawk.to:&lt;/em&gt;&lt;/strong&gt; Go to &lt;a href="https://www.tawk.to/" rel="noopener noreferrer"&gt;Tawk.to&lt;/a&gt; and click Sign Up Free.&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Complete Registration:&lt;/em&gt;&lt;/strong&gt; Provide your email, name, and create a password.&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Verify Your Email:&lt;/em&gt;&lt;/strong&gt; If prompted, complete email verification to secure your account.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 2: Set Up Your Chat Widget
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Log In to Tawk.to:&lt;/strong&gt;  After signing in, click Add Property to create a new property (typically, this is your website).&lt;/p&gt;

&lt;p&gt;Enter Property Details:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Property Name:&lt;/strong&gt;  Typically, this is the name of your website.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;URL:&lt;/strong&gt; Add the URL for your website.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Category:&lt;/strong&gt; Choose the relevant category for your website or application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Complete Setup:&lt;/strong&gt; Click Next and then Done to finalize the setup of your property.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgyjv2olwntmy2wa73cgj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgyjv2olwntmy2wa73cgj.png" alt="Image description" width="800" height="396"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 3: Get the JavaScript Code
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Retrieve Widget Code:&lt;/strong&gt; After setting up the property, Tawk.to will generate a JavaScript code snippet for the chat widget.&lt;br&gt;
Copy Code: This code snippet will be added to your website’s HTML.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!-- Start of Tawk.to Live Chat Script --&amp;gt;
&amp;lt;script type="text/javascript"&amp;gt;
var Tawk_API=Tawk_API||{}, Tawk_LoadStart=new Date();
(function(){
    var s1=document.createElement("script"),s0=document.getElementsByTagName("script")[0];
    s1.async=true;
    s1.src='https://embed.tawk.to/YOUR_UNIQUE_PROPERTY_ID/default';
    s1.charset='UTF-8';
    s1.setAttribute('crossorigin','*');
    s0.parentNode.insertBefore(s1,s0);
})();
&amp;lt;/script&amp;gt;
&amp;lt;!-- End of Tawk.to Live Chat Script --&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4: Add the Tawk.to Code to Your Website&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;For an HTML Website&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Open HTML File:&lt;/strong&gt; Access your website’s HTML file.&lt;br&gt;
Insert Code: Paste the Tawk.to code snippet just before the closing &lt;/p&gt;

</description>
      <category>chatgpt</category>
      <category>nextjs</category>
      <category>typescript</category>
      <category>coding</category>
    </item>
    <item>
      <title>WordPress Co-Founder Matt Mullenweg Declares WP Engine a 'Cancer' – Is Your Hosting Provider Hurting the Community?</title>
      <dc:creator>Asim khan</dc:creator>
      <pubDate>Thu, 26 Sep 2024 17:18:59 +0000</pubDate>
      <link>https://forem.com/asim_khan_cbe65e41bcbbc65/wordpress-co-founder-matt-mullenweg-declares-wp-engine-a-cancer-is-your-hosting-provider-hurting-the-community-di</link>
      <guid>https://forem.com/asim_khan_cbe65e41bcbbc65/wordpress-co-founder-matt-mullenweg-declares-wp-engine-a-cancer-is-your-hosting-provider-hurting-the-community-di</guid>
      <description>&lt;h2&gt;
  
  
  Introduction:
&lt;/h2&gt;

&lt;p&gt;In a fiery confrontation that’s sent shockwaves through the WordPress ecosystem, Automattic CEO and WordPress co-founder Matt Mullenweg has launched a scathing attack on WP Engine, labeling the company a “cancer” to WordPress. This bold accusation, made during his keynote at WordCamp US 2024, reveals deep frustrations over what Mullenweg perceives as WP Engine’s exploitation of the open-source WordPress project. This isn’t the first time Mullenweg has criticized companies profiting from WordPress, but his latest tirade against WP Engine has been particularly severe — and it’s igniting fierce debate within the community.&lt;/p&gt;

&lt;p&gt;Let’s dive into the core of this conflict and why Mullenweg believes WP Engine is harming WordPress, a platform that powers over 40% of the web.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F67xfcr034f5kv2ncgvwm.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F67xfcr034f5kv2ncgvwm.jpg" alt="Image description" width="275" height="183"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Open Source Struggle: What’s Behind the Feud?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Mullenweg’s issue with WP Engine centers around the company’s business model, which profits from providing managed WordPress hosting services. According to Mullenweg, while businesses like WP Engine capitalize on WordPress’s popularity, they fail to give back to the project in meaningful ways. Automattic, the company Mullenweg founded, donates 3,900 hours per week towards WordPress's growth, whereas WP Engine reportedly contributes only 40 hours, despite both companies generating around half a billion dollars in revenue annually.&lt;/p&gt;

&lt;p&gt;WP Engine’s limited contribution, Mullenweg argues, is symptomatic of a larger problem. Private equity investors, such as Silver Lake, which backs WP Engine, prioritize profits over the open-source values that WordPress was built on. “Silver Lake doesn’t give a dang about your open-source ideals,” Mullenweg said, urging WordPress users to consider switching to alternative hosting providers that contribute more to the ecosystem.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv2cnyzxy2asftii33wfc.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv2cnyzxy2asftii33wfc.jpg" alt="Image description" width="800" height="851"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;The Revisions Controversy: How WP Engine Limits Core WordPress Features&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One of Mullenweg’s key grievances against WP Engine is how the company limits WordPress’s built-in revision tracking feature. The WordPress platform is designed to store every change made by users, allowing them to roll back to previous versions of their content. However, WP Engine disables this feature by default, allowing only three revisions that are automatically deleted after 60 days.&lt;/p&gt;

&lt;p&gt;Mullenweg claims this restriction undermines the very purpose of WordPress, which is to protect and manage content. The decision to limit revisions, he argues, is driven by a desire to cut costs rather than serve users. "They disable revisions because it costs them more money to store the history of the changes in the database," Mullenweg contended. For users, this means losing the ability to recover valuable content — a move Mullenweg called a direct affront to WordPress’s core promise.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A Call to Action: Vote with Your Wallet&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Mullenweg didn’t stop at criticizing WP Engine’s practices. He went a step further, urging WordPress users to reconsider where they host their sites. He encouraged attendees to explore other hosting providers like Hostinger, Bluehost Cloud, and Pressable, which may offer better support and uphold the values of the open-source community.&lt;/p&gt;

&lt;p&gt;With growing concerns over private equity-backed companies like WP Engine prioritizing profits over community contributions, Mullenweg’s message is clear: “Vote with your wallet.” By choosing hosts that actively give back to the WordPress project, users can help ensure the platform remains sustainable for future generations.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4q79volujf1hz0u3fjgr.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4q79volujf1hz0u3fjgr.jpg" alt="Image description" width="500" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A Battle for the Future of WordPress&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This isn’t the first time Mullenweg has targeted companies for taking advantage of the open-source nature of WordPress. In previous remarks, he referred to GoDaddy as a “parasitic company” and an “existential threat to WordPress’ future” for similar reasons. However, his comments about WP Engine have escalated the rhetoric to a new level. By calling the company a “cancer,” Mullenweg is warning of the long-term risks of allowing companies that don't uphold WordPress’s founding principles to dominate the ecosystem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What’s Next? WP Engine Responds&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the wake of these explosive remarks, WP Engine’s legal team has sent a cease-and-desist letter to Automattic, refuting Mullenweg’s accusations and requesting that he retract his statements. It remains to be seen how this legal battle will unfold, but one thing is certain: Mullenweg’s comments have reignited a crucial conversation about the future of WordPress and its open-source ideals.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion: A Fight for the Soul of WordPress&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;At its core, the feud between Matt Mullenweg and WP Engine is about more than just hosting services — it’s about the future of WordPress and the importance of giving back to the open-source community. As users and businesses continue to build on WordPress’s foundation, this conflict raises important questions about who benefits most from the project and how to ensure its long-term sustainability.&lt;/p&gt;

&lt;p&gt;If you’re using WordPress, it might be time to ask yourself: who is really supporting the platform you rely on, and are they giving back enough to keep it alive for the next generation?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Take Action: Is It Time to Switch Hosting Providers?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When your hosting contract comes up for renewal, consider the values and practices of the company you’re supporting. Voting with your wallet could help sustain the future of WordPress.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdqf9vwsj4g6js8twi9js.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdqf9vwsj4g6js8twi9js.png" alt="Image description" width="800" height="793"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>wordpress</category>
      <category>godot</category>
      <category>devops</category>
      <category>development</category>
    </item>
    <item>
      <title>Join the Party: A Comprehensive Guide to SQL Joins with Examples</title>
      <dc:creator>Asim khan</dc:creator>
      <pubDate>Sun, 22 Sep 2024 14:59:59 +0000</pubDate>
      <link>https://forem.com/asim_khan_cbe65e41bcbbc65/join-the-party-a-comprehensive-guide-to-sql-joins-with-examples-511e</link>
      <guid>https://forem.com/asim_khan_cbe65e41bcbbc65/join-the-party-a-comprehensive-guide-to-sql-joins-with-examples-511e</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the world of database management, joining tables is a crucial operation that allows you to combine data from multiple tables into a single result set. SQL joins are used to retrieve data from two or more tables based on a related column between them. In this blog, we'll delve into the different types of SQL joins, including inner join, left join, right join, and outer join, along with examples to help you understand the concepts better.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2pw4k8g2ikn4yjt1quyk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2pw4k8g2ikn4yjt1quyk.png" alt="Image description" width="446" height="327"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a SQL Join?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A SQL join is a clause used to combine rows from two or more tables based on a related column between them. The join condition is specified in the ON clause, which defines the relationship between the tables. The result of a join operation is a new table that contains columns from both tables.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqx6eme0rbddp4uidu37c.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqx6eme0rbddp4uidu37c.jpg" alt="Image description" width="540" height="675"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Types of SQL Joins&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Inner Join&lt;/strong&gt;&lt;br&gt;
An inner join returns only the rows that have a match in both tables. It combines rows from two or more tables where the join condition is met.&lt;/p&gt;

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

&lt;p&gt;Suppose we have two tables, Customers and Orders, and we want to retrieve the customer names and their corresponding order details.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Customers table:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CustomerID  CustomerName
1           John Smith
2           Jane Doe
3           Bob Brown
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Orders table:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;OrderID CustomerID  OrderDate
1   1           2022-01-01
2   1           2022-01-15
3   2           2022-02-01
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Inner Join:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT Customers.CustomerName, Orders.OrderDate
FROM Customers
INNER JOIN Orders
ON Customers.CustomerID = Orders.CustomerID;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CustomerName    OrderDate
John Smith  2022-01-01
John Smith  2022-01-15
Jane Doe    2022-02-01
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyorcgo60m9eu3g0ov611.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyorcgo60m9eu3g0ov611.jpg" alt="Image description" width="800" height="449"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;2. Left Join (or Left Outer Join)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A left join returns all the rows from the left table and the matching rows from the right table. If there are no matches, the result will contain null values for the right table columns.&lt;/p&gt;

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

&lt;p&gt;Using the same Customers and Orders tables, let's retrieve all customers, even if they don't have any orders.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Left Join:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT Customers.CustomerName, Orders.OrderDate
FROM Customers
LEFT JOIN Orders
ON Customers.CustomerID = Orders.CustomerID;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Result:

CustomerName    OrderDate
John Smith  2022-01-01
John Smith  2022-01-15
Jane Doe    2022-02-01
Bob Brown   null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Right Join (or Right Outer Join)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A right join is similar to a left join, but it returns all the rows from the right table and the matching rows from the left table. If there are no matches, the result will contain null values for the left table columns.&lt;/p&gt;

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

&lt;p&gt;Using the same Customers and Orders tables, let's retrieve all orders, even if there is no matching customer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Right Join:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT Customers.CustomerName, Orders.OrderDate
FROM Customers
RIGHT JOIN Orders
ON Customers.CustomerID = Orders.CustomerID;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Result:

CustomerName    OrderDate
John Smith  2022-01-01
John Smith  2022-01-15
Jane Doe    2022-02-01
null            2022-03-01
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Left Join with Null&lt;/strong&gt;&lt;br&gt;
A left join with null returns all the rows from the left table where the join condition is not met, i.e., where the right table columns are null.&lt;/p&gt;

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

&lt;p&gt;Using the same Customers and Orders tables, let's retrieve all customers who don't have any orders.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Left Join with Null:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT Customers.CustomerName
FROM Customers
LEFT JOIN Orders
ON Customers.CustomerID = Orders.CustomerID
WHERE Orders.CustomerID IS NULL;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CustomerName
Bob Brown
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Right Join with Null&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A right join with null returns all the rows from the right table where the join condition is not met, i.e., where the left table columns are null.&lt;/p&gt;

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

&lt;p&gt;Using the same Customers and Orders tables, let's retrieve all orders that don't have a matching customer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Right Join with Null:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT Orders.OrderDate
FROM Customers
RIGHT JOIN Orders
ON Customers.CustomerID = Orders.CustomerID
WHERE Customers.CustomerID IS NULL;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;OrderDate
2022-03-01
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6. Full Outer Join&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A full outer join returns all rows from both tables, with null values in the columns where there are no matches.&lt;/p&gt;

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

&lt;p&gt;Using the same Customers and Orders tables, let's retrieve all customers and orders, even if there are no matches.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Full Outer Join:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
SELECT Customers.CustomerName, Orders.OrderDate
FROM Customers
FULL OUTER JOIN Orders
ON Customers.CustomerID = Orders.CustomerID;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CustomerName    OrderDate
John Smith  2022-01-01
John Smith  2022-01-15
Jane Doe    2022-02-01
Bob Brown   null
null            2022-03-01
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;In this blog, we've explored the different types of SQL joins, including inner join, left join, right join, and outer join, along with examples to help you understand the concepts better. By mastering these join operations, you'll be able to retrieve data from multiple tables and perform complex queries with ease. Remember to practice these examples and experiment with different join operations to become proficient in SQL joins.&lt;/p&gt;

&lt;h2&gt;
  
  
  if you still have any confusion
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2vajxg9nyrakwnzxxp6n.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2vajxg9nyrakwnzxxp6n.jpg" alt="Image description" width="480" height="478"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  still then
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsz8w1foli8714wg4jyoi.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsz8w1foli8714wg4jyoi.jpg" alt="Image description" width="246" height="205"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>sql</category>
      <category>database</category>
      <category>sqlserver</category>
    </item>
    <item>
      <title>Understanding String vs string in TypeScript</title>
      <dc:creator>Asim khan</dc:creator>
      <pubDate>Thu, 19 Sep 2024 16:02:01 +0000</pubDate>
      <link>https://forem.com/asim_khan_cbe65e41bcbbc65/understanding-string-vs-string-in-typescript-4o7p</link>
      <guid>https://forem.com/asim_khan_cbe65e41bcbbc65/understanding-string-vs-string-in-typescript-4o7p</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj3y0bi59neoh8pp85nfe.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj3y0bi59neoh8pp85nfe.jpeg" alt="Image description" width="300" height="168"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In TypeScript, you may encounter two seemingly similar types: String and string. Although they might appear interchangeable at first glance, they serve different purposes and have distinct characteristics. Here's a detailed breakdown to help clarify the differences and guide you on best practices.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Basics: string vs String
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;string (Primitive Type):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;string is the primitive type in TypeScript and JavaScript for handling textual data. It is used to define variables, function parameters, and return values that will hold text.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let message: string = "Hello, World!";

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;String (Wrapper Object):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;String is a global object in JavaScript that wraps the primitive string type. You can use it to create string objects with additional methods.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let message: String = new String("Hello, World!");

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Key Differences
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Primitive vs Object:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;string is a primitive type and represents the raw textual data. It is simple and efficient.&lt;/li&gt;
&lt;li&gt;String is an object wrapper around the primitive string. It provides methods and properties that are not available on the primitive type.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;The string type is used with literals and does not require the new keyword.&lt;/li&gt;
&lt;li&gt;The String object requires the new keyword and can be instantiated like this
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let obj: String = new String("Hello");

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Usage and Compatibility:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;TypeScript encourages the use of string rather than String for defining variables. This is because string is a more efficient and straightforward way to work with textual data.&lt;/li&gt;
&lt;li&gt;TypeScript will generally convert between string and String when necessary, but this can lead to unexpected issues. For example:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let a: String = "test"; // This uses the String object
let b: string = "another test"; // This uses the primitive string

a = b; // This is allowed
b = a; // This causes a TypeScript compiler error

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

&lt;/div&gt;



&lt;p&gt;The error occurs because string and String are not directly interchangeable. TypeScript distinguishes between the primitive type &lt;br&gt;
string and the object type String.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6ya3lrw6r7da4uihfab6.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6ya3lrw6r7da4uihfab6.jpg" alt="Image description" width="700" height="468"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Best Practices&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use string for Textual Data:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Stick to string for declaring variables, parameters, and return types in TypeScript. It is more common and aligns with JavaScript practices.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let name: string = "Alice";

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Avoid Using String Object:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Avoid using the String object for most cases. It's usually unnecessary and can lead to confusion or bugs in TypeScript. Use string literals instead.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let name: string = "Bob"; // Preferred
let nameObj: String = new String("Bob"); // Less preferred

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Conversion Between Types:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you need to convert between string and String, be aware of the potential issues. Use methods like toString() to convert String objects back to primitive strings:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let strObj: String = new String("example");
let primitiveStr: string = strObj.toString(); // Convert to primitive string

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

&lt;/div&gt;



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

&lt;p&gt;In summary, string is the preferred way to handle text in TypeScript due to its simplicity and alignment with JavaScript primitives. The String object, while valid, is generally not necessary for most use cases and can introduce complexity. By understanding these differences, you can write cleaner, more effective TypeScript code and avoid common pitfalls.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft3ncrypkcf02qbsxlcdp.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft3ncrypkcf02qbsxlcdp.jpeg" alt="Image description" width="217" height="233"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>react</category>
      <category>developers</category>
    </item>
    <item>
      <title>SSR in Next.js 14: What’s New in App Routing Compared to Page Routing</title>
      <dc:creator>Asim khan</dc:creator>
      <pubDate>Sun, 15 Sep 2024 16:33:33 +0000</pubDate>
      <link>https://forem.com/asim_khan_cbe65e41bcbbc65/understanding-nextjs-page-routing-vs-app-routing-and-ssr-changes-in-nextjs-14-2cge</link>
      <guid>https://forem.com/asim_khan_cbe65e41bcbbc65/understanding-nextjs-page-routing-vs-app-routing-and-ssr-changes-in-nextjs-14-2cge</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi0sqv3adwsqnfmj8711w.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi0sqv3adwsqnfmj8711w.jpg" alt="Image description" width="620" height="497"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;&lt;em&gt;Introduction&lt;/em&gt;&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Next.js has long been a popular choice for building server-rendered React applications. With its built-in support for Server-Side Rendering (SSR), developers can create dynamic, SEO-friendly applications. However, the introduction of the App Router in Next.js 13 and the refinements in Next.js 14 have simplified and enhanced SSR significantly.&lt;/p&gt;

&lt;p&gt;In this blog post, we'll explore the differences in SSR between the traditional Page Routing system and the newer App Routing system, highlighting how SSR works and how it's changed with the new routing paradigm.&lt;/p&gt;

&lt;h2&gt;
  
  
  SSR in Page Routing (Pre-Next.js 13)
&lt;/h2&gt;

&lt;p&gt;Before the App Router was introduced, SSR was handled in the Page Routing system using specific functions like getServerSideProps. This function was called on every request, allowing developers to fetch data server-side before rendering the page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Example of SSR in Page Routing using getServerSideProps:&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export default function Blogs({ data }) {
  // Render the fetched data
  return (
    &amp;lt;div&amp;gt;
      {data.map((item) =&amp;gt; (
        &amp;lt;div key={item.id}&amp;gt;
          &amp;lt;h3&amp;gt;{item.title}&amp;lt;/h3&amp;gt;
          &amp;lt;p&amp;gt;{item.content}&amp;lt;/p&amp;gt;
        &amp;lt;/div&amp;gt;
      ))}
    &amp;lt;/div&amp;gt;
  );
}

// This function runs on every request
export async function getServerSideProps() {
  // Fetch data from an external API
  const res = await fetch('https://api.example.com/blogs');
  const data = await res.json();

  // Pass the data as props to the page component
  return { props: { data } };
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, getServerSideProps is the key to SSR in the Page Routing system. It allows you to fetch data from an API (or any other data source) on every request, and pass it to the page component as props. This pattern, while powerful, can result in complex codebases when handling a lot of server-side logic and different routes.&lt;/p&gt;

&lt;h2&gt;
  
  
  App Routing and SSR in Next.js 14
&lt;/h2&gt;

&lt;p&gt;With Next.js 14, SSR has become more streamlined and integrated into the App Routing system. This new system introduces Server Components and Client Components, where SSR is much more intuitive.&lt;/p&gt;

&lt;p&gt;In App Routing, you can now directly fetch data inside components without needing special functions like getServerSideProps. You can achieve this by using server actions, which makes the code simpler and easier to maintain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of SSR in App Routing with Server Components:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"use server";

export async function getBlogs() {
  try {
    const response = await fetch('https://api.example.com/posts');
    return response.json();
  } catch (error) {
    return { error: error.message };
  }
}

// This component runs on the server and fetches data
export default async function Blog() {
  const blogs = await getBlogs();

  return (
    &amp;lt;div&amp;gt;
      {(blogs || []).map((blog) =&amp;gt; (
        &amp;lt;div key={blog._id}&amp;gt;
          &amp;lt;h3&amp;gt;{blog.name}&amp;lt;/h3&amp;gt;
          &amp;lt;p&amp;gt;{blog.content}&amp;lt;/p&amp;gt;
        &amp;lt;/div&amp;gt;
      ))}
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this App Routing example, we’re using a Server Component to fetch data directly inside the component file using use server. This removes the need for separate API routes or functions like &lt;em&gt;getServerSideProps&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;The Power of Server Actions&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Next.js 14 simplifies the process by introducing server actions. These actions allow you to directly fetch and process data within the component file, reducing complexity and making your codebase more maintainable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Key Benefits of server actions:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cleaner Code:&lt;/strong&gt; Instead of scattering server-side logic in separate files or functions, you can keep everything in one place.&lt;br&gt;
Improved Maintainability: Fewer moving parts mean less code to manage, making your application easier to maintain.&lt;br&gt;
&lt;strong&gt;Better Performance:&lt;/strong&gt; With intelligent caching mechanisms, you can fine-tune your server-side logic for optimal performance.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj4ub3dbg7fkne1adg45f.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj4ub3dbg7fkne1adg45f.jpg" alt="Image description" width="227" height="222"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Hydration in Next.js
&lt;/h2&gt;

&lt;p&gt;In the context of Next.js and server-side rendering (SSR), hydration refers to the process where a statically-rendered HTML page (sent from the server) is converted into a fully interactive React application in the browser. It "hydrates" the static HTML with React's client-side JavaScript to make the page interactive.&lt;/p&gt;
&lt;h2&gt;
  
  
  Hydration in App Routing vs Page Routing
&lt;/h2&gt;

&lt;p&gt;In Page Routing, hydration is required for every component on the page, making it interactive on the client side. This means all the JavaScript needed for interactions is shipped to the client, which can lead to performance bottlenecks as the application scales.&lt;/p&gt;

&lt;p&gt;In App Routing, with Server Components, only the Client Components (those that handle interactivity) are hydrated. This selective hydration reduces the amount of JavaScript sent to the client, resulting in improved performance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of Client Components in App Routing:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'use client';  // Mark this as a client component

export default function Button() {
  return (
    &amp;lt;button onClick={() =&amp;gt; alert('Button clicked!')}&amp;gt;Click Me&amp;lt;/button&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, the Button component is marked as a Client Component with 'use client'. It allows for interactivity and runs on the client side, while other non-interactive components remain as Server Components, improving performance.&lt;/p&gt;

&lt;h2&gt;
  
  
  More About hydration in App Routing
&lt;/h2&gt;

&lt;p&gt;Here's how it works:&lt;/p&gt;

&lt;h2&gt;
  
  
  Parent Components as Server Components:
&lt;/h2&gt;

&lt;p&gt;The parent components (usually the higher-level components or entire page components) are typically Server Components. They run on the server and handle things like data fetching, rendering static HTML, and passing that data down to child components.&lt;br&gt;
Since these are server-rendered, they do not include any JavaScript on the client-side, and they are not interactive.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Client Components for Interactivity:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Child components, which handle interactivity (like buttons, forms, etc.), are Client Components. These components can use React hooks (useState, useEffect, etc.) and are hydrated on the client-side.&lt;br&gt;
Server Components pass data to these Client Components via props.&lt;br&gt;
Once the HTML is loaded in the browser, Next.js hydrates the Client Components, attaching the necessary event listeners and making the page interactive.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Server Component (Parent Component)
export default async function ParentComponent() {
  // Fetch data on the server
  const data = await fetch('https://api.example.com/data').then(res =&amp;gt; res.json());

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;h1&amp;gt;This is Server-Side Rendered&amp;lt;/h1&amp;gt;
      &amp;lt;ClientComponent data={data} /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

// Client Component (Child Component)
'use client';

import { useState } from 'react';

function ClientComponent({ data }) {
  const [count, setCount] = useState(0);

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;p&amp;gt;Data from server: {JSON.stringify(data)}&amp;lt;/p&amp;gt;
      &amp;lt;p&amp;gt;Client-side counter: {count}&amp;lt;/p&amp;gt;
      &amp;lt;button onClick={() =&amp;gt; setCount(count + 1)}&amp;gt;Increment&amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

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

&lt;/div&gt;



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

&lt;p&gt;Next.js 14 makes Server-Side Rendering (SSR) easier and more powerful with the introduction of server actions in the App Router. By allowing developers to fetch data directly inside component files, this new system streamlines server-side logic, simplifies codebases, and reduces the need for separate API routes. Coupled with selective hydration, SSR in Next.js 14 is now faster and more efficient, helping you build highly dynamic and SEO-friendly applications with ease.&lt;/p&gt;

&lt;p&gt;By leveraging these server actions, you can improve your app’s performance while keeping your code clean and maintainable. The shift from Page Routing to App Routing with Server and Client Components represents a major leap forward in building scalable web applications.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxzlyfnogc19jxoog98tw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxzlyfnogc19jxoog98tw.jpeg" alt="Image description" width="526" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>nextjs</category>
      <category>next14</category>
      <category>typescript</category>
    </item>
    <item>
      <title>The Power of exec() in Mongoose: Unlocking Better Query Execution</title>
      <dc:creator>Asim khan</dc:creator>
      <pubDate>Tue, 10 Sep 2024 18:31:55 +0000</pubDate>
      <link>https://forem.com/asim_khan_cbe65e41bcbbc65/the-power-of-exec-in-mongoose-unlocking-better-query-execution-17fd</link>
      <guid>https://forem.com/asim_khan_cbe65e41bcbbc65/the-power-of-exec-in-mongoose-unlocking-better-query-execution-17fd</guid>
      <description>&lt;p&gt;When working with MongoDB in a Node.js environment, Mongoose is a popular ODM (Object Data Modeling) library that provides a straightforward, schema-based solution to model your application data. One common question developers encounter when using Mongoose is the role of the exec() method in queries, especially when combined with findOne, find, and asynchronous operations.&lt;/p&gt;

&lt;p&gt;In this blog post, we'll delve into what the exec() method does in Mongoose, explore how it compares to using callbacks and Promises, and discuss best practices for executing queries effectively.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction to Mongoose Queries
&lt;/h2&gt;

&lt;p&gt;Mongoose provides various methods to interact with your MongoDB collections. Among these, methods like find(), findOne(), update(), and others allow you to perform CRUD (Create, Read, Update, Delete) operations. These methods accept query conditions and can be executed using callbacks, Promises, or the exec() function.&lt;/p&gt;

&lt;p&gt;Understanding how to effectively execute these queries is crucial for writing clean, efficient, and maintainable code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Callbacks vs. exec()
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Using Callbacks&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Traditionally, Mongoose queries have been executed using callbacks. A callback is a function passed as an argument to another function, which is invoked once an asynchronous operation completes.&lt;/p&gt;

&lt;p&gt;Here's an example using a callback with findOne:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User.findOne({ name: 'daniel' }, function (err, user) {
  if (err) {
    // Handle error
  } else {
    // Use the retrieved user
  }
});

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

&lt;/div&gt;



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

&lt;ol&gt;
&lt;li&gt;User.findOne searches for a user with the name 'daniel'.&lt;/li&gt;
&lt;li&gt;The callback function handles the result or any potential error.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;&lt;em&gt;Using exec()&lt;/em&gt;&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Alternatively, Mongoose queries can be executed using the exec() method, which provides more flexibility, especially when working with Promises.&lt;/p&gt;

&lt;p&gt;Here's how you can use exec() with findOne:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User.findOne({ name: 'daniel' }).exec(function (err, user) {
  if (err) {
    // Handle error
  } else {
    // Use the retrieved user
  }
});

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

&lt;/div&gt;



&lt;p&gt;In this case:&lt;br&gt;
The exec() method executes the query.&lt;br&gt;
It accepts a callback similar to the one used directly with findOne.&lt;br&gt;
While both approaches achieve the same outcome, using exec() becomes particularly beneficial when integrating with Promises or async/await syntax.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;em&gt;&lt;strong&gt;Promises and Async/Await in Mongoose&lt;/strong&gt;&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;With the advent of Promises and the async/await syntax in JavaScript, handling asynchronous operations has become more streamlined and readable. Mongoose supports these modern patterns, but it's essential to understand how they interplay with the exec() method.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Thenables vs. Promises&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Mongoose queries return "thenables," which are objects that have a .then() method but are not full-fledged Promises. This distinction is subtle but important:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Using await without exec()
const user = await UserModel.findOne({ name: 'daniel' });

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

&lt;/div&gt;



&lt;p&gt;Here, UserModel.findOne() returns a thenable. While you can use await or .then() with it, it doesn't possess all the features of a native Promise.&lt;/p&gt;

&lt;p&gt;To obtain a true Promise, you can use the exec() method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Using await with exec()
const user = await UserModel.findOne({ name: 'daniel' }).exec();

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

&lt;/div&gt;



&lt;p&gt;In this case, exec() returns a native Promise, ensuring better compatibility and functionality.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flgy6b4u2t6h58ivxbfnn.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flgy6b4u2t6h58ivxbfnn.jpg" alt="Image description" width="225" height="225"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Benefits of Using exec() with Async/Await&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Consistent Promise Behavior: Using exec() ensures you're working with native Promises, providing better consistency across your codebase.&lt;/p&gt;

&lt;p&gt;Enhanced Stack Traces: When errors occur, using exec() can provide more detailed stack traces, making debugging easier.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;&lt;em&gt;Why Use exec()?&lt;/em&gt;&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Given that you can perform queries without exec() and still use await, you might wonder why exec() is necessary. Here are the primary reasons:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Promise Compatibility:&lt;/strong&gt; As mentioned earlier, exec() returns a native Promise, which can be beneficial for integration with other Promise-based libraries or for ensuring consistent Promise behavior.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Improved Error Handling:&lt;/strong&gt; exec() provides better stack traces when errors occur, aiding in debugging and maintaining your application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Clarity and Explicitness:&lt;/strong&gt; Using exec() makes it clear that the query is being executed, enhancing code readability.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Code Examples&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Let's explore some code examples to illustrate the differences and benefits of using callbacks, exec(), and async/await with Mongoose.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using Callbacks&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Callback approach
User.findOne({ name: 'daniel' }, function (err, user) {
  if (err) {
    console.error('Error fetching user:', err);
    return;
  }
  console.log('User found:', user);
});

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

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;Using exec() with Callbacks&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// exec() with callback
User.findOne({ name: 'daniel' }).exec(function (err, user) {
  if (err) {
    console.error('Error fetching user:', err);
    return;
  }
  console.log('User found:', user);
});

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Using Promises with exec()&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// exec() returns a promise
User.findOne({ name: 'daniel' })
  .exec()
  .then(user =&amp;gt; {
    console.log('User found:', user);
  })
  .catch(err =&amp;gt; {
    console.error('Error fetching user:', err);
  });

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Using Async/Await with exec()&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// async/await with exec()
async function getUser() {
  try {
    const user = await User.findOne({ name: 'daniel' }).exec();
    console.log('User found:', user);
  } catch (err) {
    console.error('Error fetching user:', err);
  }
}

getUser();

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Using Async/Await without exec()&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// async/await without exec()
async function getUser() {
  try {
    const user = await User.findOne({ name: 'daniel' });
    console.log('User found:', user);
  } catch (err) {
    console.error('Error fetching user:', err);
  }
}

getUser();

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

&lt;/div&gt;



&lt;p&gt;Note: Both async/await examples will work, but using exec() provides a native Promise and better stack traces in case of errors.&lt;/p&gt;

&lt;h2&gt;
  
  
  Best Practices
&lt;/h2&gt;

&lt;p&gt;To ensure your Mongoose queries are efficient, maintainable, and error-resistant, consider the following best practices:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use exec() with Promises and Async/Await:&lt;/strong&gt; For better compatibility and clearer code, prefer using exec() when working with Promises or async/await.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Handle Errors Gracefully:&lt;/strong&gt; Always implement proper error handling to catch and manage potential issues during database operations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Consistent Query Execution:&lt;/strong&gt; Maintain consistency in how you execute queries throughout your codebase. Mixing callbacks and Promises can lead to confusion and harder-to-maintain code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Leverage Modern JavaScript Features:&lt;/strong&gt; Utilize async/await for more readable and manageable asynchronous code, especially in complex applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Understand Thenables vs. Promises:&lt;/strong&gt; Be aware of the differences between thenables and native Promises to prevent unexpected behaviors in your application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Optimize Query Performance:&lt;/strong&gt; Ensure your queries are optimized for performance, especially when dealing with large datasets or complex conditions.&lt;/p&gt;

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

&lt;p&gt;Mongoose's exec() method plays a crucial role in executing queries, especially when working with modern JavaScript patterns like Promises and async/await. While you can perform queries without exec(), using it provides better compatibility, improved error handling, and more explicit code execution. By understanding the differences between callbacks, exec(), and Promises, you can write more efficient and maintainable Mongoose queries in your Node.js applications.&lt;/p&gt;

&lt;p&gt;Adopting best practices, such as consistently using exec() with Promises and async/await, will enhance the reliability and readability of your code, making your development process smoother and your applications more robust.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Happy coding!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0ivee2u0cdyuzbuhulkn.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0ivee2u0cdyuzbuhulkn.jpg" alt="Image description" width="360" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>mongodb</category>
      <category>javascript</category>
      <category>mongoose</category>
      <category>webdev</category>
    </item>
    <item>
      <title>The Trap of Social Media: How Technology Shapes Our Lives</title>
      <dc:creator>Asim khan</dc:creator>
      <pubDate>Tue, 03 Sep 2024 22:01:03 +0000</pubDate>
      <link>https://forem.com/asim_khan_cbe65e41bcbbc65/the-trap-of-social-media-how-technology-shapes-our-lives-1c7o</link>
      <guid>https://forem.com/asim_khan_cbe65e41bcbbc65/the-trap-of-social-media-how-technology-shapes-our-lives-1c7o</guid>
      <description>&lt;p&gt;In today's digital age, social media has become an integral part of our lives, influencing how we interact, think, and even how we perceive ourselves. While these platforms offer convenience, connectivity, and entertainment, they also present a subtle trap—one built on lust, greed, and addiction. This trap is intricately designed by technology companies that have mastered the art of monetizing our attention.&lt;/p&gt;

&lt;p&gt;**_&lt;/p&gt;

&lt;h2&gt;
  
  
  The Business Model of Social Media: How Tech Giants Earn Money
&lt;/h2&gt;

&lt;p&gt;_**&lt;/p&gt;

&lt;p&gt;The fundamental business model of social media platforms revolves around user data. These companies provide services that give us pleasure, convenience, and a sense of connection. However, the real currency of this transaction is not the services themselves but the data we generate while using them. As the saying goes, "If you are not paying for the product, then you are the product."&lt;/p&gt;

&lt;p&gt;Every interaction, click, and scroll is meticulously tracked and analyzed. This data is then sold to advertisers who are eager to place their products in front of the most receptive audiences. Companies like Google and Facebook have become experts at this, creating detailed profiles of users based on their online behavior. These profiles allow advertisers to target users with ads that are tailored to their specific interests, desires, and even vulnerabilities.&lt;/p&gt;

&lt;p&gt;**_&lt;/p&gt;

&lt;h2&gt;
  
  
  The Competition for Attention
&lt;/h2&gt;

&lt;p&gt;_**&lt;/p&gt;

&lt;p&gt;Social media platforms are in a relentless competition for user attention. The more time we spend on their apps, the more data they can collect, and the more ads they can sell. This leads to the development of features specifically designed to keep us engaged, often without us even realizing it. For example, the "typing..." indicator in messaging apps creates anticipation, encouraging us to stay longer and remain engaged in conversations.&lt;/p&gt;

&lt;p&gt;This competition for attention has profound implications for our lives. The content we consume on social media is not neutral; it is carefully curated to keep us engaged. Over time, this shapes our thoughts, beliefs, and behaviors. While we might not notice the effects immediately, they accumulate gradually, influencing our worldview and the decisions we make.&lt;/p&gt;

&lt;p&gt;**_&lt;/p&gt;

&lt;h2&gt;
  
  
  The Cost of Convenience: The Illusion of Freedom
&lt;/h2&gt;

&lt;p&gt;_**&lt;/p&gt;

&lt;p&gt;One of the most concerning aspects of social media is the illusion of freedom it creates. We believe we are in control of our choices, but in reality, our behavior is being subtly influenced by algorithms designed to predict and manipulate our actions. Just as magicians understand human behavior to create illusions, tech companies use data to create the illusion of choice and control.&lt;/p&gt;

&lt;p&gt;As we interact with our devices, our every move is being watched. Social media platforms track what we view, how long we view it, and even how we interact with content. This data is then used to build detailed profiles, allowing these companies to predict our future behavior with remarkable accuracy. The result is a digital environment where we are constantly being nudged in directions that benefit advertisers and tech companies, often at the expense of our own well-being.&lt;/p&gt;

&lt;p&gt;**_&lt;/p&gt;

&lt;h2&gt;
  
  
  Social Media and Political Influence
&lt;/h2&gt;

&lt;p&gt;_**&lt;/p&gt;

&lt;p&gt;The influence of social media extends beyond individual lives and into the political sphere. In Pakistan, as in many other countries, social media has played a significant role in shaping political discourse and public opinion. Political parties use these platforms to reach voters, spread their messages, and mobilize support. However, the same tools can also be used to spread misinformation and manipulate public opinion.&lt;/p&gt;

&lt;p&gt;The question of whether humans genuinely desire peace is complex, but social media certainly has the power to amplify conflict. It can create echo chambers where people are exposed only to information that reinforces their existing beliefs, leading to increased polarization and division. This has been seen in various contexts, including the allegations of Russian interference in elections through digital means.&lt;/p&gt;

&lt;p&gt;**_&lt;/p&gt;

&lt;h2&gt;
  
  
  The Uncertain Truth of the Digital Age
&lt;/h2&gt;

&lt;p&gt;_**&lt;/p&gt;

&lt;p&gt;In the digital age, the concept of truth has become increasingly elusive. With so many people holding different beliefs and ideologies, it is difficult to determine what is truly factual. Social media platforms like Google and Facebook do not have the capacity to discern absolute truth; they simply present content based on algorithms that prioritize engagement over accuracy. This makes it more important than ever to approach social media with caution and critical thinking.&lt;/p&gt;

&lt;p&gt;**_&lt;/p&gt;

&lt;h2&gt;
  
  
  embed Conclusion: The Need for Vigilance
&lt;/h2&gt;

&lt;p&gt;_**&lt;/p&gt;

&lt;p&gt;As we navigate the complexities of the digital world, it is crucial to remain vigilant. Social media offers incredible opportunities for connection and information, but it also poses significant risks. We must be aware of how these platforms shape our lives, influence our thoughts, and potentially manipulate our actions. In the end, we are all participants in a vast experiment—one where the stakes are our freedom, privacy, and ultimately, our humanity.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Solving the "Punycode Module is Deprecated" Issue in Node.js</title>
      <dc:creator>Asim khan</dc:creator>
      <pubDate>Fri, 23 Aug 2024 23:14:41 +0000</pubDate>
      <link>https://forem.com/asim_khan_cbe65e41bcbbc65/solving-the-punycode-module-is-deprecated-issue-in-nodejs-2e59</link>
      <guid>https://forem.com/asim_khan_cbe65e41bcbbc65/solving-the-punycode-module-is-deprecated-issue-in-nodejs-2e59</guid>
      <description>&lt;p&gt;Hi everyone, my name is Asim Khan, and I am currently a full stack developer at Meta Melon. Recently, I encountered a frustrating issue while working on a project for &lt;a href="https://naseebi.com/" rel="noopener noreferrer"&gt;Naseebi.com&lt;/a&gt;, a matrimonial mobile and web application. The issue involved the deprecation of the punycode module in Node.js, and I want to share my experience and solution with you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Punycode
&lt;/h2&gt;

&lt;p&gt;Punycode is a way to convert international characters in domain names (like 你好.com) into a format compatible with the Domain Name System (DNS), which only understands ASCII characters. It ensures global accessibility for non-English domain names.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
Original (Unicode): müller.de&lt;br&gt;
Punycode (ASCII): xn--mller-kva.de&lt;br&gt;
When a user types müller.de, the browser converts it to xn--mller-kva.de so DNS can handle it.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Issue
&lt;/h2&gt;

&lt;p&gt;While working on the profile creation feature in the application, I encountered a 502 Bad Gateway error. After checking my server logs on AWS EC2, I found this warning:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The punycode module is deprecated. Please use a userland alternative instead. (Use node --trace-deprecation ... to show where the warning was created)

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

&lt;/div&gt;



&lt;p&gt;This was strange because I hadn't used punycode directly in my code. However, after inspecting my package-lock.json file, I found that it was included as a dependency somewhere in the project. My Node.js version at the time was v22.0.0. I tried downgrading to v20.9.0 and even v18.18.0, but the warning persisted.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding the Problem
&lt;/h2&gt;

&lt;p&gt;The punycode module was deprecated in Node.js version 21. To resolve this, I needed to replace it with the recommended userland alternative, punycode.js. However, simply installing the userland module didn't seem to help.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solutions and Workarounds
&lt;/h2&gt;

&lt;p&gt;Here are the steps I took to finally resolve the issue:&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Downgrade Node.js Version
&lt;/h2&gt;

&lt;p&gt;If you're not particular about using the latest Node.js version, a quick fix is to downgrade to a version before 21.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nvm install 20.5.1
nvm use 20.5.1

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Identify the Problematic Dependencies
&lt;/h2&gt;

&lt;p&gt;You can run npm ls punycode to identify which dependencies are still using punycode.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm ls punycode

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

&lt;/div&gt;



&lt;p&gt;In my case, the culprits were ajv and whatwg-url-without-unicode. I found these through the following steps:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Updating ajv: I updated ajv in my package.json file.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"overrides": {
  "ajv": "^8.17.1"
}

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

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Updating whatwg-url: I updated whatwg-url as well.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"overrides": {
  "ajv": "^8.17.1",
  "whatwg-url": "^14.0.0"
}

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

&lt;/div&gt;



&lt;p&gt;After these updates, the warning was gone. However, if the issue persists, you can use the following steps.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;3. Suppress the Warning (Temporary Fix)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You can suppress the warning in your package.json scripts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
  "start": "NODE_NO_WARNINGS=1 vite"
}

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

&lt;/div&gt;



&lt;p&gt;This will remove the deprecation warnings from your console output.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;4. Use pm2 to Manage Your Application (Horizontal Scaling)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Finally, I realized that one of my two clusters was down(horizontal Scale) so I added a ecosystem.config.js file in the project root to manage my application with pm2.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {
  apps: [
    {
      name: "my-app",
      script: "npm",
      args: "run start",
      instances: "max",
      exec_mode: "cluster",
      max_memory_restart: "1G",
      watch: false,
      autorestart: true,
      restart_delay: 5000,
    },
  ],
};

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

&lt;/div&gt;



&lt;p&gt;After pushing the code and pulling it on EC2, I restarted the pm2 server, and everything started working smoothly.&lt;/p&gt;

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

&lt;p&gt;This issue taught me a lot about managing dependencies and dealing with deprecated modules. While the punycode module is deprecated, you can still use it temporarily, but it's better to address the issue now to avoid problems in the future. I hope this guide helps you if you encounter a similar issue.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>punycode</category>
      <category>node</category>
      <category>asimkhan</category>
    </item>
  </channel>
</rss>
