<?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: Aditya Mathur</title>
    <description>The latest articles on DEV Community by Aditya Mathur (@mathuraditya7).</description>
    <link>https://dev.to/mathuraditya7</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%2F451182%2Fdc2c3ab3-348a-4004-a794-f17dce4f2beb.jpg</url>
      <title>DEV Community: Aditya Mathur</title>
      <link>https://dev.to/mathuraditya7</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mathuraditya7"/>
    <language>en</language>
    <item>
      <title>Introducing Hono OpenAPI: Simplifying API Documentation for HonoJS</title>
      <dc:creator>Aditya Mathur</dc:creator>
      <pubDate>Sat, 07 Dec 2024 15:18:47 +0000</pubDate>
      <link>https://dev.to/mathuraditya7/introducing-hono-openapi-simplifying-api-documentation-for-honojs-2e0e</link>
      <guid>https://dev.to/mathuraditya7/introducing-hono-openapi-simplifying-api-documentation-for-honojs-2e0e</guid>
      <description>&lt;p&gt;&lt;strong&gt;First things first: why create another OpenAPI library for Hono when one already exists?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is a question many have asked. Yes, there is &lt;a href="https://github.com/honojs/middleware/tree/main/packages/zod-openapi" rel="noopener noreferrer"&gt;Zod OpenAPI&lt;/a&gt;, created by &lt;a href="https://github.com/yusukebe" rel="noopener noreferrer"&gt;Yusuke&lt;/a&gt;. While it’s a great package, it has some significant limitations that led to the creation of a new solution.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Challenges with &lt;code&gt;@hono/zod-openapi&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Let’s break down why &lt;code&gt;hono-openapi&lt;/code&gt; was built by comparing the two approaches.&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Syntax and Workflow Differences
&lt;/h4&gt;

&lt;p&gt;Here’s an example using &lt;code&gt;@hono/zod-openapi&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Using @hono/zod-openapi &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;OpenAPIHono&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;createRoute&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;z&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;@hono/zod-openapi&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;ParamsSchema&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;object&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="nx"&gt;z&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;string&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;openapi&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;param&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;id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;in&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;path&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="na"&gt;example&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;1212121&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;route&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createRoute&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;get&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/users/{id}&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;params&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ParamsSchema&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;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;OpenAPIHono&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;openapi&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;route&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;c&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;id&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;valid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;param&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="nx"&gt;c&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="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&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;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;Ultra-man&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="c1"&gt;// The OpenAPI documentation will be available at /doc&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/doc&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="na"&gt;openapi&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;3.0.0&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;info&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;1.0.0&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;My API&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;Now compare this to the same application written with &lt;code&gt;hono-openapi&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Using Hono-OpenAPI&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;z&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;zod&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;Hono&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;hono&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;describeRoute&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;hono-openapi&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;resolver&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;validator&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;zValidator&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;hono-openapi/zod&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Extending the Zod schema with OpenAPI properties&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;zod-openapi/extend&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;paramSchema&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;object&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="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;string&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;openapi&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;example&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;1212121&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="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="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Hono&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nx"&gt;app&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nf"&gt;zValidator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;param&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;paramSchema&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;c&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;param&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;valid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;param&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="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Hello &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;param&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="s2"&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="nx"&gt;app&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/openapi&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nf"&gt;openAPISpecs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;documentation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;info&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hono&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;1.0.0&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;API for greeting users&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="na"&gt;servers&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;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;http://localhost:3000&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Local server&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="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The difference is clear: &lt;strong&gt;&lt;code&gt;hono-openapi&lt;/code&gt; lets you work directly within the standard HonoJS workflow&lt;/strong&gt;. This eliminates the steep learning curve and ensures that the syntax aligns with HonoJS documentation and conventions.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Challenges with Opting In
&lt;/h4&gt;

&lt;p&gt;With &lt;code&gt;@hono/zod-openapi&lt;/code&gt;, retrofitting an existing HonoJS application to generate OpenAPI specs is a significant challenge. Rewriting routes for a large application can be time-consuming and error-prone. &lt;code&gt;hono-openapi&lt;/code&gt; solves this by working as middleware, so you can add it to existing apps without major changes.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Limited Validator Support
&lt;/h4&gt;

&lt;p&gt;The original library only supports &lt;a href="https://zod.dev/" rel="noopener noreferrer"&gt;Zod&lt;/a&gt;. While Zod is excellent, many developers use alternatives like &lt;a href="https://valibot.dev/" rel="noopener noreferrer"&gt;Valibot&lt;/a&gt;, &lt;a href="https://arktype.io/" rel="noopener noreferrer"&gt;ArkType&lt;/a&gt;, and &lt;a href="https://github.com/sinclairzx81/typebox" rel="noopener noreferrer"&gt;TypeBox&lt;/a&gt;. &lt;code&gt;hono-openapi&lt;/code&gt; is validator-agnostic, offering first-class support for multiple libraries.&lt;/p&gt;




&lt;h3&gt;
  
  
  Why OpenAPI Specs Matter
&lt;/h3&gt;

&lt;p&gt;Some might wonder, “Why bother with OpenAPI specs at all? My app works fine without them.”&lt;/p&gt;

&lt;p&gt;Here’s why generating OpenAPI specs is a game-changer:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;API Client Generation&lt;/strong&gt;: Use the specs to auto-generate clients for various programming languages, saving development time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Developer Collaboration&lt;/strong&gt;: Keep your team in sync with up-to-date API documentation, reducing miscommunication and bugs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Streamlined Debugging&lt;/strong&gt;: Eliminate guesswork when APIs fail by providing clear, accurate documentation for all endpoints.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Best Practices&lt;/strong&gt;: Automatically generate documentation that evolves with your codebase, ensuring consistency across branches and versions.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is an example of Generate Docs from OpenAPI Specs using Scalar -&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%2Fat00az4e5fmw5de47sk3.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%2Fat00az4e5fmw5de47sk3.png" alt="Image description" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And this is how you use Scalar with Hono -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&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;apiReference&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;@scalar/hono-api-reference&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="nx"&gt;app&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/docs&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nf"&gt;apiReference&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="s2"&gt;saturn&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/openapi&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you’ve ever worked on a team where frontend and backend developers had to manually sync API details, you’ll know how painful it can be. OpenAPI specs solve this by providing a single source of truth.&lt;/p&gt;




&lt;h3&gt;
  
  
  Why Choose &lt;code&gt;hono-openapi&lt;/code&gt;?
&lt;/h3&gt;

&lt;p&gt;To address these challenges and promote best practices, &lt;code&gt;hono-openapi&lt;/code&gt; was built with the following goals in mind:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Validator-Agnostic&lt;/strong&gt;: Use your preferred validation library — Zod, Typebox, ArkType, Valibot, or others.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Seamless Integration&lt;/strong&gt;: Add it to any HonoJS project as middleware, with minimal changes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automatic OpenAPI Generation&lt;/strong&gt;: Define schemas once and let the library handle the rest.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Type-Safe&lt;/strong&gt;: Built with TypeScript for reliable and consistent type validation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Customizable&lt;/strong&gt;: Tailor the generated OpenAPI specs to meet your project’s requirements.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Ready to Get Started?
&lt;/h3&gt;

