<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Fabio Biondi on Medium]]></title>
        <description><![CDATA[Stories by Fabio Biondi on Medium]]></description>
        <link>https://medium.com/@biondifabio?source=rss-6811aef7b11------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*oedl7L9aP0Jsk3IIH7OOug.jpeg</url>
            <title>Stories by Fabio Biondi on Medium</title>
            <link>https://medium.com/@biondifabio?source=rss-6811aef7b11------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 06:36:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@biondifabio/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Qwik & Arduino with Johnny Five]]></title>
            <link>https://biondifabio.medium.com/qwik-arduino-with-johnny-five-9f3c0431f691?source=rss-6811aef7b11------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f3c0431f691</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[arduino]]></category>
            <category><![CDATA[qwik]]></category>
            <category><![CDATA[qwiklabs]]></category>
            <category><![CDATA[johnny-five]]></category>
            <dc:creator><![CDATA[Fabio Biondi]]></dc:creator>
            <pubDate>Mon, 13 Nov 2023 23:01:58 GMT</pubDate>
            <atom:updated>2023-11-13T23:08:24.226Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*13oxUud_mJ_CLTErCKAItA.jpeg" /></figure><p>Some days ago I have shared some experiments I have recently done with Qwik and Arduino on my <a href="https://www.linkedin.com/in/fabiobiondi/">LinkedIn</a> and <a href="https://twitter.com/biondifabio">Twitter</a> profiles.</p><p>A lot of people asked me more details about it, so I wrote this article to explain what I did.</p><p>Anyway, as the post title suggests, we can control Arduino, Raspberry and other micro-controllers directly from a front-end application built in JavaScript 😱.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F883641389%3Fapp_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F883641389&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F1752313233-ea15307d490be034fde1c25e8fa9d7ef877dc7ce02669a7a41386153b3cb6cb7-d_1280&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/49f32fc73bb3440caab2bafca688eca2/href">https://medium.com/media/49f32fc73bb3440caab2bafca688eca2/href</a></iframe><h3>Johnny Five</h3><p>Some times ago I have played with <a href="https://johnny-five.io/">johnny-five</a>, a JavaScript Robotics &amp; IoT platform.<br>In short words, we can communicate with our Arduino or Raspberry by using JavaScript with a very friendly syntax.</p><p>For example, to blink a LED you can :</p><p>1) Connect a LED to PIN 13 of your Arduino board:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/0*gpfLhSizI5Xg5hig.png" /></figure><p>2) Create a JavaScript module, i.e. index.js:</p><pre>const { Board, Led } = require(&quot;johnny-five&quot;);<br><br>// connect your board<br>const board = new Board();<br>// when board is ready<br>board.on(&quot;ready&quot;, () =&gt; {<br>  // Create a standard `led` component instance<br>  const led = new Led(13);<br>  // &quot;blink&quot; the led in 500ms<br>  // on-off phase periods<br>  led.blink(500);<br>});</pre><p>3) Run the code in your terminal</p><pre>node index.js</pre><blockquote><em>I have used </em><a href="https://nodejs.org/en/"><em>Node</em></a><em> v.18</em></blockquote><p>Here you can find more details about the installation of Johnny Five and how the previous example works:</p><p>• <a href="https://github.com/rwaldron/johnny-five/wiki/Getting-Started">Johnny Five Get Started</a><br>• <a href="https://johnny-five.io/examples/">Johnny Five Examples</a></p><h3>Qwik</h3><p><a href="https://qwik.builder.io/">Qwik</a> is a full-stack web framework to create super-performing and SEO friendly applications.</p><p>One of its most interesting features is the server$ functions, that allow you to create a function that is always executed on the server.</p><blockquote><em>server$ is a form of RPC (Remote Procedure Call) mechanism between the client and server, just like a traditional HTTP endpoint but strongly typed thanks to Typescript, and easier to maintain.<br>Source: </em><a href="https://qwik.builder.io/docs/server$/"><em>Qwik server$ Documentation</em></a></blockquote><p>Following I show you a very basic example of server$ function:</p><pre>import { component$, useSignal } from &#39;@builder.io/qwik&#39;;<br>import { server$ } from &#39;@builder.io/qwik-city&#39;;<br><br>// executed on server<br>const serverGreeter = server$((firstName: string) =&gt; {<br>  const greeting = `Hello ${firstName}`;<br>  return greeting;<br>});<br><br>export default component$(() =&gt; {<br>  // Signal to contains the input value<br>  const text = useSignal(&#39;&#39;);<br><br>  return (<br>    &lt;&gt;<br>      &lt;label&gt;<br>        Your Name:<br>        &lt;input bind:value={text} /&gt;<br>      &lt;/label&gt;<br>      &lt;button<br>        onClick$={async () =&gt; {<br>          // invoke the server$ function <br>          // passing the input text value<br>          // when button is clicked <br>          const greeting = await serverGreeter(text.value);<br>          alert(greeting);<br>        }}<br>      &gt;<br>        greet<br>      &lt;/button&gt;<br>    &lt;/&gt;<br>  );<br>});</pre><h3>Blink LED with Johnny Five &amp; Qwik</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*eA7FhEDDNwX315J_.jpg" /></figure><p>Since the Qwik $server function always run on server, we can use any package designed to run in a Node.js environment.</p><p>So my first thought was: <br><em>&lt;&lt; maybe I can use Johnny Five directly on Qwik to control my Arduino &gt;&gt;</em><br>And yes, it worked! 😍</p><p>Let me show you how I did:</p><p>1) First, connect a LED to PIN 13 of your Arduino Board</p><p>2) Create a new <a href="https://qwik.builder.io/docs/getting-started/">Qwik Project</a>:</p><pre># create the project<br>npm create qwik@latest<br><br># Run the project <br>npm run dev</pre><p>This process creates a basic Qwik Project with a couple of routes.</p><p>3) Now we can open and update the default route component (routes/index.tsx):</p><ul><li>create a button whose click we invoke the server function</li><li>import the “johnnyfive” package, create a Board instance and use its API to define the PIN 13 and blink the connected LED:</li></ul><pre>// routes/index.tsx<br>import { component$, useSignal } from &#39;@builder.io/qwik&#39;;<br>import { server$ } from &#39;@builder.io/qwik-city&#39;;<br>import five, { Board, Led } from &#39;johnny-five&#39;<br><br>const board = new five.Board();<br><br>const arduinoBlink = server$(() =&gt; {<br>  // Define LED PIN<br>  const led = new Led(13);<br>  // Blink<br>  led.blink(555);<br>});<br><br>export default component$(() =&gt; {<br>  return (<br>    &lt;&gt;<br>      &lt;button<br>        onClick$={async () =&gt; {<br>          // Blink LED<br>          // Invoke the server function <br>          // when button is clicked<br>          await arduinoBlink();<br>        }}<br>      &gt; BLINK LED &lt;/button&gt;<br>    &lt;/&gt;<br>  );<br>});</pre><p><a href="https://johnny-five.io/examples/led/">Johnny Five Blink Example</a></p><h3>LCD display</h3><p>Johnny Five allow us to easily use sensors, LCDs, Servo / Motors, Joysticks and several other devices.</p><p>For example you can easily <a href="https://johnny-five.io/examples/lcd/">write into a LCD display</a> as well:</p><pre>// Define LCD PINS <br>const lcd = new five.LCD({ pins: [7, 8, 9, 10, 11, 12] });<br>// Move the cursors to positio 0,0 and display a text<br>lcd.cursor(0, 0).print(&#39;Hello Qwik!&#39;);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*NhU9IYkwrD_tztM9.png" /></figure><p>So, as you can imagine you can use this snippet of code in a Qwik server$ function as we did to blink the LED.</p><p>1) First, we can create a JS module in which we write the functions that contains the logic to communicate with the hardware and that are invoked by the server$ function:</p><pre>// arduino.server.ts<br>import { server$ } from &#39;@builder.io/qwik-city&#39;;<br>import five, { Board, Led } from &#39;johnny-five&#39;<br><br>const board = new five.Board();<br>export const arduinoBlinkFn = () =&gt; {<br>  const led = new Led(13);<br>  led.blink(555);<br>};<br>export const arduinoLCDFn = server$((<br>  text1: string, text2: string<br>) =&gt; {<br>  // Define LCD PINS <br>  const lcd = new five.LCD({ pins: [7, 8, 9, 10, 11, 12] });<br>  // display text1 in the first line of the display<br>  lcd.cursor(0, 0).print(text1);<br>  // display text2 in the second line<br>  lcd.cursor(1, 0).print(text2);<br>});</pre><p>2) Now we can simply create the UI in Qwik using JSX syntax, adding a couple of text inputs and a button to send both texts to the device.</p><p>The arduinoLCDFn() server function is invoked when the button is clicked, passing the values of both text inputs.</p><pre>// routes/index.tsx<br>import { component$, useSignal } from &#39;@builder.io/qwik&#39;;<br>import { server$ } from &#39;@builder.io/qwik-city&#39;;<br>import { arduinoBlinkFn, arduinoLCDFn } from &#39;~/arduino.server.utils&#39;;<br><br>const arduinoBlink = server$(() =&gt; {<br>  arduinoBlinkFn()<br>});<br><br>const arduinoLCD = server$((<br>  text1: string, text2: string<br>) =&gt; {<br>  arduinoLCDFn(text1, text2)<br>});<br><br><br>export default component$(() =&gt; {<br>  const textRow1 = useSignal(&#39;&#39;);<br>  const textRow2 = useSignal(&#39;&#39;);<br>  return (&lt;&gt;<br>    &lt;button<br>      onClick$={async () =&gt; {<br>        await arduinoBlink();<br>      }}<br>    &gt; BLINK LED &lt;/button&gt;<br>    &lt;input type=&quot;text&quot; bind:value={textRow1} placeholder=&quot;row 1&quot;  /&gt;<br>    &lt;input type=&quot;text&quot; bind:value={textRow2} placeholder=&quot;row 2&quot;  /&gt;<br>    &lt;button<br>      onClick$={async () =&gt; {<br>        await arduinoLCDFn(textRow1.value, textRow2.value);<br>      }}<br>    &gt; WRITE ON LCD &lt;/button&gt;<br>  &lt;/&gt;);<br>});</pre><p>Here the final result:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F883641389%3Fapp_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F883641389&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F1752313233-ea15307d490be034fde1c25e8fa9d7ef877dc7ce02669a7a41386153b3cb6cb7-d_1280&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/49f32fc73bb3440caab2bafca688eca2/href">https://medium.com/media/49f32fc73bb3440caab2bafca688eca2/href</a></iframe><h3>Conclusion</h3><p>Of course it’s nothing special but this example demonstrates the simplicity and flexibility with which we can use any JavaScript modules within the server function.</p><p>How cool is that?<br>What do you think?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f3c0431f691" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create web components using Google Lit]]></title>
            <link>https://biondifabio.medium.com/create-web-components-using-google-lit-71099093b8fc?source=rss-6811aef7b11------2</link>
            <guid isPermaLink="false">https://medium.com/p/71099093b8fc</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[lit]]></category>
            <category><![CDATA[web-components]]></category>
            <category><![CDATA[google]]></category>
            <dc:creator><![CDATA[Fabio Biondi]]></dc:creator>
            <pubDate>Fri, 17 Jun 2022 14:06:42 GMT</pubDate>
            <atom:updated>2022-06-17T14:17:45.963Z</atom:updated>
            <content:encoded><![CDATA[<p>Web components are a set of technologies that allow us to create reusable HTML elements, in which all features are encapsulated within their code.</p><p>The advantage of using web components is that they can be used anywhere: in HTML/VanillaJS, Vue, <a href="https://www.linkedin.com/feed/hashtag/?keywords=react&amp;highlightedUpdateUrns=urn%3Ali%3Aactivity%3A6943560854025994240">#react</a>, <a href="https://www.linkedin.com/feed/hashtag/?keywords=angular&amp;highlightedUpdateUrns=urn%3Ali%3Aactivity%3A6943560854025994240">#angular</a> applications and in any other modern (or future) JS framework/library.</p><p>However, Native APIs for creating <a href="https://www.linkedin.com/feed/hashtag/?keywords=webcomponents&amp;highlightedUpdateUrns=urn%3Ali%3Aactivity%3A6943560854025994240">#webcomponents</a> are not very pleasant to use. The DX is horrible 🤮</p><p>Frameworks like “Google <a href="https://www.linkedin.com/feed/hashtag/?keywords=lit&amp;highlightedUpdateUrns=urn%3Ali%3Aactivity%3A6943560854025994240">#lit</a>” greatly simplify their creation and in these slides I’ll describe:<br>➡️ how to create web components using Lit<br>➡️ publish a web component on npm<br>➡️ use the web component in vanilla JS, Angular and React</p><p>Let me know if you liked this content and remember to follow me on:</p><p>• YouTube: <a href="https://lnkd.in/gTjvc_J4">https://lnkd.in/gTjvc_J4</a><br>• Twitch: <a href="https://lnkd.in/d2v6mHc">https://lnkd.in/d2v6mHc</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.slideshare.net%2Fslideshow%2Fembed_code%2Fkey%2Ft5Htp4oCs21hgo&amp;display_name=SlideShare&amp;url=https%3A%2F%2Fwww.slideshare.net%2Ffabio_biondi%2Fcreate-web-components-using-google-lit&amp;image=https%3A%2F%2Fcdn.slidesharecdn.com%2Fss_thumbnails%2F1-220617135754-7afafd77-thumbnail-4.jpg%3Fcb%3D1655474312&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=slideshare" width="600" height="640" frameborder="0" scrolling="no"><a href="https://medium.com/media/3467ce9ec4f7733f5df5613ee407c01a/href">https://medium.com/media/3467ce9ec4f7733f5df5613ee407c01a/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SEjMu3cHBCxbTRRqTRK61A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*shDkeCLPsFEJAN8ZAFx2ww.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dn6avg-6ILLVh5TfvE85NQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cq3X3K878VeiBX9c00fgyg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*31BsuBHQ1p2rxbOOqD6klA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lL24PBWt-kPqRqw6egZV1g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gYEIhqqn8XJpE8xEhbCRHQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nY7bC1AoNQmoNNAi2kAjuw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tM9It9Yu6bCHN1C9DCWSkA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hcS-0S-IA1vvqPHtgRWIUQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3hRd_PLhQZuknycJS0etLg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tOI1ZUVYH3hqoSOKmK6-JA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71099093b8fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular 14 features: videos & tips]]></title>
            <link>https://biondifabio.medium.com/angular-14-features-videos-tips-98b4bc32e788?source=rss-6811aef7b11------2</link>
            <guid isPermaLink="false">https://medium.com/p/98b4bc32e788</guid>
            <category><![CDATA[news]]></category>
            <category><![CDATA[components]]></category>
            <category><![CDATA[modules]]></category>
            <category><![CDATA[tools]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Fabio Biondi]]></dc:creator>
            <pubDate>Wed, 18 May 2022 23:30:18 GMT</pubDate>
            <atom:updated>2022-05-22T22:28:14.609Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JCV-an09Kpp2gDhLjGlftA.png" /></figure><p>A collection of videos and tips about the most interesting features introduced by <strong>Angular 14: standalone components</strong>, <strong>ng completion</strong>, <strong>typed forms</strong> (coming soon), <strong>DI </strong>new features and more.<br>The list is not complete and I will gradually update in the next weeks.</p><blockquote>All videos are just quick tips, so they are very fast and, for this reason, they are suitable for developers who are already familiar with the framework.</blockquote><h3>Install Angular 14</h3><p>Since the Angular current version is 13.x, if you want to try some of the new interesting features introduced by the version 14, you must install the release candidate of the CLI using the following command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*go7UXFm1urmTICgrXyqgFQ.png" /></figure><h3>Angular 14 &amp; Standalone Components</h3><p>In this video I show you one of the most interesting features introduced by Angular V14: <strong>standalone components</strong>.</p><p>Standalone components can be used by the framework without needing to be declared in any module, they can be lazy-loaded, they can import other modules and much more.<br>In the video we will also explore a couple of new features provided by the router.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F3Gw-qfxEOSw%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D3Gw-qfxEOSw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F3Gw-qfxEOSw%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/9e23e75d356961ba9a2441de79c7b9a8/href">https://medium.com/media/9e23e75d356961ba9a2441de79c7b9a8/href</a></iframe><h3>How to create Angular (14) applications without ngModules (by using Standalone Components)</h3><p>In the next video I describe how to create an Angular application without <strong>ngModules</strong>, that only use standalone components.</p><p>We’ll also see :</p><p>➡️ application bootstrap with standalone components<br>➡️ how to use standalone components and directives in other components <br>➡️ how to handle dependency injection <br>➡️ create routes, nested routes and navigation <br>➡️ lazy loading with standalone components</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FmVCQgk9_RRg%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DmVCQgk9_RRg&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FmVCQgk9_RRg%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/fbf8f73a95393dc208475f5cf79715cf/href">https://medium.com/media/fbf8f73a95393dc208475f5cf79715cf/href</a></iframe><h3>Angular 14: ng completion</h3><p><strong>ng completion</strong> is a new cool feature introduced in Angular CLI version 14 that allow you to add real-time type-ahead autocompletion in your terminal (bash or zsh).</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FKrlQFiGhjnE%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DKrlQFiGhjnE&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FKrlQFiGhjnE%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/1664ea029bc5db325527dc051828de7e/href">https://medium.com/media/1664ea029bc5db325527dc051828de7e/href</a></iframe><h3>The “inject” function</h3><p>In this short video I will show you some tricks to use the new “inject” feature provided by Angular 14, a utility to inject a token from the currently active injector. Topics:</p><ul><li>How to use the <strong>inject</strong> function</li><li>Built-in and custom Services</li><li>Injection Token</li><li>useFactory</li><li>use <strong>inject </strong>in functions</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F4jHg9_Jb7RM%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D4jHg9_Jb7RM&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F4jHg9_Jb7RM%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/16be7db0bbee666810776f78962aa14c/href">https://medium.com/media/16be7db0bbee666810776f78962aa14c/href</a></iframe><p>You can find more videos about Angular, React, Lit and several web technologies on my <a href="https://www.youtube.com/c/FabioBiondi">YouTube Channel</a> and you may also be interested in my <a href="https://www.twitch.tv/fabio_biondi">Twitch Channel</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98b4bc32e788" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quick animated introduction to Pre-Rendering, SSR and SSG in NextJS]]></title>
            <link>https://biondifabio.medium.com/quick-animated-introduction-to-pre-rendering-ssr-and-ssg-in-nextjs-ecb5920100c7?source=rss-6811aef7b11------2</link>
            <guid isPermaLink="false">https://medium.com/p/ecb5920100c7</guid>
            <category><![CDATA[static-site-generation]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[server-side-rendering]]></category>
            <category><![CDATA[seo]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Fabio Biondi]]></dc:creator>
            <pubDate>Sun, 06 Mar 2022 20:16:04 GMT</pubDate>
            <atom:updated>2022-03-06T20:16:47.525Z</atom:updated>
            <content:encoded><![CDATA[<p>I have noticed that the concept of pre-rendering, SSR and SSG is not very clear to many developers.</p><p>So let’s do some clarity them using <a href="https://reactjs.org/">React</a> and <a href="https://nextjs.org/">NextJS</a> and some animations I have created.</p><h3>Pre-rendering: React vs NextJS</h3><p>Lest’ start with the concept of pre-rendering.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*Y3CpcDEchDBFswz3oKSV2g.gif" /></figure><p>In React and in SPAs in general, you usually have a single HTML page for the whole application and routes are “simulated” by destroying and creating components.</p><p>Your data are often acquired via REST API (or e.g. Graph QL) on the client side with a simple fetch when the component is initialized. For example, in React by using the <em>useEffect</em> hook, in Angular by using the ngOnInit lifecycle method and so on. <br>However, <strong>in this way, you will obtain a first render of the page without data that will be displayed only at the second render</strong>. <br>The result is superfluous rendering (so bad performance), longer loading times and very poor search engine results.</p><p><strong>NextJS</strong>, on the other hand,<strong> pre-renders each page.</strong></p><p>What does it mean?</p><p>Next, behind the scenes, uses several strategies to generate a different html for each single page of your app/website that already contain all data you need in the (first) render.<br>Each page can have its own title, metadata and is associated with the minimum JS code needed to make that page work.<br>This is automatically translates into better performance and SEO.</p><h3>Hydration</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*8QPLhIJl2zD5q4z_yrR4ng.gif" /></figure><p>When the page is loaded in the browser, a non-interactive version is first rendered, then the JS code necessary to make it work is loaded and finally the page becomes interactive.</p><p><strong>This process is called Hydration</strong>.</p><h3>SSR vs SSG</h3><p>What I love about NextJS is the simplicity, compared to any other framework, with which it is possible to take advantage of the pre-rendering.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*JJ08Em7cUokgTLZTNyI_YA.gif" /></figure><p>As I said earlier, React applications that need data acquired from external APIs usually have a first empty render, with no data, and then a second render in which the data is present.<br>This behavior can generate performance and SEO problems!</p><p>Thanks to the pre-rendering (done by NextJS) we can instead render a page that already contains data at the first render.</p><blockquote>Next offers three pre-rendering modes in order to optimize site performance and search engine optimization: <strong>Server Side Rendering (SSR)</strong>, <strong>Static Site Generation (SSG)</strong> and <strong>Incremental Static Regeneration (ISR)</strong>.</blockquote><p>In the animation above we see the differences between SSG and SSR.<br>1. SSG: pages are created at build time. When users request one of these pages NextJS provide a cached version where all data has been previously loaded and rendered on the page. <br>2. SSR: users request a page, NextJS fetch data behind the scenes, and the page is loaded.</p><h3>Mixing SSR and SSG</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*EBCkTpvtvZbhIwFyqf7t1g.gif" /></figure><p><strong>Next offers the possibility to choose the pre-rendering method for each individual page.</strong></p><p>It will then be possible to create Next hybrid applications that use SSG for some pages and SSR for others.<br>It is highly preferable to use SSG whenever possible. The applications will turn out really fast, as if “they were written in vanilla HTML / CSS”. <br>Sometimes you get the feeling of viewing a local site from your PC for how fast they are.</p><h3><strong>SSG with and without Data</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*aCMs3IxOBonttCGj_RZbnQ.gif" /></figure><p>When we create pages that do not require external data Next creates a static version of the page at build time (essentially HTML, CSS and the minimum JS code necessary to make it eventually interactive).<br>These pages act like normal React pages without pre-rendering in which it is still possible to make REST calls on the client side (i.e. by using <em>useEffect</em> hook and <em>fetch</em> API)</p><p>In many scenarios, however, we need to load data from external APIs, databases or even from local JSON and Markdown files. In this case Next will be able to make these requests during the build phase, acquiring the data and generating the static pages that already include all the data a page needs in the first render.<br>When data changes we have 3 ways to render the updates:</p><ol><li>a new build</li><li>re-deploy</li><li>use Incremental Site Regeneration (I’ll talk about this topic in another article)</li></ol><h3>Server Side Rendering (SSG)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*7TEKaVM6HhAHl0uDc4kjSw.gif" /></figure><p><em>Server side rendering</em> comes to our aid if, on the other hand, we need to acquire data at each user’s request. NextJS takes care of each user request, acquires the data from an external source and renders the page on the fly.</p><p>It can be <strong>very useful when data changes frequently but server-side costs could increase dramatically over time</strong>. Furthermore, if we use third-party APIs that have a cost based on consumption (YouTube, Google Map, Firebase API and so on) these costs could also increase.</p><h3>Conclusion</h3><p>I hope this article has clarified some aspects which I had a hard time understanding at first and I apologize for my English, but most of my content has usually been written in Italian.</p><p>Let me know if you liked the article and if you are interested in other content like this on the technologies I love: Angular, React, Redux, NGRx, Next, RxJS or JS / TS</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ecb5920100c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular Use Cases]]></title>
            <link>https://medium.com/series/angular-use-cases-a9089f0499ce?source=rss-6811aef7b11------2</link>
            <guid isPermaLink="false">https://medium.com/p/a9089f0499ce</guid>
            <dc:creator><![CDATA[Fabio Biondi]]></dc:creator>
            <pubDate>Sat, 20 Jul 2019 14:34:28 GMT</pubDate>
            <atom:updated>2019-07-20T14:34:28.649Z</atom:updated>
            <content:encoded><![CDATA[<img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9089f0499ce" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>