&lt;p&gt;If this sounds like the solution you’ve been waiting for, check out the library and join the conversation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Repository&lt;/strong&gt;: &lt;a href="https://github.com/rhinobase/hono-openapi" rel="noopener noreferrer"&gt;hono-openapi&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Documentation&lt;/strong&gt;: &lt;a href="https://github.com/rhinobase/hono-openapi#readme" rel="noopener noreferrer"&gt;GitHub README&lt;/a&gt; | &lt;a href="https://hono.dev/examples/hono-openapi" rel="noopener noreferrer"&gt;Hono Examples&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;I hope this article convinces you to try &lt;code&gt;hono-openapi&lt;/code&gt; and see how it simplifies building and documenting APIs. Your feedback matters! Let’s build a stronger HonoJS community together.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>serverless</category>
      <category>node</category>
    </item>
    <item>
      <title>Hono for Express Developers: A Modern Alternative for Edge Computing</title>
      <dc:creator>Aditya Mathur</dc:creator>
      <pubDate>Wed, 11 Sep 2024 13:44:47 +0000</pubDate>
      <link>https://dev.to/mathuraditya7/hono-for-express-developers-a-modern-alternative-for-edge-computing-4pd8</link>
      <guid>https://dev.to/mathuraditya7/hono-for-express-developers-a-modern-alternative-for-edge-computing-4pd8</guid>
      <description>&lt;p&gt;&lt;strong&gt;Express.js&lt;/strong&gt; has long been the go-to choice for many developers when it comes to building web servers. With over &lt;strong&gt;30 Million&lt;/strong&gt; weekly installs, it's clear that Express has cemented itself as an industry standard. But as time has passed, so have the requirements of modern web applications. Developers are now seeking frameworks that are not only simple but also &lt;strong&gt;more robust&lt;/strong&gt;, &lt;strong&gt;type-safe&lt;/strong&gt;, and better suited for &lt;strong&gt;edge computing and serverless environments&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Over the years, frameworks like &lt;em&gt;NestJS&lt;/em&gt;, &lt;em&gt;Next.js&lt;/em&gt;, and &lt;em&gt;Nuxt.js&lt;/em&gt; have tried to evolve and improve the developer experience. While these frameworks are powerful, they often come with significant complexity or a heavy setup process, which can feel overwhelming, especially for simpler use cases. Sometimes, developers need something that's just as simple and lightweight as Express but with modern features.&lt;/p&gt;

&lt;p&gt;This is where &lt;strong&gt;Hono&lt;/strong&gt; steps in.&lt;/p&gt;

&lt;p&gt;Hono offers the simplicity of Express with the added benefits of &lt;strong&gt;higher performance&lt;/strong&gt;, &lt;strong&gt;modern web standards&lt;/strong&gt;, and &lt;strong&gt;better support for TypeScript&lt;/strong&gt;. In this article, We’ll compare their core concepts, highlight differences, and show how Hono can boost your development experience, especially for edge and serverless deployments.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Setting Up: Simplicity at Its Core
&lt;/h2&gt;

&lt;p&gt;Setting up a basic server with Express is straightforward, and Hono shares that simplicity. Here’s a quick look at initializing both frameworks:&lt;/p&gt;

&lt;p&gt;Express -&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="nx"&gt;express&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express&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="nf"&gt;express&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nx"&gt;app&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/&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;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello from Express!&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;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3000&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;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;Server is running on http://localhost:3000&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hono -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&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;serve&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;@hono/node-server&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;Hono&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;hono&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="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Hono&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nx"&gt;app&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/&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;c&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;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello from Hono!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

&lt;span class="nf"&gt;serve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, the code structure is similar. The key differences here are -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An extra package &lt;code&gt;@hono/node-server&lt;/code&gt;, which is used to serve the Hono app. This package is necessary to run Hono apps in Node.js environments. This is also what makes Hono different from Express, as you can have the same codebase for all the environments.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hono Supports multiple environments like Node.js, Deno, and even the browser. This makes it a great choice for developers who want to build applications that can run on multiple platforms. You can see the full list of all the supported runtimes on the &lt;a href="https://hono.dev" rel="noopener noreferrer"&gt;Hono docs&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;And also in place of &lt;code&gt;req&lt;/code&gt; and &lt;code&gt;res&lt;/code&gt;, Hono uses a single context object &lt;code&gt;c&lt;/code&gt; which contains all the information about the request and response. This makes it easier to work with the request and response objects. That's why we have &lt;code&gt;c.text&lt;/code&gt; instead of &lt;code&gt;res.send&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Routing: Chainable and Efficient
&lt;/h2&gt;

&lt;p&gt;Just like Express, Hono also has an excellent routing system. Here’s how you can define routes in both frameworks:&lt;/p&gt;

&lt;p&gt;Express -&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="nx"&gt;app&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/user&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;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;User page&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hono -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/user&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;c&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;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;User page&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Other than having a single variable &lt;code&gt;c&lt;/code&gt; (context) instead of &lt;code&gt;req&lt;/code&gt; and &lt;code&gt;res&lt;/code&gt;, the routing system in Hono is similar to Express. You can define routes using &lt;code&gt;app.get&lt;/code&gt;, &lt;code&gt;app.post&lt;/code&gt;, &lt;code&gt;app.put&lt;/code&gt;, &lt;code&gt;app.delete&lt;/code&gt;, etc.&lt;/p&gt;

&lt;p&gt;Additionally, since Hono is optimized for performance, you can expect faster request handling compared to Express.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Middleware: Flexibility Meets Minimalism
&lt;/h2&gt;

&lt;p&gt;Express is well-known for its middleware system, and Hono provides similar functionality. Here’s how you can use middleware in both frameworks:&lt;/p&gt;

&lt;p&gt;Express -&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="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;next&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;Middleware in Express&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;next&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;Hono -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;next&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;Middleware in Hono&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;next&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;
  
  
  4. Request and Response Handling: Web Standards at the Core
&lt;/h2&gt;

&lt;p&gt;Express uses Node-specific APIs like req and res, which are well-known to most developers:&lt;/p&gt;

&lt;p&gt;Express -&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="nx"&gt;app&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/data&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;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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;res&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="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Express response&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hono, in contrast, builds on top of Web APIs like the Fetch API, making it more future-proof and easier to adapt for edge environments.&lt;/p&gt;

&lt;p&gt;Hono -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/data&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;c&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;c&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="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hono response&lt;/span&gt;&lt;span class="dl"&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 difference might seem minor, but it highlights Hono’s commitment to leveraging modern web standards, which can result in more maintainable and portable code.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Error Handling: A Simple, Efficient System
&lt;/h2&gt;

&lt;p&gt;Both frameworks offer straightforward ways to handle errors. In Express, you typically define an error-handling middleware:&lt;/p&gt;

&lt;p&gt;Express -&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="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;next&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;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Something went wrong&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hono offers a similar approach, keeping things clean and lightweight:&lt;/p&gt;

&lt;p&gt;Hono -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;onError&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;c&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;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Something went wrong&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;500&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 Hono, error handling is just as easy but comes with the added benefit of cleaner syntax and better performance.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Performance Comparison: The Edge Advantage
&lt;/h2&gt;

&lt;p&gt;Performance is where Hono truly outshines Express. Built with speed and edge deployments in mind, Hono’s lightweight framework outperforms Express in most benchmarks. Here’s why:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hono uses modern Web APIs and doesn’t rely on Node.js specifics.&lt;/li&gt;
&lt;li&gt;Its minimalist design makes it faster, with fewer dependencies to manage.&lt;/li&gt;
&lt;li&gt;Hono can easily take advantage of edge computing environments, like Cloudflare's workers and pages or Deno.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In performance-critical applications, this makes Hono a compelling choice.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Deployments: Edge and Serverless First
&lt;/h2&gt;

&lt;p&gt;Hono is designed from the ground up for edge and serverless environments. It seamlessly integrates with platforms like &lt;strong&gt;Cloudflare Workers&lt;/strong&gt;, &lt;strong&gt;Vercel&lt;/strong&gt;, and &lt;strong&gt;Deno Deploy&lt;/strong&gt;. While Express is more traditional and often paired with Node.js servers, Hono thrives in modern, distributed environments.&lt;/p&gt;

&lt;p&gt;If you’re building applications that need to run closer to the user, Hono APIs can easily run on the edge and will offer significant benefits over Express.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Ecosystem and Community: Growing Rapidly
&lt;/h2&gt;

&lt;p&gt;Express boasts one of the largest ecosystems in the Node.js world. With thousands of middleware packages and a huge community, it's a familiar and reliable option. However, Hono’s ecosystem is growing fast. Its middleware collection is expanding, and with its focus on performance and modern web standards, more developers are adopting it for edge-first applications.&lt;/p&gt;

&lt;p&gt;While you might miss some Express packages, the Hono community is active and building new tools every day.&lt;/p&gt;

&lt;p&gt;You can find more about the Hono community and ecosystem on the &lt;a href="https://hono.dev" rel="noopener noreferrer"&gt;Hono website&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Learning Curve: Express Devs Will Feel Right at Home
&lt;/h2&gt;

&lt;p&gt;Hono’s API is designed to be intuitive, especially for developers coming from Express. With a similar routing and middleware pattern, the learning curve is minimal. Moreover, Hono builds on top of Web APIs like Fetch, which means that the skills you gain are portable beyond just server-side development, making it easier to work with modern platforms and environments.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion: Why You Should Try Hono
&lt;/h2&gt;

&lt;p&gt;Hono brings a fresh approach to web development with its performance-first mindset and focus on edge computing. While Express has been a reliable framework for years, the web is changing, and tools like Hono are leading the way for the next generation of applications.&lt;/p&gt;

&lt;p&gt;If you're an Express developer looking to explore edge computing and serverless architectures, or want a faster, more modern framework, try Hono. You’ll find that many concepts are familiar, but the performance gains and deployment flexibility will leave you impressed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ready to Get Started?
&lt;/h2&gt;

&lt;p&gt;Try building your next project with Hono and experience the difference for yourself. You can find resources and starter templates to help you easily switch from Express.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm create hono@latest my-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it! You're ready to go. Happy coding with Hono! Do share with me your experience with Hono in the comments below, on &lt;a href="https://x.com/MathurAditya7" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; or &lt;a href="https://github.com/MathurAditya724" rel="noopener noreferrer"&gt;Github&lt;/a&gt;. I'd be glad to hear your thoughts!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>serverless</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Deploying Hono Js App on Vercel</title>
      <dc:creator>Aditya Mathur</dc:creator>
      <pubDate>Wed, 17 Apr 2024 06:14:13 +0000</pubDate>
      <link>https://dev.to/mathuraditya7/pitfalls-of-deploying-hono-js-app-on-vercel-15h7</link>
      <guid>https://dev.to/mathuraditya7/pitfalls-of-deploying-hono-js-app-on-vercel-15h7</guid>
      <description>&lt;p&gt;&lt;a href="https://hono.dev/"&gt;Hono&lt;/a&gt; is an ultrafast web framework for the edge and it's amazing. It's simple as express and the DX is mind-blowing. And now you can also serve JSX with it 🤯. Anyone in the industry for long enough knows that a setup like this can be quite tedious to manage and maintain. I might sound biased for Hono, and that's true, I love it ❤️.&lt;/p&gt;

&lt;p&gt;While working on a project using Hono, I saw the need for a rate limiter, which was not present in the ecosystem. So I build one, &lt;code&gt;hono-rate-limiter&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;GitHub - &lt;a href="https://github.com/rhinobase/hono-rate-limiter"&gt;github.com/rhinobase/hono-rate-limiter&lt;/a&gt;&lt;br&gt;
NPM - &lt;a href="https://www.npmjs.com/package/hono-rate-limiter"&gt;npmjs.com/package/hono-rate-limiter&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As with every good project, you need a website that hosts examples to better understand your project. And I did make one, which you can check out here - &lt;a href="https://hono-rate-limiter.vercel.app/"&gt;hono-rate-limiter.vercel.app&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Building the application was easy, I built everything in just 3 days (including the library, tests, and the example) but deploying it took me more than 3 days. The main reasons were -&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Lack of documentation for deploying on vercel.&lt;/li&gt;
&lt;li&gt;Pitfalls for deploying Hono on vercel.&lt;/li&gt;
&lt;li&gt;Problem with getting the correct config for my library (i.e. getting the IP address).&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Lack of Documentation
&lt;/h2&gt;

&lt;p&gt;Hono does have a template application for Vercel, but in my case, my requirements were different (aren't they always 😅). I was working in a monorepo (using &lt;a href="https://nx.dev/"&gt;nx&lt;/a&gt;) because I wanted to manage my libs, tests, and examples all together in a single place, instead of having different repos.&lt;/p&gt;

&lt;p&gt;For this, as there was no guide to do it, I had to set up a JS project and then add Hono and Vercel stuff from scratch in my monorepo. Hono was simple as there was not that much to configure but figuring out Vercel was tedious. Vercel as of right now doesn't have a template to deploy your Hono Js project, so you will need to set up all the things from scratch. Such a thing was the root dir of the project, which I needed to set up as the root of the example folder &lt;code&gt;/apps/sandbox&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In my example, I was having a home page built using Hono's JSX so in place of hosting it on &lt;code&gt;/api&lt;/code&gt;, I wanted to host it on &lt;code&gt;/&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So to overcome this, you need some understanding of how Vercel deploys your application when using the &lt;code&gt;vercel.json&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;This was my Vercel config file to host it on &lt;code&gt;/&lt;/code&gt; instead of &lt;code&gt;/api&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;vercel.json&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"rewrites"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"source"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/(.*)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"destination"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/api"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Pitfalls
&lt;/h2&gt;

&lt;p&gt;Vercel doesn't have a template to deploy your Hono app, so there are some hops you have to go through.&lt;/p&gt;

&lt;p&gt;For example, setting up env variables in your Vercel project &lt;code&gt;NODEJS_HELPERS=0&lt;/code&gt;, I came to this from this conversation on &lt;a href="https://github.com/honojs/node-server/issues/84#issuecomment-1745066420"&gt;Github&lt;/a&gt;. I am still not sure, why setting this up makes the difference, if anyone of you reading this does, do let us know in the comments.&lt;/p&gt;

&lt;h2&gt;
  
  
  My Config Issues
&lt;/h2&gt;

&lt;p&gt;So after all these issues, I was able to deploy my application on Vercel 👍🏼. Everything was working, I double-checked it and finally deployed it. I tweeted about it on X&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1771943040891945404-177" src="https://platform.twitter.com/embed/Tweet.html?id=1771943040891945404"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1771943040891945404-177');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1771943040891945404&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;And then something weird happened, people who were coming on the weren't getting uniquely identified from their IP. I checked and figured that I was not getting their IP. So I branched out and checked the example again, It was working perfectly as intended.&lt;/p&gt;

&lt;p&gt;After hours of debugging, it turned out that the headers I was getting on the branch deployment were different from the ones on the production. I corrected the header variable name, and it started working.&lt;/p&gt;

&lt;p&gt;After the tweet it took me 4 - 5 hours to release, there was an issue and around 2 hours to resolve it. So I did lose the peak traffic time on the app when everyone wanted to try it out. And the package didn't receive the attention it was capable of.&lt;/p&gt;

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

&lt;p&gt;I learned a lot and it was stressful and fun, especially contributing to something I love working with. If you are interested try out &lt;code&gt;hono-rate-limiter&lt;/code&gt; and let me know if you find any bugs or have any feature requests. I will be more than happy to connect with you.&lt;/p&gt;

&lt;p&gt;Hopefully, this might help someone, who wants to deploy a Honojs app on Vercel.&lt;/p&gt;

&lt;p&gt;If you want to check out my lib from which I got all my learnings, here are the links -&lt;/p&gt;

&lt;h3&gt;
  
  
  hono-rate-limiter
&lt;/h3&gt;

&lt;p&gt;GitHub - &lt;a href="https://github.com/rhinobase/hono-rate-limiter"&gt;github.com/rhinobase/hono-rate-limiter&lt;/a&gt;&lt;br&gt;
NPM - &lt;a href="https://www.npmjs.com/package/hono-rate-limiter"&gt;npmjs.com/package/hono-rate-limiter&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Do let me know what you think about it and how we can boost the community in the future. Do show us your support by giving us a star and for more content like this in the future.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>serverless</category>
      <category>node</category>
    </item>
    <item>
      <title>Things I learned while building projects with NX</title>
      <dc:creator>Aditya Mathur</dc:creator>
      <pubDate>Mon, 18 Mar 2024 03:28:25 +0000</pubDate>
      <link>https://dev.to/mathuraditya7/things-i-learned-while-building-projects-with-nx-39gm</link>
      <guid>https://dev.to/mathuraditya7/things-i-learned-while-building-projects-with-nx-39gm</guid>
      <description>&lt;p&gt;Lately, I have fallen in love with these monorepo tools, especially the Nx library ❤️. Initially, I just used &lt;code&gt;vite&lt;/code&gt; or &lt;code&gt;next&lt;/code&gt; for building applications, but for the past 2 years, I have been using these for my projects, and it's amazing. Now I can't even imagine my projects without them. For building a website or a dashboard, you are good without these tools. But as soon as your scope of work expands beyond that, you should start using these tools.&lt;/p&gt;

&lt;p&gt;Many of you might not have heard about the concept of Monorepos, or many of you might know about it but don't understand its benefits and issues of using something like this.&lt;/p&gt;

&lt;p&gt;Some of the monorepo tools out there are -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://nx.dev/"&gt;Nx&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://lerna.js.org/"&gt;Lerna&lt;/a&gt; currently maintained by Nx team&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://turbo.build/"&gt;Turbo Repo&lt;/a&gt; by Vercel&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://bazel.build/"&gt;Bazel&lt;/a&gt; by Google&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://buck2.build/"&gt;Buck 2&lt;/a&gt; by Facebook&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can also use workspaces but these are specialized tools to help you with your day-to-day tasks. Right now Nx and Turbo repo are the most popular monorepo tools (according to me).&lt;/p&gt;

&lt;p&gt;So first of all, let's talk about why you even need this tooling.&lt;/p&gt;

&lt;p&gt;So the majority of you might not need this, you should be more than fine with your &lt;code&gt;create-next-app&lt;/code&gt; or &lt;code&gt;vite&lt;/code&gt; commands to get a starter template and build on top of it. But when we are talking about applications like ERPs, CRMs, or any application that may have more than one portal and multiple small helper packages, that's when you need a monorepo.&lt;/p&gt;

&lt;p&gt;Building large-scale applications is easy but maintaining them and adding new features from time to time, can be quite hectic if you haven't used the correct tools from the start. You need tools for -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Building&lt;/li&gt;
&lt;li&gt;Testing&lt;/li&gt;
&lt;li&gt;Deploying&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And all of this can easily be done with a monorepo tool. And they provide even more functionality out of the box. The list of features includes -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Running Concurrent Builds - Multiple packages or apps can be built concurrently.&lt;/li&gt;
&lt;li&gt;Task Dependencies - It creates a dependency graph through which it can identify package interdependencies. Helping it to place the tasks in order so that nothing breaks while still being concurrent.&lt;/li&gt;
&lt;li&gt;Caching - Once a package is built, you don't need to build it again if there are no changes. These tools can also store this on the cloud, calling it &lt;em&gt;Remote Caching&lt;/em&gt;, resulting in faster CI.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Resulting in a great DX ❤️&lt;/p&gt;

&lt;p&gt;When building an app, you tend to build it again and again. Being stuck for like 5 minutes every time you are building it, ah the worst feeling 😵‍💫. Even if you are using rust-based compilers, these builds tend to increase in size as you add more and more features. Nextjs alone can take up to 2 minutes to build a single app. And imagine these things happening in sync.&lt;/p&gt;

&lt;p&gt;I guess now you are also starting to understand why these tools are important. And the best part is these features that I just told you about are just the beginning, they provide a ton of more features.&lt;/p&gt;

&lt;p&gt;Nx provides out-of-the-box tooling for setting up your Apps and Libraries in React, Nextjs, Vue, Angular, Express, and many more. You can check out the list here - &lt;a href="https://nx.dev/nx-api"&gt;Nx Api&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;They also have internal tooling to move, rename, lint, build, and test all your packages. You can add custom commands too if you want, but for the majority part, Nx does have all the tooling.&lt;/p&gt;

&lt;p&gt;And If you are a good developer you must have already seen it coming that, if the library is doing most of the work it will be harder to extend the behavior when needed. Honestly, I also thought that, and sometimes it does look like that, but every time it was because of a config issue by one of the build tools.&lt;/p&gt;

&lt;p&gt;Because Nx is not in the driver's seat, you are. It is just providing you with the utilities to do your day-to-day operations. Cause at the end of the day, it is just a folder manager 😂&lt;/p&gt;

&lt;p&gt;There were times when Nx had some problems in their internal tooling but their team is quite fast and efficient in helping you out and resolve these errors.&lt;/p&gt;

&lt;p&gt;By now you must be thinking, I am being biased for Nx and not giving attention to Turbo Repo. And yes, it is true. Compared to Nx, Turbo is quite new in the market and they are still working on their tooling. Nx has a more mature base and a thriving community. Then too, I initially started with Turbo Repo only, but because of the lack of tooling and helper functions it was quite hard to navigate. Because of the building helpers in Nx, it is much easier to get started. Because there will be a huge learning curve ahead of you when you are starting to work with either of them. Having things to get you started, can make it much easier.&lt;/p&gt;

&lt;p&gt;Even with these tools, there will be quite a lot to learn, about the configs and packages to build a library. I have explained this in more detail in this article, &lt;a href="https://dev.to/mathuraditya7/things-i-learned-while-building-my-js-library-2k06"&gt;Things I learned while building my JS library&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope this provides you with some good insight into, why these tools are needed and what benefits you will get from using tools like this. Do give it a shot and let me know what do you think about it. Which one did you like, Nx or Turbo?&lt;/p&gt;

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

&lt;p&gt;I learned a lot. Tools like &lt;code&gt;create-next-app&lt;/code&gt; and &lt;code&gt;vite&lt;/code&gt; take away all the heavy lifting stuff and give us an abstract layer to work upon, but these are great till you have a single project to build or not many dependencies are there. As things start to grow the need for tools like this increases.&lt;/p&gt;

&lt;p&gt;If you want to check out my lib from which I got all my learnings, here are the links -&lt;/p&gt;

&lt;h3&gt;
  
  
  @rafty/ui
&lt;/h3&gt;

&lt;p&gt;GitHub - &lt;a href="https://github.com/rhinobase/raftyui"&gt;github.com/rhinobase/raftyui&lt;/a&gt;&lt;br&gt;
Docs - &lt;a href="https://rafty.rhinobase.io"&gt;rafty.rhinobase.io&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  @fibr/react (Under Development)
&lt;/h3&gt;

&lt;p&gt;GitHub - &lt;a href="https://github.com/rhinobase/fibr"&gt;github.com/rhinobase/fibr&lt;/a&gt;&lt;br&gt;
Docs - &lt;a href="https://fibr.rhinobase.io"&gt;fibr.rhinobase.io&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Do let me know what you think about it and how we can boost the community in the future. Do show us your support by giving us a star and for more content like this in the future.&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Things I learned while building my JS library</title>
      <dc:creator>Aditya Mathur</dc:creator>
      <pubDate>Sun, 10 Mar 2024 06:41:26 +0000</pubDate>
      <link>https://dev.to/mathuraditya7/things-i-learned-while-building-my-js-library-2k06</link>
      <guid>https://dev.to/mathuraditya7/things-i-learned-while-building-my-js-library-2k06</guid>
      <description>&lt;p&gt;If you call yourself a developer, and you haven't created any library or thought about building one, my friend you haven't scratched the surface of being a developer.&lt;/p&gt;

&lt;p&gt;While working on a personal project or in your company, you must have thought about making a library around those functions or components you are building repeatedly. And it makes sense too, according to the DRY (Don't Repeat Yourself) principle. But a lot of effort goes into making something that is useful and others also can use.&lt;/p&gt;

&lt;p&gt;And building a library is not just about, bundling some functions or components together which are flexible and dynamic. There is a lot of thought goes into it like&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;API&lt;/strong&gt; - Simple and easy-to-use functions, with IntelliSense in the editor&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bundling&lt;/strong&gt; - Getting everything together into a single package or multiple packages, which can be easily used by you and your team.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Versioning&lt;/strong&gt; - Tools to release and version your packages&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Testing&lt;/strong&gt; - Checking if there are any breaking changes and the application is working correctly. Maybe you can have a test app, where you deploy the changes to check if everything is working before releasing a new version. Or simply a jest or playwright test to check them in a CI/CD workflow through automation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And then in the JS world, you also have to figure out things like&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;tree-shaking&lt;/li&gt;
&lt;li&gt;side effects&lt;/li&gt;
&lt;li&gt;ESM or CJS&lt;/li&gt;
&lt;li&gt;code splitting&lt;/li&gt;
&lt;li&gt;bundling dependencies&lt;/li&gt;
&lt;li&gt;dev dependencies&lt;/li&gt;
&lt;li&gt;peer dependencies&lt;/li&gt;
&lt;li&gt;exports&lt;/li&gt;
&lt;li&gt;modules&lt;/li&gt;
&lt;li&gt;types (.d.ts files)&lt;/li&gt;
&lt;li&gt;JS Docs or TS Docs&lt;/li&gt;
&lt;li&gt;and many more...&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These might look overwhelming to you but knowing these things is crucial for your career and in general as a developer. I will not go in-depth about what these things are in this article, maybe in the future but there are plenty of amazing articles about these on the internet.&lt;/p&gt;

&lt;p&gt;However, all of these problems can be resolved with a bundling tool like, Rollup, Vite, and Webpack. Knowing what configuration will be required and how things will be working is the hard part. As that is the main thing, Nextjs uses Webpack, pre-configured to handle all of the bundling of their application, so that you won't have to.&lt;/p&gt;

&lt;p&gt;Lately, they are also working on a new bundling tool, Turbopack which is written in Rust and I think they are claiming that it's backward compatible with Webpack but still, it's in alpha, so we will have to see. Vite is also working on Rolldown, a Rust-based version of Rollup. These updates and changes will not make sense to you as long as you are in the ecosystem.&lt;/p&gt;

&lt;p&gt;As a JS Developer or any developer, you should know how to an environment without the need for any setup tools. As these tools are great for starting a new project but as soon as you will require something outside of this ecosystem, you are stuck.&lt;/p&gt;

&lt;p&gt;Solving leet code questions, or any sort of competitive questions helps you to understand the core coding concepts. But building a library, and iterating over it helps you understand the concepts of your programming language, because different languages may have the same keywords or functions like while loop, for loop, variable declarations, and others. But their inner workings and performance will differ and this is how you become an expert in that language, by knowing these things. So that you can already see where your functions or applications might suffer in speed or performance.&lt;/p&gt;

&lt;p&gt;This is true for any programming language, not just JS. The best part is, that you start to get familiar with all the tools and are more comfortable while using them. Making you faster and more efficient in building applications.&lt;/p&gt;

&lt;p&gt;Building a production application or library is not easy. And the learning you get while building them on your own is far more than just watching it on Youtube or following a tutorial.&lt;/p&gt;

&lt;p&gt;And I also, as an experienced developer have messed up a lot. Sometimes there were config errors and bugs in general, proper testing was not done before deployment, documentation website was not working properly. If the library has integration capabilities then, that might not be working properly, and the list goes on and on.&lt;/p&gt;

&lt;p&gt;The thing is mistake happens, and that is what the learning is so that next time it doesn't happen. If you are using tools like &lt;em&gt;nextjs&lt;/em&gt; or &lt;em&gt;nuxtjs&lt;/em&gt;, then you need to build things like this. Because these tools are built to help developers build applications rather than stuck in setting things up, like Rollup or Webpack configs. Yes, these tools are amazing and do most of the stuff for you but big production applications are not just &lt;em&gt;nextjs&lt;/em&gt; or &lt;em&gt;nuxtjs&lt;/em&gt;, they comprise a lot of small/medium-sized libraries and applications built on &lt;em&gt;Python&lt;/em&gt; (for AI maybe) and just &lt;em&gt;React&lt;/em&gt; (Admin Panel). Then the need for a monorepo arises but you might not know what a monorepo is, because you have never come out of these ecosystems.&lt;/p&gt;

&lt;p&gt;You can refer to this article, &lt;a href="https://dev.to/mathuraditya7/things-i-learned-while-building-my-component-library-1pmc"&gt;Things I Learned While Building My Component Library&lt;/a&gt;, where I have gone into more detail about the tools and libraries that my team and I use to build applications.&lt;/p&gt;

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

&lt;p&gt;I learned a lot. From building better APIs and functions to libraries and publishing them on npm. It took me 6 months to complete all of this. And yes I know this sounds like a lot of time, but I had my fun. Building this gave me insight into what goes into building a library which others can also use and cherish.&lt;/p&gt;

&lt;p&gt;I would say that if you haven't ever built a library, you should at least try to. The community is a great help, if you are stuck somewhere, some people can help you or also have fallen into the same problems, on which you can build.&lt;/p&gt;

&lt;p&gt;Github, StackOverflow, and other online forms are great places to seek help and guidance related to your problems.&lt;/p&gt;

&lt;p&gt;If you want to check out my lib from which I got all my learnings, here are the links -&lt;/p&gt;

&lt;h3&gt;
  
  
  @rafty/ui
&lt;/h3&gt;

&lt;p&gt;GitHub - &lt;a href="https://github.com/rhinobase/raftyui"&gt;github.com/rhinobase/raftyui&lt;/a&gt;&lt;br&gt;
Docs - &lt;a href="https://rafty.rhinobase.io"&gt;rafty.rhinobase.io&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Do let me know what you think about it and how we can boost the community in the future. Do show us your support by giving us a star and for more content like this in the future.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Things I learned while building my Component Library</title>
      <dc:creator>Aditya Mathur</dc:creator>
      <pubDate>Sun, 03 Mar 2024 19:43:34 +0000</pubDate>
      <link>https://dev.to/mathuraditya7/things-i-learned-while-building-my-component-library-1pmc</link>
      <guid>https://dev.to/mathuraditya7/things-i-learned-while-building-my-component-library-1pmc</guid>
      <description>&lt;p&gt;Component libraries have changed how we build applications. It gives us the essential building blocks to develop an application's UI while hiding all the complicated logic from us to achieve that behavior. And the funny part is, the majority of the developers don't understand what is happening behind the scenes. This is a good thing, as it tells us that the library that you are using is quite good, and flexible to achieve your goals. So overall component libraries are great, they are flexible, customizable, and correctly documented and most of them work out of the box.&lt;/p&gt;

&lt;p&gt;But if you are a front-end developer, you must understand and know what is happening behind the scenes. This can make a ton of difference when you are building a component on your own without any help from a component library. Because at the end of the day, the component library can be framework-specific, while this knowledge is transferable.&lt;/p&gt;

&lt;p&gt;Let's take an example, to help you understand why you should know about this. Have you ever visited a website,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Where the link is just on the text instead of the whole button&lt;/li&gt;
&lt;li&gt;Keyboard navigation doesn't work, inside a menu or something similar&lt;/li&gt;
&lt;li&gt;Tabbing and focus are not working properly, for example, in case of an alert dialog, the default focus should be on the less destructive button, like a cancel button.&lt;/li&gt;
&lt;li&gt;and many more...&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can easily find these types of problems on old, or even on some new websites.&lt;/p&gt;

&lt;p&gt;In 2024, building a website is not just about putting some divs and adding the content. It's about accessibility, user-friendliness, theming, and consistency across the whole application.&lt;/p&gt;

&lt;p&gt;A component library takes into account all of these problems and on top of it, provides a thoughtful and easy-to-use API.&lt;/p&gt;

&lt;p&gt;Tho these problems might seem like minor issues that can be easily solved, and yes they can be. But it's about the thought process when you are building stuff. Many of us don't think about these issues, but once you start to, things change. You start to notice these things in your interfaces, and other's interfaces and you will find gaps. And this is what marks the difference between a senior and a junior developer or a good and a bad app.&lt;/p&gt;

&lt;p&gt;And you will also tend to realize that using native components is far better than making custom ones, like a date picker. Because all the aspects of this component are managed by the browser, or the OS and if you make yours then you will need to handle this on your own. You can use a library, but if it has a bug then you are stuck until it is resolved.&lt;/p&gt;

&lt;p&gt;Let's now dive a bit deeper, and let me tell you about the libraries that I used to build my component library.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Radix Primitives
&lt;/h2&gt;

&lt;p&gt;You might have heard about it and maybe also used it. These are like the barebone components for React which you can use directly also to build applications. It includes most of the commonly used components like Dialog, Slider, Menu, Popover, etc.&lt;/p&gt;

&lt;p&gt;And you might be thinking, If I am already using this why am I even building one in the first place?&lt;/p&gt;

&lt;p&gt;So basically, these are &lt;em&gt;primitives&lt;/em&gt;, and as the name suggests these are just barebone components that handle the working logic and API. There are no styling and theme options available.&lt;/p&gt;

&lt;p&gt;You can make your components from scratch, all you need to do is achieve all the accessibility features and make these components as per the WAI-ARIA design patterns, it should be consistent between all browsers too, and keep it up to date with the web standards.&lt;/p&gt;

&lt;p&gt;I don't know about you but I am happy to pass all this work on to a library. 😂&lt;/p&gt;

&lt;p&gt;It is not impossible to make all these components from scratch, and you will have to make custom components. Because the radix components set is small, it will manage to help you with most of the interfaces. But for some advanced and more complex ones like resizable windows and command palettes, you might need to find another library or make it yourself.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Tailwind
&lt;/h2&gt;

&lt;p&gt;Now for styling, we are going to use TailwindCSS. I think I don't need to tell you why this is the best choice. You can already find plenty of articles, regarding why TailwindCSS is so great and better than runtime CSS.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. NX
&lt;/h2&gt;

&lt;p&gt;Building and managing multiple and heavy apps can be quite cumbersome. You will require a tool to manage your mono repo so that you can store your docs, storybook, and library code in a single folder. And NX is great for this sort of work. it's blazingly fast in building your app and caching it, which makes consecutive builds fast.&lt;/p&gt;

&lt;p&gt;I can not emphasize this more if you are building a large project like building a component library, you should use a tool like nx to manage it. It will make your life so much easier.&lt;/p&gt;

&lt;p&gt;You can also use turbo repo, which is another project which tries to achieve the same thing. It's just that NX worked for me and also it was in the market way before Turbo.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Rollup
&lt;/h2&gt;

&lt;p&gt;This is so much better than webpacks. It's simple, easy to use and the important this is, it's easy to understand. Because webpacks are verbose, you have to tell it all the things, and a lot of configuration goes into it. When you are building a library these configs can slow you down.&lt;/p&gt;

&lt;p&gt;Rollup provides a simple API that is easy to understand. And it does most of the heavy lifting for you. If you are building something complex and want control over it, then you should go for webpacks, but still, 90% of the scenarios rollup should be enough.&lt;/p&gt;

&lt;p&gt;You can also use Vite, at the time of building the component library, the support for library mode was not stable. I did ask the team about this at the time, and they told me they were not sure if they were going to work on it. I am also a Vite fanboy like most of the other developers, thanks to its outstanding performance. I do use it for my storybook setup, but for building the library, I use rollup.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Storybook
&lt;/h2&gt;

&lt;p&gt;You need to test all your components. You can create a react app to test them or use the tool that the industry uses, Storybook. You can easily create an isolated environment to test your components and test them. It comes with a ton of features to help you with your work.&lt;/p&gt;

&lt;p&gt;It can do a lot of testing for you. If you can automate the testing of the components, you can check Cypress or PlayWright. They can even provide you with screenshots of when the error occurred.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Docs
&lt;/h2&gt;

&lt;p&gt;Documentation is important! You should most definitely write about your components on how to use them. You just need a simple website or even just use MD files to write about them.&lt;/p&gt;

&lt;p&gt;It doesn't need to be perfect but just enough so that others can understand. Add property tables, examples, and other things so that people can start using them.&lt;/p&gt;

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

&lt;p&gt;I learned a lot. From building better components to libraries and publishing them on npm. It took me 6 months to complete all of this. And yes I know this sounds like a lot of time, but I had my fun. Building this gave me insight into what goes into building a library which others can also use and cherish.&lt;/p&gt;

&lt;p&gt;The thing I love most about JS is that there are a ton of tools to choose from. These tools which I have listed here are the ones, which worked for me and my team. And there are plenty of more options out there which work for you. So don't be shy and do tell us about some of the alternatives that worked for you.&lt;/p&gt;

&lt;p&gt;If you want to check out my component lib, here are the links -&lt;/p&gt;

&lt;h3&gt;
  
  
  @rafty/ui
&lt;/h3&gt;

&lt;p&gt;GitHub - &lt;a href="https://github.com/rhinobase/raftyui"&gt;github.com/rhinobase/raftyui&lt;/a&gt;&lt;br&gt;
Docs - &lt;a href="https://rafty.rhinobase.io"&gt;rafty.rhinobase.io&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Do let me know what you think about it and how we can boost the community in the future. Do show us your support by giving us a star and for more content like this in the future.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>react</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Squeezing more performance out of your Nextjs App</title>
      <dc:creator>Aditya Mathur</dc:creator>
      <pubDate>Mon, 05 Feb 2024 09:43:44 +0000</pubDate>
      <link>https://dev.to/mathuraditya7/squeezing-more-performance-out-of-your-nextjs-app-5fp4</link>
      <guid>https://dev.to/mathuraditya7/squeezing-more-performance-out-of-your-nextjs-app-5fp4</guid>
      <description>&lt;p&gt;Presenting the Page Speed score for a recent project undertaken for a client.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgqvac5jhn06dq9zuel1r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgqvac5jhn06dq9zuel1r.png" alt="Page Speed Score for the website" width="563" height="119"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A bit about the website and all the requirements we had while making it -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;More than 100 pages (This doesn't include the dynamic pages) 😳&lt;/li&gt;
&lt;li&gt;Multiple data endpoints for fetching the content 🫠&lt;/li&gt;
&lt;li&gt;Tons of High Res Images (Static and Dynamic) 👀&lt;/li&gt;
&lt;li&gt;Live Preview when editing articles and events&lt;/li&gt;
&lt;li&gt;and Low Latency (Of course! 😭)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Typical client requirements for websites these days. 🫣&lt;/p&gt;

&lt;p&gt;Now some of you might already know that &lt;em&gt;Next JS&lt;/em&gt; fits perfectly for making projects like these and does most of the heavy lifting for you. So honestly, these things can be easily achieved using Nextjs features like &lt;strong&gt;Draft Mode&lt;/strong&gt;, &lt;strong&gt;Image&lt;/strong&gt;, &lt;strong&gt;ISR&lt;/strong&gt;, and others. But in this article, we will not be going into details of these.&lt;/p&gt;

&lt;p&gt;Being a developer your job is to build and integrate ideas and requirements faster. And build an app that is easy to use for your client and also for you to build upon it. And for this, it's not just the framework that we need to correctly choose but also the tools we use.&lt;/p&gt;

&lt;h2&gt;
  
  
  List of tools
&lt;/h2&gt;

&lt;p&gt;These are the tools we use daily to improve our DX when building any application.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. React Hook Forms 🔥
&lt;/h3&gt;

&lt;p&gt;The best package for building forms and managing their states. we have used a couple of the form builders in the past but we always land on this as the final choice for building robust and interactive forms.&lt;/p&gt;

&lt;p&gt;With their dev tools, your life is 10x better when debugging your forms.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://react-hook-form.com"&gt;https://react-hook-form.com&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Zod 🔮
&lt;/h3&gt;

&lt;p&gt;Validation === &lt;code&gt;zod&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It is simple, small, and powerful!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://zod.dev"&gt;https://zod.dev&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. TailwindCSS 🪄
&lt;/h3&gt;

&lt;p&gt;Believe me, when I say this, don't use &lt;code&gt;css-in-js&lt;/code&gt;. Just use Tailwind for building your app, it will be 3x more performant automatically. And the best thing about this is, there is no magic happening under the hood, It is what it is.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tailwindcss.com"&gt;https://tailwindcss.com&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Rafty UI ✨
&lt;/h3&gt;

&lt;p&gt;If you want to build fast, you need a component library and it should support Tailwind. There are a ton of libraries out there but in the end, they lack a ton of features compared to other Non TailwindCSS libraries.&lt;/p&gt;

&lt;p&gt;So we created our component library for this, it is open source and has a ton of features out of the box. Go check it out and let us know what you think.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://rafty.rhinobase.io"&gt;https://rafty.rhinobase.io&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  5. TanStack Query 🎆
&lt;/h3&gt;

&lt;p&gt;Hands down the best library for helping you manage data fetching and data re-validation. Use it with &lt;code&gt;axios&lt;/code&gt; for fetching data, it is an amazing combination.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tanstack.com/query/latest"&gt;https://tanstack.com/query/latest&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  6. React Icons 💖
&lt;/h3&gt;

&lt;p&gt;Need icons for your design, just use &lt;code&gt;react-icons&lt;/code&gt;. It does the job. It's more than just a package full of icons. You can use these builtin providers to improve your DX more.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://react-icons.github.io/react-icons"&gt;https://react-icons.github.io/react-icons&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;These are just our opinions on tools that we love using when building an application. You might have a different stack or set of libraries that you use, comment them down below and we can give feedback on them.&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>webdev</category>
      <category>tutorial</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Tools to build lightweight React Apps</title>
      <dc:creator>Aditya Mathur</dc:creator>
      <pubDate>Sat, 04 Nov 2023 05:44:33 +0000</pubDate>
      <link>https://dev.to/mathuraditya7/tools-to-build-lightweight-react-apps-1p3b</link>
      <guid>https://dev.to/mathuraditya7/tools-to-build-lightweight-react-apps-1p3b</guid>
      <description>&lt;p&gt;TLDR;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;@rafty/ui&lt;/code&gt; - &lt;a href="https://rafty.rhinobase.io"&gt;Rafty UI&lt;/a&gt; for UI components&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;zustand&lt;/code&gt; - &lt;a href="https://docs.pmnd.rs/zustand/getting-started/introduction"&gt;Zustand&lt;/a&gt; for managing states&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;tailwindcss&lt;/code&gt; - &lt;a href="https://tailwindcss.com/"&gt;TailwindCSS&lt;/a&gt; for styling your components&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;dndkit&lt;/code&gt; - &lt;a href="https://dndkit.com/"&gt;DNDKit&lt;/a&gt; for working with DND stuff&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;lodash&lt;/code&gt; - &lt;a href="https://lodash.com/"&gt;Lodash&lt;/a&gt; for utility functions&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;React is a great tool for building applications, thanks to its extensive ecosystem and welcoming community. You can create both simple and complex applications easily with React, whether you choose to use frameworks like &lt;em&gt;Next.js&lt;/em&gt; and &lt;em&gt;Remix&lt;/em&gt; or not. However, these applications can quickly become quite large if you haven’t planned ahead. This is where tools like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Chakra, MUI for UI,&lt;/li&gt;
&lt;li&gt;Redux, React Context for state management,&lt;/li&gt;
&lt;li&gt;and many others come into play.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These libraries are undoubtedly valuable and can alleviate many development challenges, but incorporating them into your app can significantly increase its size. You might wonder why this is a problem, so let’s first explore that.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;We can summarize the problem in 4 key points - &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Big bundle size&lt;/strong&gt; - This means your app requires more bandwidth and time to render on the client, even if you employ code splitting or frameworks to separate the code into pages. Your overall build size remains substantial.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Time to compile&lt;/strong&gt; - Larger bundles necessitate more time for compilation, and Hot Module Reload (HMR) will also take more time to reflect changes in the app, leading to a less favorable Developer Experience (DX).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Slow Apps&lt;/strong&gt; - In a production environment, your app will perform slowly when delivering changes to clients. This slowness can also affect your development experience.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Device Support&lt;/strong&gt; - Since your application demands a significant amount of memory and processing power to render all components, it might not work well on lightweight laptops or older machines.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It’s essential to keep in mind that these issues primarily arise when building large-scale applications involving elements such as graphs, drag-and-drop functionality, data streams, multiple API requests, and other complex processing tasks. For your portfolio website, though, it should work just fine 😁.&lt;/p&gt;

&lt;p&gt;These problems can significantly impact the app you’re building, and unfortunately, you can’t entirely solve them, as the issue lies not in your code but in the libraries themselves.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Solution
&lt;/h2&gt;

&lt;p&gt;The solution is quite simple, migrate to these libs -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;@rafty/ui&lt;/code&gt; - &lt;a href="https://rafty.rhinobase.io"&gt;Rafty UI&lt;/a&gt; for UI components&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;zustand&lt;/code&gt; - &lt;a href="https://docs.pmnd.rs/zustand/getting-started/introduction"&gt;Zustand&lt;/a&gt; for managing states&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;tailwindcss&lt;/code&gt; - &lt;a href="https://tailwindcss.com/"&gt;TailwindCSS&lt;/a&gt; for styling your components&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;dndkit&lt;/code&gt; - &lt;a href="https://dndkit.com/"&gt;DNDKit&lt;/a&gt; for working with DND stuff&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;lodash&lt;/code&gt; - &lt;a href="https://lodash.com/"&gt;Lodash&lt;/a&gt; for utility functions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are my favorite libs to build applications in 2023, and there might be more. If you know any, tell us about it down in the comments.&lt;/p&gt;

</description>
      <category>react</category>
      <category>typescript</category>
      <category>nextjs</category>
      <category>opensource</category>
    </item>
    <item>
      <title>How React Component Libraries are Changing</title>
      <dc:creator>Aditya Mathur</dc:creator>
      <pubDate>Tue, 31 Oct 2023 11:33:54 +0000</pubDate>
      <link>https://dev.to/mathuraditya7/how-react-component-libraries-are-changing-p71</link>
      <guid>https://dev.to/mathuraditya7/how-react-component-libraries-are-changing-p71</guid>
      <description>&lt;h2&gt;
  
  
  Quick Overview of SSR
&lt;/h2&gt;

&lt;p&gt;Lately, you may have heard about the rise of Server-Side Rendering (SSR) components in React, particularly if you are coming from the Next.js ecosystem. This change is reshaping how we use and interact with React Component Libraries.&lt;/p&gt;

&lt;p&gt;If you’re transitioning from the Page Router or the core React application, you’re likely accustomed to rendering applications on the client side. This implies that all the calculations, processing, and data fetching occur on the client. However, things are evolving rapidly, primarily due to &lt;a href="https://react.dev/blog/2020/12/21/data-fetching-with-react-server-components"&gt;React Server Components&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;While there are numerous articles and videos available for a more in-depth understanding of React Server Components, here’s a brief overview: it allows us to render components on the server, encompassing all calculations, processing, and data fetching on the server side. The client only receives HTML and CSS, which should result in faster page loading speeds and an improved user experience for your customers.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;However, there’s a catch: if you’re using hooks in a component, that component must be designated as a client component. React hooks cannot be rendered on the server since the API is unavailable there. To address this, you’ll need to annotate these components with the &lt;code&gt;“use client”&lt;/code&gt; keyword. Once you’ve marked a parent component with this keyword, all its child components will be rendered as Client Components, even if they aren’t utilizing hooks.&lt;/p&gt;

&lt;p&gt;But how is all this affecting the React Component Libs?&lt;/p&gt;

&lt;p&gt;Check out this example on &lt;code&gt;Chakra-UI&lt;/code&gt; docs -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// app/page.tsx&lt;/span&gt;
&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;use client&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;Link&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;@chakra-ui/next-js&lt;/span&gt;&lt;span class="dl"&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;Page&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="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Link&lt;/span&gt; &lt;span class="na"&gt;href&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;'/about'&lt;/span&gt; &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;'blue.400'&lt;/span&gt; &lt;span class="na"&gt;_hover&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&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;blue.500&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      About
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Link&lt;/span&gt;&lt;span class="p"&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;As you can see, even for just a simple link, we must use the &lt;code&gt;“use client”&lt;/code&gt; keyword. This is also required in the &lt;code&gt;page.tsx&lt;/code&gt;, which implies that all components within this file will be client-rendered, potentially negating the advantages of the Next.js 13 App Router.&lt;/p&gt;

&lt;p&gt;One might argue that you could create a separate component for this Link Component to eliminate the need for using the &lt;code&gt;“use client”&lt;/code&gt; keyword in the main page file. However, this approach could lead to creating numerous components solely to avoid using the &lt;code&gt;“use client”&lt;/code&gt; keyword, which may not be practical in the long run.&lt;/p&gt;

&lt;h3&gt;
  
  
  This is not a solution, This is a hack!
&lt;/h3&gt;

&lt;p&gt;The crux of the issue lies in the necessity of adding the &lt;code&gt;“use client”&lt;/code&gt; keyword to all components. However, the challenge is exacerbated by the bloat that some libraries exhibit due to their architecture and underlying foundations. Notably, libraries like Chakra UI, MUI, and Ant Design handle this challenge with varying degrees of success.&lt;/p&gt;

&lt;p&gt;A substantial portion of this bloat can be attributed to the libraries’ use of providers, such as &lt;code&gt;ThemeProvider&lt;/code&gt;. Over time, these providers have grown in size and weight. As a result, building large applications with these libraries becomes increasingly complex and resource-intensive, particularly in cases like creating a data-rich dashboard or a substantial form with more than 50 fields, essentially a sizeable component on a single page.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Solution - &lt;em&gt;Micro Context Components&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;By simplifying the context of components to their core functionality, we can reduce this overhead and develop lightweight applications. This transformation is made possible by libraries and tools like TailwindCSS, Radix UI, Adobe Aria, and many others.&lt;/p&gt;

&lt;p&gt;Instead of relying on a &lt;code&gt;ThemeProvider&lt;/code&gt; to handle light and dark modes, we can leverage TailwindCSS. When it comes to creating components, Radix UI allows us to build accessible UI components. Additionally, we can establish micro-contexts on top of them to manage props related to sizing and color schemes.&lt;/p&gt;

&lt;p&gt;By adopting these approaches, we can cut our application’s size in half, enhance accessibility, and improve speed, all without any compromises.&lt;/p&gt;

&lt;p&gt;There are tons of lib that are built to solve these problems and you can start using them right away - &lt;/p&gt;

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

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://rafty.rhinobase.io"&gt;Rafty UI&lt;/a&gt; (Created by Me 😁)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.radix-ui.com/"&gt;Radix Themes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://daisyui.com/"&gt;Daisy UI&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;and many more.&lt;/p&gt;

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

&lt;p&gt;React is a fantastic framework for building applications due to its extensive ecosystem and the high demand from companies seeking React developers. However, things can quickly get out of hand if not managed properly. These libraries can help prevent you from making common mistakes by offering lightweight components.&lt;/p&gt;

&lt;p&gt;Rafty UI effectively addresses this issue by leveraging readily available tools like TailwindCSS and Radix UI, resulting in a very shallow learning curve. In fact, you can get started with it in just a few hours and create impressive applications. I’ve been using it for a while now, and it’s truly remarkable how compact and lightning-fast my applications have become.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Do let me know what you guys think about &lt;a href="https://rafty.rhinobase.io"&gt;Rafty UI&lt;/a&gt;!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you have any questions, do let me know and I will be happy to answer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disclaimer&lt;/strong&gt; - As of right now, this is the scene as per best of my knowledge, but with the ever-changing world, these Libs might come up with some amazing solutions but nothing like that seems to be happening soon. Right now things seem to be moving towards the &lt;strong&gt;Micro Context&lt;/strong&gt; based React Component Libs.&lt;/p&gt;

&lt;p&gt;Let me know what you all think, in the comments.&lt;/p&gt;

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