<?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: Ayoub Alouane</title>
    <description>The latest articles on DEV Community by Ayoub Alouane (@ayoub_alouane).</description>
    <link>https://dev.to/ayoub_alouane</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%2F1117404%2F134e85f1-22be-48d9-8251-71f77f4f910b.jpg</url>
      <title>DEV Community: Ayoub Alouane</title>
      <link>https://dev.to/ayoub_alouane</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ayoub_alouane"/>
    <language>en</language>
    <item>
      <title>MuleSoft Associate Certification: Essential Tips and Key Concepts</title>
      <dc:creator>Ayoub Alouane</dc:creator>
      <pubDate>Mon, 16 Sep 2024 21:22:01 +0000</pubDate>
      <link>https://dev.to/ayoub_alouane/mulesoft-associate-certification-essential-tips-and-key-concepts-201c</link>
      <guid>https://dev.to/ayoub_alouane/mulesoft-associate-certification-essential-tips-and-key-concepts-201c</guid>
      <description>&lt;p&gt;I was a little stressed, do you know why? Because I forgot the date of the exam. Fortunately, I had a small reminder from my agenda 30 minutes before the exam. I tried my best to quickly review the documentation I wrote when I was preparing for the exam.&lt;/p&gt;

&lt;p&gt;Make sure to have a good internet connection, and it might be helpful to restart your laptop. This will close all running programs that could potentially interrupt the browser required for taking the exam, which you will need to download before starting.&lt;/p&gt;

&lt;p&gt;The first thing you should know is that the associate certification tests your knowledge of Enterprise Integration concepts. You need to understand why we use MuleSoft, not just how to implement a listener and an object store. These technical details are important but not sufficient for the associate exam.&lt;/p&gt;

&lt;p&gt;It's also about your knowledge of cloud solutions. Having a good understanding of the differences between SaaS, PaaS, and IaaS, and knowing when to use them, will be beneficial. I can say that I had two or three questions about cloud solutions, including CloudHub and PCE. You should understand the differences, as well as the why and when of using these solutions.&lt;/p&gt;

&lt;p&gt;Before starting the exam, make sure you are familiar with the structure of a YAML file. You might have a question about that, as well as about JSON and XML. Additionally, review communication protocols such as gRPC, REST, and SOAP. There will be questions on these topics as well.&lt;/p&gt;

&lt;p&gt;Understanding systems such as Supply Chain Management (SCM), Customer Relationship Management (CRM), Enterprise Resource Planning (ERP), and Content Management Systems (CMS) is crucial. You should know the purpose of each system and read some scenarios of their use to have a solid understanding of the differences between them.&lt;/p&gt;

&lt;p&gt;Knowledge of project management methodologies is essential. You should understand what Kanban, Waterfall, Agile, and Scrum are. These concepts might seem irrelevant for a MuleSoft certification, but they are not. You will get at least one question about these concepts, so don't forget to review them.&lt;/p&gt;

&lt;p&gt;A thorough understanding of Integration Patterns, such as Consolidation, Orchestration, Aggregation, and Choreography, are unavoidable. A good understanding of these concepts is required because the exam focuses heavily on them. My advice is to thoroughly read about each one and try to implement them, which will give you a solid understanding of these patterns.&lt;/p&gt;

&lt;p&gt;Finally, ensure you know the components of the Anypoint Platform including Anypoint Exchange, Anypoint Runtime Plane, Anypoint Control Plane, Anypoint Runtime Manager, Anypoint API Manager, Anypoint Design Center, and Anypoint API Designer...Knowing the use of each component will help you answer at least three or four questions in the exam.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>From Disconnected Chaos to Unified Systems: The Evolution of Enterprise Integration</title>
      <dc:creator>Ayoub Alouane</dc:creator>
      <pubDate>Sun, 25 Feb 2024 22:08:02 +0000</pubDate>
      <link>https://dev.to/playfulprogramming/from-disconnected-chaos-to-unified-systems-the-evolution-of-enterprise-integration-28nh</link>
      <guid>https://dev.to/playfulprogramming/from-disconnected-chaos-to-unified-systems-the-evolution-of-enterprise-integration-28nh</guid>
      <description>&lt;h2&gt;
  
  
  Introduction:
&lt;/h2&gt;

&lt;p&gt;Before explaining what an ESB (Enterprise Service Bus) is, we should establish some context. The first question to ask is: What brought us to here? The answer is not simple because it depends on problems that perhaps modern developers have not faced.&lt;/p&gt;

&lt;p&gt;If you are working in a large company, you might constantly wonder how you arrived at the current state and what might have been overlooked. If you're an architect, or someone with a role that's complex to define, by examining multiple projects within your company, you'll notice that applications have cohesion among them. Yet, they are designed as if this isn't the case. This is often due to a lack of long-term vision. If these applications need to share information with each other, we're faced with a difficult technical and management process, because each app belongs to a different department and may be developed using different programming languages and tools. Here, I'm trying to highlight the importance of SOA (Service-Oriented Architecture).&lt;/p&gt;

&lt;p&gt;Perhaps members of the hierarchy are hesitating to collaborate and discuss their apps, but they need to, because they should offer a good service to the user at the minimum cost, otherwise, another company will.&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%2Fmm6g3hw1d0o26p65w6qy.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%2Fmm6g3hw1d0o26p65w6qy.png" alt="A conceptual artwork dividing the scene into two contrasting halves. On one side, illustrate the complexity and disconnection in a large company's IT" width="800" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How could we integrate apps in the past?
&lt;/h2&gt;

&lt;p&gt;When talking about sharing information (messages) between apps (services), we're not referring to someone who will write information on a sheet of paper and send it to a member of another team, who will then manually input it into their app. That method is inefficient, that's not what we're considering. We are trying to find a modern way to transfer messages that need to be secure, reliable, monitorable, manageable, and, finally, loosely coupled. It means that we should integrate our applications into a system so that they can communicate and share messages.&lt;/p&gt;

&lt;p&gt;But, when you're reading this article, do you think that we started with a perfect solution? Of course not, so let's take a deep dive into history.&lt;/p&gt;

&lt;h3&gt;
  
  
  Point-to-point integration
&lt;/h3&gt;

&lt;p&gt;Point-to-point integration was the first method employed to achieve integration between apps. Before I explain how it works, here is a figure that illustrates how point-to-point architecture functions:&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%2F3lf0yuzbjtfru21grp7n.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%2F3lf0yuzbjtfru21grp7n.png" alt="P2P Architecture" width="800" height="395"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The point-to-point integration approach connects two apps with a direct relationship. Imagine we want to establish communication between house 1 and house 2 using a P2P connection, we would have a direct line between the two, It means that if the line goes down, we will lose the connection between the two houses, herefore, we cannot confidently say that we have a reliable system. If we wanted to add house 3, we would need to add additional lines between houses 1 and 3, and 2 and 3, This means that our houses are tightly coupled. It's also insecure because we have a direct relationship, which becomes a single point of attack for spying on our data. Moreover, it's non-monitorible because we can't easily keep track of our communications due to the lack of a central monitoring system. And finally, it's non-manageable because managing direct lines between a large number of houses is challenging.&lt;/p&gt;

&lt;p&gt;Now, we can draw a parallel between houses and a service-oriented architecture. For instance, as seen in figure 4, service CRM is directly coupled to Sales, and HR is directly connected to Finance. This setup is risky because if we make changes in the Finance service, we must initiate a new integration process to adapt the all other services. And that's a laborious task to undertake each time we need to make modifications to the services.&lt;/p&gt;

&lt;p&gt;So, is this approach still applicable? Clearly not. After P2P, we moved on to something called Central EAI (Enterprise Application Integration) broker, which is a better approach. Let's explore this in the following paragraphs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Central Enterprise Application Integration Broker
&lt;/h3&gt;

&lt;p&gt;To be clear, this approach resolved all the P2P issues by connecting applications through a centralized system, and that's the key word: centralized. So, if we want to benefit from this approach, the leaders of each project or service must give up control to a centralized infrastructure where each service is integrated. Thus, our system will be secure, reliable, loosely coupled, monitorable, and manageable, but we will lose some control over our services.&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%2Fs6bbvfe45btn6d6ow5st.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%2Fs6bbvfe45btn6d6ow5st.png" alt="Central Enterprise Application Integration Broken" width="800" height="395"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Perhaps this seems a bit complicated, let's simplify it with a real-world example. Imagine our city has a single central post office instead of each person delivering their mail directly to recipients (P2P). Now, we need only to have the address of each recipient and send the mail to the central post office, which has complete control over the delivery process. This centralization ensures a secure process because the post office has invested in reducing the risk of theft or loss to a minimum. Additionally, the post office can easily monitor and manage mail through a system that keeps track of every parcel sent and received. This method is an improvement over the previous system, which was established to expedite mail delivery. If necessary, the post office will establish new processes to ensure delivery without involving the sender and the receiver in these issues.&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%2Frzuffr76daca0cynh209.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%2Frzuffr76daca0cynh209.png" alt="Visualize a simplified analogy of a centralized service model using a cityscape. In the foreground, depict individuals at a single, large, central post" width="800" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Just like the post office, the centralized EAI broker features a central hub responsible for the routing, security, monitoring, and transformation of data to ensure it is in a format that can be understood by the receiving service.&lt;/p&gt;

&lt;p&gt;Like we see, this architecture is great, it solved all of the P2P problems, but it created new ones. We now have a single point of failure, if the central hub id down, all the communications will fail, and it's really difficult to communicate with a service that we can't integrate into our centralized EAI broker because it's an external one that doesn't belong to our company.&lt;/p&gt;

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

&lt;p&gt;Now that we have reviewed the approaches we had in the past, in the coming articles we will cover the modern ways to integrate our services, without having the issues we faced previously.&lt;br&gt;
To give you a hint, imagine that instead of having a single centralized post office in our city, we have multiple small post offices that do the work and can scale if the city grows.&lt;br&gt;
See you in the next articles of this series.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>api</category>
      <category>softwareengineering</category>
      <category>microservices</category>
    </item>
    <item>
      <title>The Sisyphean Quest for Web Performance</title>
      <dc:creator>Ayoub Alouane</dc:creator>
      <pubDate>Tue, 29 Aug 2023 13:23:42 +0000</pubDate>
      <link>https://dev.to/playfulprogramming/the-sisyphean-quest-for-web-performance-22l3</link>
      <guid>https://dev.to/playfulprogramming/the-sisyphean-quest-for-web-performance-22l3</guid>
      <description>&lt;p&gt;It's been more than 12 years since we started using SPAs (Single Page Applications). This approach was revolutionary for DX (Developer Experience). However, in terms of web performance, we experienced a decline unlike any seen before, leading to catastrophic times for interactivity. Even now, we see this issue with applications built using frameworks that solely rely on SPAs. These frameworks have tried to improve their rendering methods. In this article, we will explain the evolution of rendering on the web, culminating with a spotlight on a new rendering technique that many believe will revolutionize web performance.&lt;/p&gt;

&lt;p&gt;The history of web development often begins with a total SSR, PHP &amp;amp; JQuery, for example. During those times, DX (Developer Experience) was challenging, and riddled with errors, and the code was complex and difficult to debug. While this article won't delve extensively into those aspects, it's worth noting that these tools offered developers complete autonomy over their application's architecture. Thus, any performance issues were often the result of mistakes in their code. In contrast, with SPAs (Single Page Applications), it's usually the framework itself that becomes the root cause of major performance problems.&lt;/p&gt;

&lt;h2&gt;
  
  
  Client Side Rendering (CSR)
&lt;/h2&gt;

&lt;p&gt;Single Page Applications (SPA) marked a significant shift in web development, a true revolution in building web apps. Initially, we were thrilled with the outstanding UX it provided. However, as time progressed, we began to encounter performance bottlenecks because we have started to use SPAs for startup critical applications such as ecomerce, where startup matters a lot . Our apps took longer to become visible and interactive. Often, users were greeted with a blank screen at the start, forced to wait. The more our apps relied on JavaScript, the longer these delays became. Regrettably, as we scaled our apps, we often sacrificed performance. This increasing complexity largely stemmed from one root issue: JavaScript's limitations.&lt;/p&gt;

&lt;p&gt;The question here is, it's because of what? it's because we should wait for the browser to download, execute, and render all the javascript of our application, to be visible and interactive, this figure shows us how it works:&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%2Fcwt0oowbmotpcusef9t5.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%2Fcwt0oowbmotpcusef9t5.png" alt="Client Side Rendering" width="800" height="382"&gt;&lt;/a&gt;Image Source: &lt;a href="https://www.youtube.com/watch?v=k-A2VfuUROg&amp;amp;feature=youtu.be" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=k-A2VfuUROg&amp;amp;feature=youtu.be&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To address these performance challenges, we experimented with various methods like lazy loading, preloading, and code splitting. However, as history would have it, these enhancements proved insufficient.&lt;/p&gt;

&lt;h2&gt;
  
  
  Server Side Rendering (SSR)
&lt;/h2&gt;

&lt;p&gt;As previously mentioned, SSR is a traditional method of rendering. However, it became essential to revisit this approach to tackle certain challenges. The primary concern was performance, prompting a reimagined approach to how SSR operates.&lt;/p&gt;

&lt;p&gt;After addressing the SPA issue, frameworks such as Angular and React sought to enhance their method of delivering page content to the browser. Instead of sending a blank HTML and then downloading the JavaScript for the entire web app to execute, they choose to generate the webpage on the server. This server-rendered page contains HTML, CSS, and also data from a database or an API. Once this is sent to the client, we have a page that is visible, completely visible, but unfortunately not interactive, so the JavaScript should be delivered and executed on the client side in order to add handlers to the DOM nodes, it meas that our page will be visible twice. This process is known as hydration, re-executing of application code in order to make the static page interactive. In simpler terms, the DOM will be "hydrated" with JavaScript.&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%2Fenw9ir78xm57ktccolo7.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%2Fenw9ir78xm57ktccolo7.png" alt="Server Side Rendering" width="800" height="490"&gt;&lt;/a&gt;Image Source: &lt;a href="https://developers.google.com/web/updates/2019/02/rendering-on-the-web" rel="noopener noreferrer"&gt;https://developers.google.com/web/updates/2019/02/rendering-on-the-web&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;the Time to Interactive is comparable to that of an SPA, if not longer, due to larger HTML payload. This marks the beginning of an extensive journey during which all frameworks will strive to optimize the hydration process as much as possible.&lt;/p&gt;

&lt;h2&gt;
  
  
  Static Site Generation (SSG)
&lt;/h2&gt;

&lt;p&gt;For websites focused on content that requires minimal interaction and feature content that doesn't frequently change, SSR might be an overkill. It can hinder the Time to First Byte, and CSR might negatively impact our Core Web Vitals. This calls for an alternative method, introducing Static Site Generation (SSG). With SSG, an HTML page is produced during build time for each potential route. So, if there are 3,000 articles, an individual HTML page will be generated for each during the build phase.&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%2Fsx21f8rgsdd9aanad7m4.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%2Fsx21f8rgsdd9aanad7m4.png" alt="Static Site Generation" width="800" height="442"&gt;&lt;/a&gt;Image Source: &lt;a href="https://www.patterns.dev/posts/incremental-static-rendering" rel="noopener noreferrer"&gt;https://www.patterns.dev/posts/incremental-static-rendering&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This approach appears to be efficient with great performance, but it's clear it has a drawback. For instance, every time a new article is created in the database, the entire website must be rebuilt and redeployed for that article to become accessible to users, here comes another approach.&lt;/p&gt;

&lt;h2&gt;
  
  
  Incremental Static Site Generation (iSSG)
&lt;/h2&gt;

&lt;p&gt;The name is clear, and the goal is clearer, iSSG is to fix the problem that we had with SSG, we don't need to rebuild and redeploy our websites, with iSSG we will be able to add new pages and also update existing pages.&lt;/p&gt;

&lt;p&gt;It's important to note that SSG or iSSG is best suited for sites that require minimal interactions and don't frequently update page content. While these rendering methods excel in terms of SEO and performance, they aren't ideal for web applications that demand extensive interactions with APIs or frequent changes to the page's state.&lt;/p&gt;

&lt;p&gt;While these methods aim for peak performance, they don't fit every scenario. Hence, a more versatile approach that addresses a broader range of cases is necessary.&lt;/p&gt;

&lt;h2&gt;
  
  
  Progressive Hydration
&lt;/h2&gt;

&lt;p&gt;The concept of progressive hydration in SSR is straightforward: enhancing the hydration process. With traditional Server-Side Rendering, while the page is visible, it isn't interactive – meaning buttons won't function initially. This is because we must wait for the entire JavaScript code to be downloaded and executed on the client side. However, progressive hydration, as its name implies, allows for the step-by-step hydration of our page. This means the hydration occurs node by node within the DOM. As a result, some buttons may become interactive immediately, while others lag behind due to the ongoing hydration process. Once this process concludes, the entire page achieves interactivity.&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%2Fslcrt7frzeu8mqdhpwls.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%2Fslcrt7frzeu8mqdhpwls.png" alt="Static Site Generation" width="800" height="300"&gt;&lt;/a&gt;Image Source: &lt;a href="https://www.patterns.dev/posts/progressive-hydration" rel="noopener noreferrer"&gt;https://www.patterns.dev/posts/progressive-hydration&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This method is good, but it still uses hydration, just in a better way. The challenge is guessing which part of the page a user might interact with next. It's great that users can quickly use parts of the page, but they might have to wait if they want to use other parts. They won't get full interaction until the whole page is ready.&lt;/p&gt;

&lt;h2&gt;
  
  
  Streaming Server-Side Rendering
&lt;/h2&gt;

&lt;p&gt;We've just delved into progressive hydration, where the DOM is hydrated step by step. Now, picture a scenario where the entire rendering process for the web page, including HTML and CSS, is also done progressively.&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%2Fohimoynpjguwkitra2cv.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%2Fohimoynpjguwkitra2cv.png" alt="Static Site Generation" width="800" height="295"&gt;&lt;/a&gt;Image Source: &lt;a href="https://www.patterns.dev/posts/streaming-ssr" rel="noopener noreferrer"&gt;https://www.patterns.dev/posts/streaming-ssr&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With this method, we send chunks of HTML and JavaScript to paint the user interface as quickly as possible. This ensures that users can interact with parts of the page almost immediately. This technique is effective in minimizing the Time to First Byte (TTFB), which is beneficial.&lt;/p&gt;

&lt;h2&gt;
  
  
  Selective Hydration
&lt;/h2&gt;

&lt;p&gt;Every server-side rendering technique we've discussed so far has its merits, but they aren't one-size-fits-all solutions. Consider a page we want to render using SSR that has a component requiring data on its initial load from an external API. This means there will be a delay in rendering the HTML on the server, which isn't ideal.&lt;/p&gt;

&lt;p&gt;Enter Selective Hydration. Instead of halting the entire page's rendering while waiting for a data-intensive component, this approach sends other components to the client first. These components are rendered and made interactive while the browser awaits the server-fetched data for the specific component in question.&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%2Fu2sykwu5gad0ehfp539v.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%2Fu2sykwu5gad0ehfp539v.png" alt="Selective Hydration" width="800" height="588"&gt;&lt;/a&gt;Image Source: &lt;a href="https://github.com/reactwg/react-18/discussions/37" rel="noopener noreferrer"&gt;https://github.com/reactwg/react-18/discussions/37&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Clearly, the hydration process for other components continues uninterrupted. This method boosts performance without negatively affecting other parts of our website.&lt;/p&gt;

&lt;h2&gt;
  
  
  React Server Components
&lt;/h2&gt;

&lt;p&gt;In the React world, this marked a revolutionary shift. RSC introduced a new approach to building web apps, transforming how components are managed and rendered more efficiently and effectively.&lt;/p&gt;

&lt;p&gt;RSC is more server-centric to enhance the client-side rendering, delivering only what's necessary. For exemple, if a component should only be visible under a certain condition, instead of making that decision on the client-side, it can be determined server-side. This avoids sending the component to the client, benefiting web performance since there's no need to download and execute a component that will never be displayed.&lt;/p&gt;

&lt;p&gt;RSC has a zero-bundle size, allowing us to render static content that might have previously required JavaScript libraries for construction. In the past, this was done client-side, using libraries for content that didn't need interactivity. With RSC, we can handle this server-side, producing only static content with no additional bundle size.&lt;br&gt;
For more details: &lt;a href="https://github.com/reactjs/rfcs/blob/main/text/0188-server-components.md#zero-bundle-size-components" rel="noopener noreferrer"&gt;https://github.com/reactjs/rfcs/blob/main/text/0188-server-components.md#zero-bundle-size-components&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With RSC, we gain secure, full access to the backend, as server components are never delivered to the client. This approach allows us to fetch data directly from the database, eliminating the need for an endpoint.&lt;br&gt;
For more details: &lt;a href="https://github.com/reactjs/rfcs/blob/main/text/0188-server-components.md#full-access-to-the-backend" rel="noopener noreferrer"&gt;https://github.com/reactjs/rfcs/blob/main/text/0188-server-components.md#full-access-to-the-backend&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;RSC enhances both user experience (UX) and developer experience (DX). In RSC, all imports automatically become code-splitting points, eliminating the need for additional configuration. This not only facilitates the developer's work but also boosts performance, as the server determines whether or not a component should be rendered.&lt;br&gt;
For more details: &lt;a href="https://github.com/reactjs/rfcs/blob/main/text/0188-server-components.md#automatic-code-splitting" rel="noopener noreferrer"&gt;https://github.com/reactjs/rfcs/blob/main/text/0188-server-components.md#automatic-code-splitting&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To deep dive in RSC you can consider reading this RFC: &lt;a href="https://github.com/reactjs/rfcs/blob/main/text/0188-server-components.md" rel="noopener noreferrer"&gt;https://github.com/reactjs/rfcs/blob/main/text/0188-server-components.md&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Islands Architecture (Partial Hydration)
&lt;/h2&gt;

&lt;p&gt;Now we are in a new era, an era of 0 JavaScript, the Island Architecture, It's a new way of building websites without having the need to hydrate all our website in the first load, this concept of Islands Architecture was popularized first by Astro Framework using a technique called Partial Hydration.&lt;/p&gt;

&lt;p&gt;The concept of partial hydration allows developers to determine what aspects are loaded and when in order to provide fast interactivity. This is done by being able to put some client-side JS only where it is needed. Partial hydration definitely is a wise and practical strategy. Our webpage is initially sent as pure HTML from the server to the client. JavaScript is not shipped by default.&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%2Fnryzn5ncihe0mld65p0v.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnryzn5ncihe0mld65p0v.jpg" alt="Islands Architecture (Partial Hydration)" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the example of Astro, the guiding principle is to build Islands of Interactivity that the browser can hydrate on its own. We can optimize how the page loads javascript by treating each component (Island) independently.&lt;/p&gt;
&lt;h2&gt;
  
  
  Resumability
&lt;/h2&gt;

&lt;p&gt;In our earlier discussions, we delved into how various frameworks aimed to optimize the hydration process. Hydration, traditionally seen as a bottleneck for website performance, has often been the focal point for improvement. Yet, instead of merely enhancing what's existing, it might be time for a revolutionary shift in our approach. The question isn't just about doing it faster but possibly about doing nothing at all.&lt;/p&gt;

&lt;p&gt;Introducing "Resumability." The name itself gives a clue: to "stop and resume." This concept suggests picking up right where the server left off, eliminating the repetitive nature of traditional hydration processes. Resumability's primary goal is optimal performance, emphasizing minimalistic javascript and pure HTML.&lt;/p&gt;

&lt;p&gt;Consider a contact form on the page's bottom. Traditional methods preload the necessary JavaScript, while partial hydration slightly improves this. But with Resumability, the JavaScript loads only upon direct interaction, such as clicking the send button. This innovative perspective, championed by the emerging framework Qwik, offers a fresh take on web app development, focusing on scalability without sacrificing performance.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpkrg19c7ktxpj9gr0r5k.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%2Fpkrg19c7ktxpj9gr0r5k.png" alt="Resumability" width="800" height="383"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If we try to think deeply about the figure above, we will understand the reel problem, scaling. If we have an extensive web application, it will take a lot of time to load with hydration.&lt;/p&gt;

&lt;p&gt;How it is done in Qwik? in Qwik there is code extraction for optimizing performance. For each event on our page, a specific JavaScript file is linked. If an action isn't taken, like pressing a button, its JavaScript isn't loaded. Qwik doesn't only load files upon interaction.&lt;/p&gt;

&lt;p&gt;After the initial interactive page load, it preemptively downloads the necessary javascript code for the current page via a service worker, storing it in the browser's cache. This prevents constant server requests. Instead, it pulls from the cache, or if not yet available, fetches it from the server—this is called prefetching. Unlike other frameworks that bog down initial loads with JavaScript, Qwik remains interactive without waiting for the JavaScript to be downloaded.&lt;/p&gt;

&lt;p&gt;Using this approach, Core Web Vitals like FCP, LCP, and TTI experience significant enhancements directly through the framework, without requiring developer interventions or specific optimization techniques. In contrast, many other frameworks necessitate manual optimizations, from code splitting and lazy loading to caching and more.&lt;/p&gt;

&lt;p&gt;Qwik takes away this pressure from developers. Instead of getting bogged down with configuration, they can focus solely on app development. The framework takes care of the rest, ensuring optimized performance. This innovative approach not only enhances user experience (UX) by improving performance but also streamlines the developer experience (DX).&lt;/p&gt;

&lt;p&gt;For more details, you can read this article:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag__link"&gt;
  &lt;a href="/playfulprogramming" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__org__pic"&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%2Forganization%2Fprofile_image%2F3314%2Ffd92caab-2014-431e-a19e-8ab47f2bf5ab.png" alt="Playful Programming" width="800" height="800"&gt;
      &lt;div class="ltag__link__user__pic"&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%2Fuser%2Fprofile_image%2F1117404%2F134e85f1-22be-48d9-8251-71f77f4f910b.jpg" alt="" width="800" height="921"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/playfulprogramming/qwik-the-post-modern-framework-3c5o" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Qwik – The Post-Modern Framework&lt;/h2&gt;
      &lt;h3&gt;Ayoub Alouane for Playful Programming ・ Jul 11 '23&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#javascript&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#qwik&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#frontend&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#typescript&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


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

&lt;p&gt;In web development, the quest for the best web performance possible has been nothing short of Sisyphean. The evolutionary journey through CSR, SSR, SSG, and others showcased the industry's relentless pursuit of excellence. However, each approach had its limitations, and none seemed capable of fully overcoming the performance bottlenecks. Then emerged a glimmer of hope "Resumability.", offering a promising future where performance no longer feels like an uphill battle.&lt;/p&gt;

&lt;h2&gt;
  
  
  Article resources:
&lt;/h2&gt;

&lt;p&gt;-&lt;a href="https://www.patterns.dev/" rel="noopener noreferrer"&gt;https://www.patterns.dev/&lt;/a&gt;&lt;br&gt;
-&lt;a href="https://github.com/reactjs/rfcs/blob/main/text/0188-server-components.md" rel="noopener noreferrer"&gt;https://github.com/reactjs/rfcs/blob/main/text/0188-server-components.md&lt;/a&gt;&lt;br&gt;
-&lt;a href="https://dev.to/this-is-learning/qwik-the-post-modern-framework-3c5o"&gt;https://dev.to/this-is-learning/qwik-the-post-modern-framework-3c5o&lt;/a&gt;&lt;br&gt;
-&lt;a href="https://dev.to/this-is-learning/astro-framework-169m"&gt;https://dev.to/this-is-learning/astro-framework-169m&lt;/a&gt;&lt;br&gt;
-&lt;a href="https://developers.google.com/web/updates/2019/02/rendering-on-the-web" rel="noopener noreferrer"&gt;https://developers.google.com/web/updates/2019/02/rendering-on-the-web&lt;/a&gt;&lt;br&gt;
-&lt;a href="https://web.dev/vitals/" rel="noopener noreferrer"&gt;https://web.dev/vitals/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>qwik</category>
      <category>performance</category>
      <category>webdev</category>
    </item>
    <item>
      <title>The Future Is Here: Qwik Meets Prisma Innovatively</title>
      <dc:creator>Ayoub Alouane</dc:creator>
      <pubDate>Thu, 17 Aug 2023 18:14:45 +0000</pubDate>
      <link>https://dev.to/playfulprogramming/the-future-is-here-qwik-meets-prisma-innovatively-1j6e</link>
      <guid>https://dev.to/playfulprogramming/the-future-is-here-qwik-meets-prisma-innovatively-1j6e</guid>
      <description>&lt;p&gt;If you're coming from PHP, you have Doctrine. From JAVA, you have Hibernate. In Javascript and TypeScript, we have Prisma that allows you to do Object Relational Mapping by providing a type-safe and intuitive query API to work with. The Prisma team, best known for their work on "GraphQL Yoga,”  introduced  Prisma 1 in  2018, which was a GraphQL data access layer for databases, but in 2019 the team decided to change the vision and deprioritize GraphQL to have a more general solution for databases to cover more use cases. So 2020 was the year of Prisma 2.0. The team announced on different dates of the year the three primary components Prisma Client, Prisma Migrate, and Prisma Studio.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prisma 2 Components
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Prisma Client
&lt;/h3&gt;

&lt;p&gt;Writing SQL queries will not be the case in Prisma 2. Prisma Client provides us with built-in intuitive API calls, which make it simple for developers to manipulate the database and execute complex queries using only pre-defined functions. Prisma Client has multiple features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Type-safety&lt;/strong&gt;: TypeScript is a type-safe programming language that ensures that we are using the data that we should use based on the defined types. Prisma client takes advantage of this because the generated TypeScript types are based on our database schema, so it will help us to catch errors at the compile time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Intuitive API&lt;/strong&gt;: it abstracts complex SQL queries into simple and clear functions, which gives the developer the ability to focus on the logic of his application.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Performance&lt;/strong&gt;: Query batching is the key to having a great performance in Prisma Client. This feature enables Prisma to minimize the number of query requests made to the database by grouping queries and sending them as a single batched request to the database. The result of this is reducing the latency.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Prisma Migrate
&lt;/h3&gt;

&lt;p&gt;Prisma Migrate is a special feature of Prisma. Using only files that we call “migration files,” we can implement the process of creating, updating, and managing databases using SQL commands. Prisma Migrate has multiple features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Prisma Schema&lt;/strong&gt;: it's the core of Prisma. It contains the information needed for our Database. It's a file “schema.prisma”, defined using Prisma Schema Language (PSL), used for migration file generation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Migration Files&lt;/strong&gt;: these are the files responsible for keeping the history and the actual state of our Database. Prisma Migrate can detect the changes that we make in our Prisma scheme and generates migration files for that.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Migrate CLI&lt;/strong&gt;: it's a command-line interface that helps us to manage our migrations(create new migrations, apply existing ones, and also rollbacking).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Introspection&lt;/strong&gt;: it's a feature that allows us to do reverse engineering by generating a Prisma schema file based on an existing database&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Prisma Studio
&lt;/h3&gt;

&lt;p&gt;Prisma Studio is a user-friendly Graphical User Interface that allows us to visualize and interact with our database. It supports multiple databases: PostgreSQL, MySQL, SQLite, and SQL Server. Prisma Studio has multiple features: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Data Management&lt;/strong&gt;: it allows us to perform queries such (Create, Read, Update, and Delete), so with that, it will be easy to manipulate data using a graphical interface.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real-time Data&lt;/strong&gt;: with Prisma Studio, we can visualize changes in real-time. If a change occurs in the Database, it is automatically displayed on the graphical interface.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cross-platform Compatibility&lt;/strong&gt;: it's is available in multiple OSs Windows, macOS, and Linux, and also it has a web version that we can access via the browser that we use.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Brief Introduction to Qwik
&lt;/h2&gt;

&lt;p&gt;Qwik is a framework created by the creator of Angular, Miško Hevery, with a collaboration of Adam Bradley, who created Ionic, and Manu Almeida, who created Gin Framework.&lt;/p&gt;

&lt;p&gt;Qwik, the HTML first framework’s philosophy is clear: make the fastest possible time-to-interactive (to do it faster by doing nothing).&lt;/p&gt;

&lt;p&gt;The framework delays the invocation of the javascript as much as possible and invokes it only when it is needed. The focus is on the first load.&lt;/p&gt;

&lt;p&gt;If you want to dive deep into Qwik, we already have an article about it:&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/playfulprogramming" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__org__pic"&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%2Forganization%2Fprofile_image%2F3314%2Ffd92caab-2014-431e-a19e-8ab47f2bf5ab.png" alt="Playful Programming"&gt;
      &lt;div class="ltag__link__user__pic"&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%2Fuser%2Fprofile_image%2F1117404%2F134e85f1-22be-48d9-8251-71f77f4f910b.jpg" alt=""&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/playfulprogramming/qwik-the-post-modern-framework-3c5o" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Qwik – The Post-Modern Framework&lt;/h2&gt;
      &lt;h3&gt;Ayoub Alouane for Playful Programming ・ Jul 11 '23&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#javascript&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#qwik&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#frontend&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#typescript&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  Integrate Prisma to Qwik
&lt;/h2&gt;

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

&lt;p&gt;To get started with Qwik locally, we need the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://nodejs.org/en/download/" rel="noopener noreferrer"&gt;Node.js v16.8&lt;/a&gt; or higher&lt;/li&gt;
&lt;li&gt;Your favorite IDE (&lt;a href="https://code.visualstudio.com/" rel="noopener noreferrer"&gt;vscode&lt;/a&gt; recommended)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  App Creation
&lt;/h3&gt;

&lt;p&gt;Using the Qwik CLI, we will start by starting a new Qwik Project:&lt;/p&gt;

&lt;p&gt;Using the Qwik CLI, we will start by starting a new Qwik Project:&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 qwik@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To run the server, we will need the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On port 5173, we will have our application running. Now we will install Prisma:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run qwik add prisma
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After installing Prisma, we will have a folder added in the root of our project:&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%2Fv3rdocf79mpq8ft03nz1.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%2Fv3rdocf79mpq8ft03nz1.png" alt="Prisma Folder"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The core file where we will define our scheme is &lt;code&gt;schema.prisma&lt;/code&gt;, in this tutorial, we will define a model named Company and another one named Employee, and we establish between them a relation of one-to-many, so a user can have one company and a company can have multiple employees, here is how we will implement it:&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;// This is your Prisma schema file,&lt;/span&gt;
&lt;span class="c1"&gt;// learn more about it in the docs: https://pris.ly/d/prisma-schema&lt;/span&gt;

&lt;span class="nx"&gt;generator&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;provider&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;prisma-client-js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;datasource&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;provider&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sqlite&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="nx"&gt;url&lt;/span&gt;      &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;file:./dev.db&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;model&lt;/span&gt; &lt;span class="nx"&gt;Employee&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;id&lt;/span&gt;    &lt;span class="nx"&gt;Int&lt;/span&gt;     &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;id&lt;/span&gt; &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;default&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;autoincrement&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
  &lt;span class="nx"&gt;email&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;unique&lt;/span&gt;
  &lt;span class="nx"&gt;company&lt;/span&gt; &lt;span class="nx"&gt;Company&lt;/span&gt; &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;relation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fields&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;companyId&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="nx"&gt;references&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
  &lt;span class="nx"&gt;companyId&lt;/span&gt; &lt;span class="nx"&gt;Int&lt;/span&gt;
  &lt;span class="nx"&gt;name&lt;/span&gt;  &lt;span class="nb"&gt;String&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;model&lt;/span&gt; &lt;span class="nx"&gt;Company&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;id&lt;/span&gt;    &lt;span class="nx"&gt;Int&lt;/span&gt;     &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;id&lt;/span&gt; &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;default&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;autoincrement&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
  &lt;span class="nx"&gt;website&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;unique&lt;/span&gt;
  &lt;span class="nx"&gt;name&lt;/span&gt;  &lt;span class="nb"&gt;String&lt;/span&gt;
  &lt;span class="nx"&gt;descriptions&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;
  &lt;span class="nx"&gt;employees&lt;/span&gt; &lt;span class="nx"&gt;Employee&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;After modifying the file &lt;code&gt;schema.prisma&lt;/code&gt;, we should run this command to update the migration files and create another one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx prisma migrate dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we will try to seed some companies in the database. To do that, we will create a file called &lt;code&gt;seed.ts&lt;/code&gt; in Prisma directory:&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="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;PrismaClient&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@prisma/client&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;prisma&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;PrismaClient&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;companies&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Adservio&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="s2"&gt;Great Place to Work&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;website&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;www.adservio.fr&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="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="s2"&gt;Adservio Academy&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="s2"&gt;Great Place to Learn&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;website&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;www.adservio-academy.fr&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="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="s2"&gt;Iriguard&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="s2"&gt;Great Place to be Secure&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;website&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;www.iriguard.fr&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="k"&gt;for &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;company&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;companies&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;description&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;website&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;company&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;categoryData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;prisma&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;company&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;upsert&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;where&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;website&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="na"&gt;update&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{},&lt;/span&gt;
      &lt;span class="na"&gt;create&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nx"&gt;description&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nx"&gt;website&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="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async &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;await&lt;/span&gt; &lt;span class="nx"&gt;prisma&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;$disconnect&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;prisma&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;$disconnect&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that, we should add this line to the &lt;code&gt;package.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="s2"&gt;"prisma"&lt;/span&gt;: &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"seed"&lt;/span&gt;: &lt;span class="s2"&gt;"ts-node --compiler-options {&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;module&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;:&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;CommonJS&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;} prisma/seed.ts"&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;,
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And finally, we should execute this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx prisma migrate reset
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you get this error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;An error occurred &lt;span class="k"&gt;while &lt;/span&gt;running the seed &lt;span class="nb"&gt;command&lt;/span&gt;:
Error: Command failed with ENOENT: ts-node &lt;span class="nt"&gt;--compiler-options&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"module"&lt;/span&gt;:&lt;span class="s2"&gt;"CommonJS"&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt; prisma/seed.ts
spawn ts-node ENOENT
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should install ts-node:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;ts-node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After re-executing the command, to show the results, we can execute Prisma Studio with the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx prisma studio
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here are the results:&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%2Fnp95k96yvzp3cbvg0ajj.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%2Fnp95k96yvzp3cbvg0ajj.png" alt="Result Table"&gt;&lt;/a&gt;&lt;br&gt;
Now we will create a route that will help us to create users. Here is the code of the index.ts of this route:&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="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;component$&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@builder.io/qwik&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;routeAction$&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;routeLoader$&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;zod$&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="nx"&gt;Form&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;@builder.io/qwik-city&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;PrismaClient&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;@prisma/client&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;useGetCompanies&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;routeLoader&lt;/span&gt;&lt;span class="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="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;prisma&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;PrismaClient&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;companies&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;prisma&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;company&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findMany&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;companies&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;useCreateEmployee&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;routeAction&lt;/span&gt;&lt;span class="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;prisma&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;PrismaClient&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="nx"&gt;data&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;employee&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;prisma&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;employee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="nx"&gt;data&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;employee&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="nx"&gt;zod&lt;/span&gt;&lt;span class="nf"&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="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="na"&gt;email&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;email&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="na"&gt;companyId&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;regex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/^&lt;/span&gt;&lt;span class="se"&gt;\d&lt;/span&gt;&lt;span class="sr"&gt;+$/&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;component&lt;/span&gt;&lt;span class="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;createEmployeeAction&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useCreateEmployee&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;companies&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useGetCompanies&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="nt"&gt;section&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Create User&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Form&lt;/span&gt; &lt;span class="na"&gt;action&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;createEmployeeAction&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;label&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
          Name
          &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;input&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"name"&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;label&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;label&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
          Email
          &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;input&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"email"&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"email"&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;label&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;label&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
          Companies
          &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;select&lt;/span&gt;  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"companyId"&lt;/span&gt; &lt;span class="na"&gt;data-choose-theme&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;option&lt;/span&gt;  &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"0"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Default&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;option&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;companies&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;company&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="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;option&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"text-primary"&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;company&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;company&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;company&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;option&lt;/span&gt;&lt;span class="p"&gt;&amp;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;lt;/&lt;/span&gt;&lt;span class="nt"&gt;select&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;label&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;

        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Create&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Form&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;createEmployeeAction&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h2&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Employee created successfully!&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h2&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;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;lt;/&lt;/span&gt;&lt;span class="nt"&gt;section&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;In the creation, we should choose a name, an email, and the company. To get the list of companies, we used &lt;code&gt;routeLoader$&lt;/code&gt; with a &lt;code&gt;findMany()&lt;/code&gt; that will return the list of companies. R&lt;code&gt;outeLoader$&lt;/code&gt; is good for having data rendered in the server and sent it to the client as a serialized HTML.&lt;/p&gt;

&lt;p&gt;After that, we use &lt;code&gt;routeAction$&lt;/code&gt; to create a user after submitting the form. It allows us to perform submitting and return from the server a result to the client in order to update our UI.&lt;/p&gt;

&lt;p&gt;Here are the results:&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%2Fio63m27yuw5vllj84emo.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%2Fio63m27yuw5vllj84emo.png" alt="Result"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And if we click on company:&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%2Fudmmiyvtegrtjzluzs1a.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%2Fudmmiyvtegrtjzluzs1a.png" alt="Result final"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we can see, Prisma Studio helps us to visualize all the relations between our tables.&lt;/p&gt;

&lt;p&gt;Qwik and Prisma can be integrated easily, and with Qwik, we benefit from using  &lt;code&gt;routeLoader$&lt;/code&gt; and &lt;code&gt;routeAction$&lt;/code&gt;, which help us to have a great performance with an exceptional DX because, with these features, we don't have to keep track of which code we will execute in the server or in the client, the framework does that for us.&lt;/p&gt;

</description>
      <category>qwik</category>
      <category>prisma</category>
      <category>typescript</category>
      <category>web</category>
    </item>
    <item>
      <title>Unlocking Web Performance: Core Web Vitals Clarified</title>
      <dc:creator>Ayoub Alouane</dc:creator>
      <pubDate>Wed, 09 Aug 2023 10:56:18 +0000</pubDate>
      <link>https://dev.to/playfulprogramming/rise-to-the-top-how-googles-core-web-vitals-shape-your-sites-success-1bmd</link>
      <guid>https://dev.to/playfulprogramming/rise-to-the-top-how-googles-core-web-vitals-shape-your-sites-success-1bmd</guid>
      <description>&lt;p&gt;All of us nowadays are talking about web performance, it’s the subject that is taking the most important place in talks, blogs, and podcasts, everyone is trying to give his point of view on why it’s primary and how we can achieve it. We are also witnessing rising competition in the JS Frameworks field, the discussion now is only about performance rather than Developer Experience, which was the subject with SPA Frameworks, but fortunately, now we consider that DX is becoming an acquired value that no one needs to argue about. New Frameworks are showing their ability in having big scores in PageSpeed Insights. &lt;/p&gt;

&lt;p&gt;Here is a tweet from the CEO of Vercel, who is showing how with NextJS we will be able to build websites with extremely great performance. &lt;/p&gt;

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

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



&lt;/p&gt;

&lt;p&gt;Focusing on performance is an indirect approach to enhancing the User Experience, the user should have the best page load speed on our websites, he should not wait for a page to start loading, to be visible, to be interactive, and to be stable. These factors all play a part in what is known as Core Web Vitals, key metrics Google uses in its ranking algorithm. They are sort of standards that we will talk about in this article to test &lt;strong&gt;website speed&lt;/strong&gt;. So developers utilize several performance testing tools such as GTmetrix or Google PageSpeed Insights to ensure that they respect the metrics to optimize their sites for better speed. &lt;/p&gt;

&lt;h2&gt;
  
  
  Why Web Performance is Important?
&lt;/h2&gt;

&lt;p&gt;Engaging in a discussion about performance in general will not be significant without considering the real concern about it, the User, for whom we want to build &lt;strong&gt;performant websites&lt;/strong&gt;, in other words without using political correctness the CONSUMER. To illustrate this we can draw a parallel to dining at a restaurant, Imagine you are in a restaurant, you ordered a beef bourguignon dish, you’re so hangry but you should wait 40 minutes for it, as the minutes tick away, your hunger grows, patience wears thin, maybe you will cancel your order within 15 minutes, maybe you will wait but vow never to return, you will share your disappointing experience with friends, write a bad review in google.&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%2F784u0e7950zvuvgvyvwm.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F784u0e7950zvuvgvyvwm.jpg" alt="Client waiting for a beef bourguignon dish"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This scenario is remarkably comparable to the user experience on a website.&lt;/p&gt;

&lt;p&gt;If a website fail to deliver a functional page quickly, the user's initial excitement can quickly evolve into frustration, a slow e-commerce website, for example, can lead the consumer to abandon his order and search for it on other websites, so like we can see performance is not only about technical issues but it’s a human phenomenon, an emotional state, and a psychological experience because it’s not about the website and what it’s offering, it’s about the user who searches for efficiency and immediate response. If we analyze for example apps like TikTok or Instagram Reels we will understand that users are searching for information in only 30 seconds, they don’t want to watch a documentary or a long video about a subject, a TikTok video with a minimum of seconds and a maximum of pieces of information that matches their needs.&lt;/p&gt;

&lt;p&gt;But having Performance and UX as the main factors for building websites is not something coming from nowhere, in this article we will explore also how Google managed to establish these factors as important axes to respect when building websites.&lt;/p&gt;

&lt;h2&gt;
  
  
  History of Google's Website Ranking
&lt;/h2&gt;

&lt;p&gt;Every website's goal is to appear on the first page of Google search results, perhaps even at the top of the list when users search for something related to the website's content. Google has the ability to define the criteria for displaying these results, and these criteria have been changing over the past few decades.&lt;/p&gt;

&lt;p&gt;In the beginning, Google ranked websites based on links from other high-quality websites. For example, if you had a new website for your restaurant, it would likely have a low ranking because no one was linking to it. However, if a well-known blog with a large user base were to mention and link to your website in an article, Google would adjust its ranking, resulting in a higher placement in the search results.&lt;/p&gt;

&lt;p&gt;But this approach was not efficient because there were a lot of spammers, so Google started implementing different methods such as keyword relevance and user experience and they did a lot of updates to chase websites who are spamming and buying links.&lt;/p&gt;

&lt;p&gt;In the last years, Google decided to spotlight &lt;strong&gt;User Experience&lt;/strong&gt; and Performance, so websites should not be slow or insecure to have a great user experience, for that, Google introduced Core Web Vitals in the game in 2020, which are a set of measures that give us a detailed view on the experience that will have a user in our website, and Google utilize them to rank results in Google Search. So to do things correctly from the start or to optimize an existing project we should have a deep understanding of Core Web Vitals.&lt;/p&gt;

&lt;h2&gt;
  
  
  Web Performance as a Criteria
&lt;/h2&gt;

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

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



&lt;/p&gt;

&lt;p&gt;Yes, we should be concerned about &lt;strong&gt;Core Web Vitals&lt;/strong&gt; if we worry about our users. Core Web Vitals are increasingly becoming a topic and a challenge for new frameworks, or more precisely, meta-frameworks. Meta-frameworks such as NextJS, Astro, or Qwik City are more concerned with improving the performance of web applications. These tools each have their ways of rendering, hydration, partial hydration, and resumability, but the purpose is the same: to make websites faster to provide a better user experience.&lt;/p&gt;

&lt;p&gt;Now let’s deep dive into our main subject, Core Web Vitals. These are metrics that Google uses, like we said to judge if a website has good performance or not, if it has a good user experience or not, and if it should be well ranked or not.&lt;/p&gt;

&lt;h3&gt;
  
  
  Largest Contentful Paint (LCP)
&lt;/h3&gt;

&lt;p&gt;This metric measures the time that website takes to render the largest area (element) of the page, for example, if we take the &lt;a href="http://adservio.fr/" rel="noopener noreferrer"&gt;adservio.fr&lt;/a&gt;, here in &lt;a href="https://pagespeed.web.dev/" rel="noopener noreferrer"&gt;https://pagespeed.web.dev&lt;/a&gt; it indicates the element that is considered as "Largest Contentful Paint”:&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%2Fm1bdcpd9vmghrpft9894.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%2Fm1bdcpd9vmghrpft9894.png" alt="Largest Contentful Paint"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On our page the LCP takes 2,5 s, which is not good to have a performant website, after 2,5s the user will see most of the page painted, so he will say that the page is almost ready.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cumulative Layout Shift (CLS)
&lt;/h3&gt;

&lt;p&gt;This measures the score for a page based on the entire time a page need to stop moving or shifting elements around in the DOM. If for example, we have a website for e-commerce, but after finishing showing the page, suddenly we have a bar that appears at the top of the page and moves the page to the bottom, that’s not good if we want to have a better score. Here is an example from the &lt;a href="http://ft.com/" rel="noopener noreferrer"&gt;ft.com&lt;/a&gt;, in first we have the page correctly but suddenly it moves down to show an ad (colored in red):&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%2Foilhelv2z0vgp1se461o.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%2Foilhelv2z0vgp1se461o.png" alt="Cumulative Layout Shift (CLS)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It’s all about unexpected element shifting that will occur on our page, we should not keep injecting new elements in the DOM.&lt;/p&gt;

&lt;p&gt;So now we can imagine the nightmare that we will have with Single Page Application, and how the score will be catastrophic.&lt;/p&gt;

&lt;h3&gt;
  
  
  First Input Delay (FID)
&lt;/h3&gt;

&lt;p&gt;That’s an interesting metric, FID measures the necessary time that we should wait between when the page looks ready and when the user can interact with it, which means when the browser can fire an event.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Page visible but not Interactive&lt;/th&gt;
&lt;th&gt;After 3ms the page is interactive&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&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%2Fqtdlg2z0v0ubczmosrhn.png" alt="Page visible but not Interactive"&gt;&lt;/td&gt;
&lt;td&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%2Fn9p9lr4mlwsk25z2wm8f.png" alt="After 3ms the page is interactive"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If for example, we are working with frameworks that do hydration, we will show the HTML page that is rendered the first time with SSR, but we should wait to download and execute our javascript files in order to add the necessary code to each node of the DOM. After doing this reconciliation, we will have our page ready.&lt;/p&gt;

&lt;h3&gt;
  
  
  First Contentful Paint (FCP)
&lt;/h3&gt;

&lt;p&gt;This metric is used to calculate the necessary &lt;strong&gt;load time&lt;/strong&gt; for meaningful content to be visible, from entering the URL to having something on our page, not a blank div, something visible must be rendered, here we show an example:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Blank Page&lt;/th&gt;
&lt;th&gt;First Meaningful Content&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&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%2Fvyzsxd9af1fxrenzvwdt.png" alt="Blank Page"&gt;&lt;/td&gt;
&lt;td&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%2F3not4owgtbsdkdq23fkq.png" alt="First Meaningful Content"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;When a user sees something on the page, he feels safe, he is sure now that he will have a result, that the website is working.&lt;/p&gt;

&lt;p&gt;For more details here is a &lt;a href="https://web.dev/vitals/" rel="noopener noreferrer"&gt;link&lt;/a&gt; to look at.&lt;/p&gt;

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

&lt;p&gt;Our Article now was an overview of how Google ranks websites, and we focused more on modern metrics, &lt;strong&gt;Core Web Vitals&lt;/strong&gt;, to give an overview and simple explanation of each one.&lt;/p&gt;

&lt;p&gt;This article is one of a series that we will have. In the next article, we will deep dive into Core Web Vitals, and tools to measure them. If you found this article helpful? Share your thoughts in the comments below or share it with your network!&lt;/p&gt;

</description>
      <category>web</category>
      <category>performance</category>
      <category>google</category>
      <category>webdev</category>
    </item>
    <item>
      <title>The Power Of RUST: Introduction and Deep Dive in Advanced Concepts: Ownership, References and Borrowing.</title>
      <dc:creator>Ayoub Alouane</dc:creator>
      <pubDate>Wed, 26 Jul 2023 23:35:18 +0000</pubDate>
      <link>https://dev.to/playfulprogramming/the-power-of-rust-introduction-and-deep-dive-in-advanced-concepts-ownership-references-and-borrowing-28dh</link>
      <guid>https://dev.to/playfulprogramming/the-power-of-rust-introduction-and-deep-dive-in-advanced-concepts-ownership-references-and-borrowing-28dh</guid>
      <description>&lt;p&gt;Rust is a language created by an employee in Mozilla before 2010, but after this date the programming language was sponsored by the company, inspired by C/C++, but with more efficiency, compiled, strongly typed, safe and performant but without a garbage collector.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A language empowering everyone to build reliable and efficient software.&lt;br&gt;
-rust-lang.org&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Rust is used by multiple big companies like Mozilla of course, Microsoft and Dropbox, it’s used for a lot of cases, building web servers, command-line interfaces, native desktop application, web apps using WebAssemblly, and also for operating systems.&lt;/p&gt;

&lt;p&gt;Having a safe and multithread language is already great, but with the maximum performance it will be greater, Rust is here for that, it’s a systems programming language with a compiler, so it’s not interpreted like javascript, it’s compiler is the key for having performant programs and a safe memory. Not only performance, Rust has also productivity due to the package of tooling that it has, like package manager, testing and documentation.&lt;/p&gt;

&lt;p&gt;If just start using Rust, maybe you will find it complexe and not easy to understand, but the good thing about Rust is that it makes sure that you understand the concepts before using them.&lt;/p&gt;

&lt;p&gt;In this article we will try to cover the basic and advanced concepts that differentiate Rust from other languages in order to give an accessible introduction to all developers who are trying to start coding using Rust.&lt;/p&gt;

&lt;h1&gt;
  
  
  Basic Concepts
&lt;/h1&gt;

&lt;h2&gt;
  
  
  How Mutability works?
&lt;/h2&gt;

&lt;p&gt;The principal feature of Rust is that variables are immutable by default, it means that when we give a value to a variable, we can’t change it anymore, for exemple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fn main() {
    let a = 7;
    println!("a is: {x}");
    a = 1;
    println!("a is: {x}");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we run this code it will show an error “&lt;em&gt;cannot assign twice to immutable variable &lt;code&gt;a&lt;/code&gt;&lt;/em&gt;”, because we tried to assign a new value to an immutable variable, so the compiler is able to show us errors in the compile time in order to have a safe code. But maybe in other cases we will need a mutable variable, it's possible in Rust, but we should specify that in the code by adding the keyword &lt;strong&gt;mut&lt;/strong&gt;, for exemple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fn main() {
    let mut a = 2;
    println!("a is: {x}");
    a = 9;
    println!("a is: {x}");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The compiler in this case will not show us an error, because we specify that the variable is mutable, so we can change its value.&lt;/p&gt;

&lt;p&gt;Now we have an understanding of how to define variables using the &lt;strong&gt;let&lt;/strong&gt; keyword and how we can change its nature with &lt;strong&gt;mut&lt;/strong&gt; in order to be mutable, but there is another keyword to define variables, its &lt;strong&gt;const&lt;/strong&gt;, using this keyword will allow us to declare constants. &lt;/p&gt;

&lt;p&gt;Maybe you will say that &lt;strong&gt;let&lt;/strong&gt; without the keyword &lt;strong&gt;mut&lt;/strong&gt; is already used for defining constants that will not change, but there are some differences:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Constants are immutable, always immutable, there is no chance that they will become mutable, we can’t use the keyword &lt;strong&gt;mut&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Constants must have there values in the compile time, they should not have values that we will be calculated in the runtime.&lt;/li&gt;
&lt;li&gt;When we declare Constants we should annotate the type of the value.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Exemple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const RESULT: u32 = 57 * 24;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can notice that the variable has a specific naming, it’s the convention of naming constants in Rust. &lt;strong&gt;u32&lt;/strong&gt; is the type of the value that we assigned to the variable RESULT.&lt;/p&gt;

&lt;p&gt;We should mention also that constants are also available in the scope where they were defined the entire time of the running of our program.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is exactly Shadowing?
&lt;/h2&gt;

&lt;p&gt;Another important concept, before introducing it, we should show an exemple:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Exemple 1&lt;/th&gt;
&lt;th&gt;Exemple 2&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;let a = 4;&lt;/td&gt;
&lt;td&gt;let a = 4;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;let a = a  *  2;&lt;/td&gt;
&lt;td&gt;a = a * 2;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;As we learned, we can’t re-assign a value to a variable defined with only let, it must be immutable, so the exemples that we have will show error normally, that’s the case for Exemple 2, but the exemple 1 is different, it’s not about re-assigning, it’s about declaring a variable with the same name of the last variable. In Rust we say that the first variable is &lt;strong&gt;shadowed&lt;/strong&gt; by the second one, in other words, the second variable &lt;strong&gt;overshadows&lt;/strong&gt; the first, it means that if we print variable a, we will have the first value multiplied by 2. But it’s also about scope, for exemple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fn main() {
    let a = 4;
    println!("(1) a is: {a}");
    let a = a * 2;
    println!("(2) a is: {a}");
    {
        let a = a + 6;
            println!("(3) a is: {a}");
    }
    println!("(4) a is: {a}");
}
//result
Compiling playground v0.0.1 (/playground)
    Finished dev [unoptimized + debuginfo] target(s) in 0.57s
     Running `target/debug/playground`
Standard Output
(1) a is: 4
(2) a is: 8
(3) a is: 14
(4) a is: 8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, as we can see, a was equal to 4, but after re-declaring it, the first variable was shadowed by the second so it equals 8. Now, after opening an other scope we re-declare the variable, so the third variable will shadow the second, but after closing the scope, we returned to the previous declaration that we had in the parent scope.&lt;/p&gt;

&lt;p&gt;In this process, we didn’t change the variable, we transformed the value, but the variable itself still immutable after any transformation that we can perform on the value.&lt;/p&gt;

&lt;p&gt;We can also change the type of the value in the transformation if we want, but like we said we should use the keyword let in order to create a new variable but with the same name.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction to Data Types
&lt;/h2&gt;

&lt;p&gt;Data Types in Rust are really different, they have a specific syntax. the first thing that we should know is that Rust is statically typed, in other words we should specify the types of all variables at the compile time, Rust can also understand the typed of a variable based on the value that we assigned to it.&lt;/p&gt;

&lt;p&gt;We have here two types of Data Type: Scalar and Compound:&lt;/p&gt;

&lt;h3&gt;
  
  
  Scalar
&lt;/h3&gt;

&lt;p&gt;Single value: integers, floating-point numbers, booleans and characters.&lt;/p&gt;

&lt;h4&gt;
  
  
  Integers
&lt;/h4&gt;

&lt;p&gt;In Rust there is Signed and Unsigned integers. Signed are integers that can be negative (they can have a signe), unsigned are only positive integers so they will never have a sign. Here is a table that illustrate multiple types:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Length&lt;/th&gt;
&lt;th&gt;Signed&lt;/th&gt;
&lt;th&gt;Unsigned&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;8-bit&lt;/td&gt;
&lt;td&gt;i8&lt;/td&gt;
&lt;td&gt;u8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;16-bit&lt;/td&gt;
&lt;td&gt;i16&lt;/td&gt;
&lt;td&gt;u16&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;32-bit&lt;/td&gt;
&lt;td&gt;i32&lt;/td&gt;
&lt;td&gt;u32&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;64-bit&lt;/td&gt;
&lt;td&gt;i64&lt;/td&gt;
&lt;td&gt;u64&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;128-bit&lt;/td&gt;
&lt;td&gt;i128&lt;/td&gt;
&lt;td&gt;u128&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;arch&lt;/td&gt;
&lt;td&gt;isize&lt;/td&gt;
&lt;td&gt;usize&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  Floating-Point
&lt;/h4&gt;

&lt;p&gt;Floating-point types are numbers with decimal points, they are always signed, there is no unsigned floating-points, and they have two types: f32, f64 (it’s the default type).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fn main() {
    let a = 6.0; // f64

    let b: f32 = 2.9; // f32
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Boolean
&lt;/h4&gt;

&lt;p&gt;In Rust Boolean Types are: &lt;em&gt;true&lt;/em&gt; and &lt;em&gt;false&lt;/em&gt;, to define a boolean we use the keyword &lt;strong&gt;bool&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fn main() {
    let condition: bool = true;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Character
&lt;/h4&gt;

&lt;p&gt;The Character type is a primitive alphabetic type. In Rust we define char with single quotes, but string literals with double quotes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fn main() {
    let a: char = 'B';
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Compound Types:
&lt;/h3&gt;

&lt;p&gt;Compound types in rust represent  a group of values inside one type, in Rust we have two: Tuples and Arrays.&lt;/p&gt;

&lt;h4&gt;
  
  
  Array
&lt;/h4&gt;

&lt;p&gt;In Rust an Array is a group of values that have the same type, and the group itself has a fixed length.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fn main() {
    let arr: [i32; 5] = [34, 51, 11, 42, 87];
    let result = arr[2]; // result = 11
}
// i32 is the type of the values
// 5 is the size of the array
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Tuple:&lt;/strong&gt;&lt;br&gt;
In Rust a Tuple is like an array but it can have values with different types.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fn main() {
    let tup: (u64, f32, i8) = (902, 2.2, -1);
    let result = tup.1; //result = 2.2
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How Functions works in Rust?
&lt;/h2&gt;

&lt;p&gt;Functions in Rust are defined with keyword &lt;strong&gt;fn&lt;/strong&gt;, main function is the entry point of our program:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fn main() {
    hello_adservio(28); //here we pass the value 28 as an argument
}

//Declaring the type of each parameter in a function is mandatory
fn hello_adservio(a: u32) { //the function here has a parametre of type u32
    println!("The age is: {a}");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fn main() {
    let x : u64 = multiply_3(5);// the function has a return value of type u64

    println!("The value of x is: {x}");
}

// '-&amp;gt; u64' means that our function has a return type of u64
fn multiply_3(x: u64) -&amp;gt; u64 {
        // we can see here that we don't have a semicolon ';' in the end of our ligne
    x * 3 
}

//result: The value of x is: 15
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this exemple, x * 3 has not a semicolon, so Rust will see it as an expression that will return a value, if we add a semicolon in the end of the line we will get an error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Compiling playground v0.0.1 (/playground)
error[E0308]: mismatched types
  --&amp;gt; src/main.rs:8:26
   |
8  | fn multiply_3(x: u64) -&amp;gt; u64 {
   |    ----------            ^^^ expected `u64`, found `()`
   |    |
   |    implicitly returns `()` as its body has no tail or `return` expression
9  |         // we can see here that we don't have a semicolon ';' in the end of our ligne
10 |     x * 3;
   |          - help: remove this semicolon to return this value
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  How OWNERSHIP Wokrs ?
&lt;/h1&gt;

&lt;h2&gt;
  
  
  What is Ownership
&lt;/h2&gt;

&lt;p&gt;Being able to manage the memory is the key, Rust is able to test a set of rules through its compiler. These set of rules represent ownership, it's a new concept for developers, it may appear complexe but when we will have a deep understanding of how it works, we will be more productive and we will be able to make safe and performant programs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stack and Heap
&lt;/h2&gt;

&lt;p&gt;Before talking about ownership rules, we should give a reminder about "stack and Heap". In a system programming language like RUST, we should have a total control over the memory, the stack and the heap, both are parts of our memory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Last in first out&lt;/strong&gt; is the definition of the stack, it’s the part of the memory where we push and pop data from, this data should have a fixed size. Therefore the Heap is for data with unknown size at the compile time. In the Heap we don't push data, we allocate the memory for it, so in other words, when we want to store data in the heap. The memory allocator will search for a place in the heap that can store this data, and it will return a pointer to it, this pointer will be stored in the stack, because its size is fixed, the pointer is the address for the data stored in the heap, after having a deep dive in ownership we will have a deep understanding of how the memory works.&lt;/p&gt;

&lt;h2&gt;
  
  
  Variable Scope
&lt;/h2&gt;

&lt;p&gt;All variables have a defined scope, in where they are valid, exemple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let a = "Adservio";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The variable is a String Literal type, it's valid when it is between the brackets, the a variable is immutable, so it's stored in the stack. In order to go deep in ownership we should choose another exemple, STRING type, can be mutable, so we can change it in the runtime.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let mut a = String::from("Adservio");

a.push_str(", Great Place!"); 

println!("{a}"); // this will print `Adservio, Great Place!`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The variable now is mutable, so in order to support a size that can be changed in the runtime, we should allocate memory in the heap.&lt;/p&gt;

&lt;p&gt;Now I should throw a reminder, RUST doesn't have a Garbage collector, so in programming languages that has a GC, the GC will take the responsibility to free the memory from a variable when it detects that it will never be used, but in languages that don't have GC, it's up to us to free the memory when we identify that the variable will never be used, but if we forget, the variable will be always there occupying the memory for nothing, so we will have a wasted memory.&lt;/p&gt;

&lt;p&gt;Rust is different, it has not a GC, but it manage to do that for us, its approach is to free the memory automatically when the variable go out of scope by calling a function called &lt;strong&gt;drop&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deep Dive in How variables work
&lt;/h2&gt;

&lt;p&gt;Starting with a simple exemple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let a = 7;
let b = a;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Variables a and b are immutable, so they will be stored in the stack, because they are integers that have a fixed size, so we will create a variable a with the value 7, copy this value and assign it to b, so we have two variable with different data, now let us look to another exemple that will give us a different case:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let a = String::from("Adservio");
let b = a;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We know that String variables are mutable, so the variable a is made of 3 things, the pointer, the length and the capacity, but now we will have a focus on the pointer. The pointer is stored in the stack, the value of the string in the Heap. Now, we assigned the a to b, so we copied the pointer but without copying the data in the Heap that the pointer refers to.&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%2Fa7t3j39phlci8x7rqlb5.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%2Fa7t3j39phlci8x7rqlb5.png" alt=" " width="800" height="653"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So the two pointers now point on the same value in the heap, the question that we will have now, is if the variable a goes out of scope, normally Rust will free the memory by calling the function drop, the error here is that we will clean a value that is used by other pointer. Another case is that both variables a and b go out of scope in the same time, so Rust will try to free the memory twice, it’s called “&lt;strong&gt;double free error&lt;/strong&gt;”. So what is the solution? In order to have a safe memory, Rust will invalidate the variable a, so after its assigning to the variable b, we will no longer have access to the variable a. Exemple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fn main() {
    let a = String::from("Adservio");
    let b = a;
    println!("The value of a is: {a}");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Compiling playground v0.0.1 (/playground)
error[E0382]: borrow of moved value: `a`
 --&amp;gt; src/main.rs:4:35
  |
2 |     let a = String::from("Adservio");
  |         - move occurs because `a` has type `String`, which does not implement the `Copy` trait
3 |     let b = a;
  |             - value moved here
4 |     println!("The value of a is: {a}");
  |                                   ^ value borrowed here after move
  |
  = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider cloning the value if the performance cost is acceptable
  |
3 |     let b = a.clone();
  |              ++++++++

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

&lt;/div&gt;



&lt;p&gt;The error generated by the Rust compiler suggested us to do “let b = a.clone();” which is a deep copy instead of “let b = a;” which we called a “&lt;strong&gt;move&lt;/strong&gt;”, the variable a was moved into b.&lt;/p&gt;

&lt;p&gt;Rust is here for better performance, so it will never decide to go by default with a deep copy because of the cost in term of the runtime performance (for values stored in the Heap).&lt;/p&gt;

&lt;p&gt;Another case, for types like integers that have a fixed size, the variables are stored completely in the stack, so their copying is not expensive. This code will not have errors:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fn main() {
    let a = 7;
    let b = a;
    println!("The value of a is: {a}");
    println!("The value of b is: {b}");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How Functions Work with Ownership
&lt;/h2&gt;

&lt;p&gt;Assigning a variable to another is like passing a variable to a function, it works with same concept, Exemple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fn main() {
    let a = String::from("Adservio");  
    print_var(a); 
    println!("{a}");            
}

fn print_var(value: String) { 
    println!("{value}");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Compiling playground v0.0.1 (/playground)
error[E0382]: borrow of moved value: `a`
 --&amp;gt; src/main.rs:4:14
  |
2 |     let a = String::from("Adservio");  
  |         - move occurs because `a` has type `String`, which does not implement the `Copy` trait
3 |     print_var(a); 
  |               - value moved here
4 |         println!("{a}");            
  |                    ^ value borrowed here after move
  |
note: consider changing this parameter type in function `print_var` to borrow instead if owning the value isn't necessary
 --&amp;gt; src/main.rs:7:21
  |
7 | fn print_var(value: String) { 
  |    ---------        ^^^^^^ this parameter takes ownership of the value
  |    |
  |    in this function
  = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider cloning the value if the performance cost is acceptable
  |
3 |     print_var(a.clone()); 
  |                ++++++++
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code will throw an error which is normal, because the function took ownership of the value of &lt;strong&gt;a&lt;/strong&gt; and Rust will automatically invalidate it. We have an other exemple for integers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fn main() {
    let a = 7;                      
    print_var(a); 
    println!("{a}");
}

fn print_var(value: i32) { 
    println!("{value}");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code will work normally, it will not throw an error. Like the exemple of assigning integers. The function will not take ownership.&lt;/p&gt;

&lt;h1&gt;
  
  
  References and Borrowing
&lt;/h1&gt;

&lt;p&gt;To start this part, we should have an idea about how return values work in Rust, the question here is returning a value from a function can transfer ownership? the answer is a big YES, here is an exemple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fn main() {
    let a = init_value();
    let b = String::from("Group");  
    let c = takes_and_gives_back(b);  
}
fn init_value() -&amp;gt; String {       
    let value = String::from("adservio"); 
    value                              
}
fn takes_and_gives_back(value: String) -&amp;gt; String { 
    value
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Looking now in the main function, we start by initiating a variable called a, we give it the value returned by the function init_value(), so here we have the function moving its owenership of the value returned to the variable a.&lt;/p&gt;

&lt;p&gt;Now let us define a variable b that we will initiate with the value “Group”, and we define now a variable called c, that will get the returned value of the function takes_and_gives_back(b) that will took b as argument, here the function takes_and_gives_back() took ownership of the variable b, and returned a new value and transfer it's ownership to c.&lt;/p&gt;

&lt;p&gt;So, is that the only way to keep using a value? by transferring ownership? The answer is NO, Rust has a feature called references.&lt;/p&gt;

&lt;p&gt;let us took another exemple now:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fn main() {
    let a = String::from("adservio");
    let b = calculate_length(a);
    println!("The length of '{a}' is {b}.");
}
fn calculate_length(value: String) -&amp;gt; usize {
    value.len()
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This exemple will clearly throw an error, because the ownership of the value of a is moved to the function calculate_length() that returned a value to assign to b, but when we try to print a:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;error[E0382]: borrow of moved value: `a`
 --&amp;gt; src/main.rs:6:31
  |
2 |     let a = String::from("adservio");
  |         - move occurs because `a` has type `String`, which does not implement the `Copy` trait
3 |
4 |     let b = calculate_length(a);
  |                              - value moved here
5 |
6 |     println!("The length of '{a}' is {b}.");
  |                               ^ value borrowed here after move
  |
note: consider changing this parameter type in function `calculate_length` to borrow instead if owning the value isn't necessary
 --&amp;gt; src/main.rs:9:28
  |
9 | fn calculate_length(value: String) -&amp;gt; usize {
  |    ----------------        ^^^^^^ this parameter takes ownership of the value
  |    |
  |    in this function
  = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider cloning the value if the performance cost is acceptable
  |
4 |     let b = calculate_length(a.clone());
  |                               ++++++++

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

&lt;/div&gt;



&lt;p&gt;The error here is “&lt;strong&gt;note: consider changing this parameter type in function &lt;code&gt;calculate_length&lt;/code&gt; to borrow instead if owning the value isn't necessary&lt;/strong&gt;” is trying to told us already what we should do.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Magical Symbole &amp;amp;
&lt;/h2&gt;

&lt;p&gt;Here is the correct version that will not throw an error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fn main() {
    let a = String::from("adservio");

    let b = calculate_length(&amp;amp;a); //&amp;amp;...

    println!("The length of '{a}' is {b}.");
}

fn calculate_length(c: &amp;amp;String) -&amp;gt; usize {
    c.len()
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can see here that the variable we passed has &amp;amp; just before it &lt;strong&gt;&lt;code&gt;&amp;amp;a&lt;/code&gt;&lt;/strong&gt;, and the type of the parameter in calculate_length() has a &amp;amp; before it: &lt;strong&gt;`&amp;amp;&lt;/strong&gt;String`, the symbole &amp;amp; here is telling the rust compiler that the function will only borrow the variable, and that we will pass only a reference to it instead of moving the ownership.&lt;/p&gt;

&lt;p&gt;By &amp;amp; we can create a reference to a, so that if we stopped using the reference the value will not be dropped because de reference doesn't own it.&lt;/p&gt;

&lt;p&gt;In the function calculate_length the c will not take the ownership of the value passed, because we added &amp;amp; symbole to the type, so when c goes out of scope nothing will happen to the value passed because c holds only a reference to the value not the ownership. And that's what we called &lt;strong&gt;borrowing&lt;/strong&gt;, is the concept of “to borrow” not “to own”.&lt;/p&gt;

&lt;p&gt;The question here, are we able to modify a value that we have reference to (that we borrow)? the answer is NO:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fn main() {
    let a = String::from("adservio");

    add_string(&amp;amp;a);
}

fn add_string(b: &amp;amp;String) {
    b.push_str(" Group");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we are trying to append a string to the one that we passed to the function add_string(), here is the error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;error[E0596]: cannot borrow `*b` as mutable, as it is behind a `&amp;amp;` reference
 --&amp;gt; src/main.rs:8:5
  |
8 |     b.push_str(" Group");
  |     ^^^^^^^^^^^^^^^^^^^^ `b` is a `&amp;amp;` reference, so the data it refers to cannot be borrowed as mutable
  |
help: consider changing this to be a mutable reference
  |
7 | fn add_string(b: &amp;amp;mut String) {
  |                  ~~~~~~~~~~~

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

&lt;/div&gt;



&lt;p&gt;The error:   b is a &lt;code&gt;&amp;amp;&lt;/code&gt; reference, so the data it refers to cannot be borrowed as mutable, the compiler is telling us that we cannot modify the data that b refers to because it is immutable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Mutable References
&lt;/h2&gt;

&lt;p&gt;Yes we can modify a borrowed data with using a mutable reference:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fn main() {
    let mut a = String::from("adservio");
    add_string(&amp;amp;mut a);
}

fn add_string(b: &amp;amp;mut String) {
    b.push_str(" group");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we should start by defining a as mutable value, and when we will try to pass it to the function, we should tell the compiler that it's a reference to mutable value by using a mutubale reference &lt;code&gt;&amp;amp;mut a&lt;/code&gt;, in the function declaration we add &lt;code&gt;&amp;amp;mut&lt;/code&gt;, in order to tell the compiler that b is a reference to a mutable value so that the function will be able to mutate the value that is borrowing.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;We cannot have a reference to a value that already have a mutable reference to it. &lt;strong&gt;BUT&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let mut a = String::from("adservio");

let b = &amp;amp;mut a;
let c = &amp;amp;mut a;

println!("{b}, {c}");

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

&lt;/div&gt;



&lt;p&gt;This code will throw an error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;error[E0499]: cannot borrow `a` as mutable more than once at a time
 --&amp;gt; src/main.rs:6:13
  |
5 |     let b = &amp;amp;mut a;
  |             ------ first mutable borrow occurs here
6 |     let c = &amp;amp;mut a;
  |             ^^^^^^ second mutable borrow occurs here
7 |     
8 |     println!("{b}, {c}");
  |                - first borrow later used her

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

&lt;/div&gt;



&lt;p&gt;Her we have a big &lt;strong&gt;WHY&lt;/strong&gt;? why we have this behaviour? Rust here is preventing &lt;strong&gt;data races&lt;/strong&gt; at compile time. Because here we can modify the value using the references that we have, so how we will synchronise the modification here? how we will track our code in compile time.&lt;/p&gt;

&lt;p&gt;So to prevent data races Rust is throwing an error at the compile time, but we can have multiple mutable references by using scopes, each reference that we create has a defined scope for it, exemple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   let mut a = String::from("adservio");

   {
       let b = &amp;amp;mut a;
   } 
   let b = &amp;amp;mut a;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the code here compile successfully because, there is no data races thanks to defining scopes using curly brackets.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;We cannot have mutable reference to a value when we have an immutable one to it.&lt;/p&gt;

&lt;p&gt;We can have multiple immutable references to a value, because it will not produce data races, users of the references will not modify the value, so that will not affect the other references.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;In this article we had a global view of why using Rust is great, we had a look also to the syntax and some basic concepts like mutability, and how it offer us a high level of safety and performance, we talked also about ownership, references and borrowing which are an essential concepts in Rust, if we understand them, we will have a total control of Rust when we are working with it.&lt;/p&gt;

</description>
      <category>rust</category>
      <category>performance</category>
      <category>compiling</category>
      <category>programming</category>
    </item>
    <item>
      <title>Qwik Authentication with Auth.js</title>
      <dc:creator>Ayoub Alouane</dc:creator>
      <pubDate>Tue, 18 Jul 2023 22:01:25 +0000</pubDate>
      <link>https://dev.to/playfulprogramming/qwik-authentication-with-authjs-2lid</link>
      <guid>https://dev.to/playfulprogramming/qwik-authentication-with-authjs-2lid</guid>
      <description>&lt;h2&gt;
  
  
  Introduction to Auth.js
&lt;/h2&gt;

&lt;p&gt;Auth.js is a well-known library for authentication that is used by JS Frameworks; with Auth.js we have less complexity. We also had a set of auth providers like GitHub, Google, Facebook, and others, and it can be integrated into multiple frameworks like NextJS, SveltKit, SolidStart, and Qwik.&lt;/p&gt;

&lt;p&gt;Auth.js comes with multiple features, that enable simplicity, productivity, flexibility and multiple providers. Here is the main features of Auth.js:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Providers&lt;/strong&gt;: Auth.js has the support of multiple providers that simplify for us the authentication process in our applications (Github, Google, Facebook, Twitter …). It also offers SSO services and also a simple traditional authentification.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Management&lt;/strong&gt;: Auth.js is doing a lot to help us focus on our business logic, so it manages Tokens, stores them, and takes care of refreshing them automatically.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Configuration&lt;/strong&gt;: Auth.js is simple to configure, with an easy installation, error handling, custom forms for login and registration, and simple integrations with providers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Integrations&lt;/strong&gt;: Auth.js integrates with JS frameworks easily thanks to its documentation that provide a simple guide to follow.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security&lt;/strong&gt;: Auth.js provides a high level of protection, it's a developer-friendly library, but we should not forget that it has a complexity under the hood that offers us a great level of security for our data.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Brief Introduction to Qwik
&lt;/h2&gt;

&lt;p&gt;Qwik is a framework created by the creator of Angular, Miško Hevery, with a collaboration of Adam Bradley, who created Ionic, and Manu Almeida, who created Gin Framework.&lt;/p&gt;

&lt;p&gt;Qwik, the HTML first framework’s philosophy is clear: make the fastest possible time-to-interactive (to do it faster by doing nothing).&lt;/p&gt;

&lt;p&gt;The framework delays the invocation of the javascript as much as possible and invokes it only what is absolutely needed. The focus is on the first load.&lt;/p&gt;

&lt;p&gt;If you want to dive deep in Qwik, we already have an article about it:&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/playfulprogramming" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__org__pic"&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%2Forganization%2Fprofile_image%2F3314%2Ffd92caab-2014-431e-a19e-8ab47f2bf5ab.png" alt="Playful Programming" width="800" height="800"&gt;
      &lt;div class="ltag__link__user__pic"&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%2Fuser%2Fprofile_image%2F1117404%2F134e85f1-22be-48d9-8251-71f77f4f910b.jpg" alt="" width="800" height="921"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/playfulprogramming/qwik-the-post-modern-framework-3c5o" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Qwik – The Post-Modern Framework&lt;/h2&gt;
      &lt;h3&gt;Ayoub Alouane for Playful Programming ・ Jul 11 '23&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#javascript&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#qwik&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#frontend&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#typescript&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  Integrate Auth.js to Qwik
&lt;/h2&gt;

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

&lt;p&gt;To get started with Qwik locally, we need the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://nodejs.org/en/download/" rel="noopener noreferrer"&gt;Node.js v16.8&lt;/a&gt; or higher&lt;/li&gt;
&lt;li&gt;Your favorite IDE (&lt;a href="https://code.visualstudio.com/" rel="noopener noreferrer"&gt;vscode&lt;/a&gt; recommended)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  App Creation
&lt;/h3&gt;

&lt;p&gt;Using the Qwik CLI we will start by starting a new Qwik Project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm create qwik@latest

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

&lt;/div&gt;



&lt;p&gt;Steps to create the project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌  Let's create a  Qwik App  ✨ (v1.0.0)
│
◇  Where would you like to create your new project?
│  ./qwik-auth
│
●  Creating new project in  /Users/mac/Documents/articles/qwik-auth  ... 🐇
│
◇  Select a starter
│  Basic App (QwikCity)
│
◇  Would you like to install npm dependencies?
│  Yes
│
◇  Initialize a new git repository?
│  Yes
│
◇  Created App 🐰
│
◇  Git initialized 🎲
│
◇  Installed dependencies 📋
│
○  Result ────────────────────────────────────────────────╮
│                                                         │
│  🦄  Success!  Project created in qwik-auth directory   │
│                                                         │
│  🐰 Next steps:                                         │
│     cd qwik-auth                                        │
│     npm start                                           │
│                                                         │
│  🤍 Integrations? Add Netlify, Cloudflare, Tailwind...  │
│     npm run qwik add                                    │
│                                                         │
│  📄 Relevant docs:                                      │
│     https://qwik.builder.io/docs/getting-started/       │
│                                                         │
│  💬 Questions? Start the conversation at:               │
│     https://qwik.builder.io/chat                        │
│     https://twitter.com/QwikDev                         │
│                                                         │
│  👀 Presentations, Podcasts and Videos:                 │
│     https://qwik.builder.io/media/                      │
│                                                         │
│                                                         │
├─────────────────────────────────────────────────────────╯
│
└  Happy coding! 🐇
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To run the server, we will need the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On port 5173 we will have our application running. Now we will install Auth.js:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run qwik add auth
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After installing Auth.js we should go to the file vite.config.js in order to add some configuration "optimizeDeps":&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { defineConfig } from 'vite';
import { qwikVite } from '@builder.io/qwik/optimizer';
import { qwikCity } from '@builder.io/qwik-city/vite';
import tsconfigPaths from 'vite-tsconfig-paths';

export default defineConfig(() =&amp;gt; {
  return {
    plugins: [qwikCity(), qwikVite(), tsconfigPaths()],
    preview: {
      headers: {
        'Cache-Control': 'public, max-age=600',
      },
    },
    **optimizeDeps: {
      include: [ "@auth/core" ]
    }**
  };
});

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

&lt;/div&gt;



&lt;p&gt;In this tutorial we will work with GitHub as our provider, so after installing Auth.js we will find that it added a file called: &lt;a href="mailto:plugin@auth.ts"&gt;plugin@auth.ts&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { serverAuth$ } from '@builder.io/qwik-auth';
import GitHub from '@auth/core/providers/github';
import type { Provider } from '@auth/core/providers';

export const { onRequest, useAuthSession, useAuthSignin, useAuthSignout } = serverAuth$(
  ({ env }) =&amp;gt; ({
    secret: env.get('AUTH_SECRET'),
    trustHost: true,
    providers: [
      GitHub({
        clientId: env.get('GITHUB_ID')!,
        clientSecret: env.get('GITHUB_SECRET')!,
      }),
    ] as Provider[],
  })
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Connecting to Github
&lt;/h3&gt;

&lt;p&gt;In the file: &lt;a href="mailto:plugin@auth.ts"&gt;plugin@auth.ts&lt;/a&gt;, we had some variables that we should define in our application AUTH_SECRET, GITHUB_ID and GITHUB_SECRET. To do that, we should create a file .env.local :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GITHUB_ID=*********************
GITHUB_SECRET=****************************
AUTH_SECRET=***********************************
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To generate the AUTH_SECRET we can use this website: &lt;a href="https://generate-secret.vercel.app/32" rel="noopener noreferrer"&gt;&lt;code&gt;https://generate-secret.vercel.app/32&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To generate the GITHUB_ID and GITHUB_SECRET we should go to our GitHub: Setting ⇒ Developer Setting ⇒ OAuth Apps, and we should create a new Auth App:&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%2F4evnis98bid9xzam994i.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%2F4evnis98bid9xzam994i.png" alt=" " width="800" height="872"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The result we are the generation of GITHUB_ID and GITHUB_SECRET.&lt;/p&gt;

&lt;h3&gt;
  
  
  Final Integration in our Code
&lt;/h3&gt;

&lt;p&gt;Auth.js provides us with multiple functions that will simplify for us the process of authentication:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;useAuthSignin&lt;/strong&gt;: it is a function that returns the action of sign-in to start the flow of authentication with redirection to a page with all the possible ways to sign in, example:&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;useAuthSession&lt;/strong&gt;: if we are not connected, it will return an empty object, but if we are connected, it will return a session object that contains multiple information, exemple:&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;useAuthSignout&lt;/strong&gt;: it is a function that provides us an action of signing out from our application, so all the parameters and objects that concern our session will be removed, example:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
import { component$ } from '@builder.io/qwik';
import { QwikLogo } from '../icons/qwik';
import styles from './header.module.css';
import { useAuthSignin, useAuthSession, useAuthSignout } from '~/routes/plugin@auth';

export default component$(() =&amp;gt; {
  const signIn = useAuthSignin();
    const session = useAuthSession();
  const signOut = useAuthSignout();


  return (
    &amp;lt;header class={styles.header}&amp;gt;
      &amp;lt;div class={['container', styles.wrapper]}&amp;gt;
        &amp;lt;div class={styles.logo}&amp;gt;
          &amp;lt;a href="/" title="qwik"&amp;gt;
            &amp;lt;QwikLogo height={50} width={143} /&amp;gt;
          &amp;lt;/a&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;ul&amp;gt;
          &amp;lt;li&amp;gt;
            &amp;lt;a href="https://qwik.builder.io/docs/components/overview/" target="_blank"&amp;gt;
              Docs
            &amp;lt;/a&amp;gt;
          &amp;lt;/li&amp;gt;
          &amp;lt;li&amp;gt;
            &amp;lt;a href="https://qwik.builder.io/examples/introduction/hello-world/" target="_blank"&amp;gt;
              Examples
            &amp;lt;/a&amp;gt;
          &amp;lt;/li&amp;gt;
          &amp;lt;li&amp;gt;
            &amp;lt;a href="https://qwik.builder.io/tutorial/welcome/overview/" target="_blank"&amp;gt;
              Tutorials
            &amp;lt;/a&amp;gt;
          &amp;lt;/li&amp;gt;
          &amp;lt;li&amp;gt;
            &amp;lt;span&amp;gt;
              {session.value?.user?.email}
            &amp;lt;/span&amp;gt;
          &amp;lt;/li&amp;gt;
          &amp;lt;li&amp;gt;
            {session.value?.user === undefined &amp;amp;&amp;amp; &amp;lt;button onClick$={() =&amp;gt; signIn.submit({ providerId: 'github', options: { callbackUrl: 'http://localhost:5173/' } })}&amp;gt;Sign In&amp;lt;/button&amp;gt;}
          &amp;lt;/li&amp;gt;
          &amp;lt;li&amp;gt;
            {session.value?.user !== undefined &amp;amp;&amp;amp; &amp;lt;button onClick$={() =&amp;gt; signOut.submit({ callbackUrl: '/' })}&amp;gt;Sign Out&amp;lt;/button&amp;gt;}
          &amp;lt;/li&amp;gt;
        &amp;lt;/ul&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/header&amp;gt;
  );
});

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

&lt;/div&gt;



&lt;p&gt;In the code above, we have a header that will have a button to sign in that we will show only if we are not connected:&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%2Fxpynymmjrbpjeg4ria3i.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%2Fxpynymmjrbpjeg4ria3i.png" alt=" " width="800" height="372"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So if we sign in successfully the button will disappear, and we will show the sign-out button with the user email in the header:&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%2Fdg0mgfek6dwsjil3n3uw.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%2Fdg0mgfek6dwsjil3n3uw.png" alt=" " width="800" height="357"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>frontend</category>
    </item>
    <item>
      <title>How SolidJS Works? The Easiest Introduction!</title>
      <dc:creator>Ayoub Alouane</dc:creator>
      <pubDate>Sun, 16 Jul 2023 21:34:10 +0000</pubDate>
      <link>https://dev.to/playfulprogramming/the-easiest-introduction-to-solidjs-pgi</link>
      <guid>https://dev.to/playfulprogramming/the-easiest-introduction-to-solidjs-pgi</guid>
      <description>&lt;p&gt;The first thing that come in mind is the fact that it’s the first framework for category (&lt;strong&gt;would use again&lt;/strong&gt;) and third for the category (&lt;strong&gt;want to learn&lt;/strong&gt;) in stateofjs 2022’s statistics, so we have here a really competitive framework that is getting its part in the market, it’s created by Ryan Carniato, a great fan of React as he said in much of his conferences.  &lt;/p&gt;

&lt;p&gt;Ryan Carniato is a Principal Engineer at Netlify, he was also a member of MarkoJS Core Team in eBay, he is known for his knockout.js background and also for his admiration of ReactJS. After being in the field for 25 years, he ended with creating one of the most innovative frameworks SolidJS, he started it in 2016 and the first release was in 2021, so we have here 5 years of development.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reactivity: the key concept of SolidJS
&lt;/h2&gt;

&lt;p&gt;Before talking about Reactivity in SolidJS we should have a good understanding of what is reactive programming, to illustrate the concept here is a simple exemple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = b + c
//* where the value of a updates whenever the value of b or c changes.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Reactive programming is a paradigm of building software systems that is based on data flow. Instead of viewing the system as a sequence of assignments, consider it to be a collection of continually changing dynamic equations. The code specifies the interactions between various system components and how they evolve over time. With reactive programming, the system may automatically adjust to changes without the need for continual intervention.&lt;/p&gt;

&lt;p&gt;Now let’s return to our reactivity in web development, it’s an important feature of user interface design because it guarantees that changes to the interface are reflected instantly. This is critical for providing users with a consistent and responsive experience.&lt;/p&gt;

&lt;p&gt;Reactivity was all time a subject of a lot of discussion between experts, they were continually arguing about the reactivity of every frameworks, for exemple ReactJS is known as reactive framework but for Hevery Misko (The creator of AngularJS, Angular ans Qwik) Angular and ReactsJS are not reactive frameworks.&lt;/p&gt;

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

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



&lt;/p&gt;

&lt;p&gt;But the same person will talk about SolidJS as a reactive framework:&lt;/p&gt;

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

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



&lt;/p&gt;

&lt;p&gt;By the way Mr Hevery has created a new Framework called Qwik that we covered in multiple articles, here is an introduction to his framework:&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/playfulprogramming" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__org__pic"&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%2Forganization%2Fprofile_image%2F3314%2Ffd92caab-2014-431e-a19e-8ab47f2bf5ab.png" alt="Playful Programming" width="800" height="800"&gt;
      &lt;div class="ltag__link__user__pic"&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%2Fuser%2Fprofile_image%2F1117404%2F134e85f1-22be-48d9-8251-71f77f4f910b.jpg" alt="" width="800" height="921"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/playfulprogramming/qwik-the-post-modern-framework-3c5o" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Qwik – The Post-Modern Framework&lt;/h2&gt;
      &lt;h3&gt;Ayoub Alouane for Playful Programming ・ Jul 11 '23&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#javascript&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#qwik&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#frontend&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#typescript&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;



&lt;p&gt;Here in this tweet, Mr Misko mentioned a core principe in reactivity, fine-grained reactivity, so what is it? &lt;/p&gt;

&lt;h2&gt;
  
  
  Fine-grained Reactivity
&lt;/h2&gt;

&lt;p&gt;Fine-grained reactivity is a type of reactivity that is applied at the most granular level possible. Ryan Carniato in his famous article has talked about it with a significant exemple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Fine-grained reactivity is built from a network of primitives. By primitives, I am referring to simple constructs like &lt;code&gt;Promises&lt;/code&gt; rather than JavaScript's primitive values like strings or numbers.&lt;br&gt;
Each act as nodes in a graph. You can think of it as an idealised electric circuit. Any change applies to all nodes at the same time. The problem being solved is synchronisation at a single point in time. This is a problem space we often work in when building user interfaces.&lt;br&gt;
-Ryan Carniato&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is the core concept of SolidJS, and to have a solid understanding, we should be aware of 3 important concepts: Signals, Memos and Effects.&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%2Ftgmabvevri4l8wqq7w31.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%2Ftgmabvevri4l8wqq7w31.png" alt=" " width="800" height="125"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Signals&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Signals are the elements that we want to watch, they are composed of a getter, a setter and the value. Exemple of code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const [count, setCount] = createSignal(0);

// read a value
console.log(count()); // 0

// set a value
setCount(3);
console.log(count()); //result: 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Effects&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So Signals are the ones we watch, but who is the watcher? it’s the Effect, it’s role is to observe the Signal, exemple pf code:&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%2F2l2h16ig8nqnqk0cv8q6.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%2F2l2h16ig8nqnqk0cv8q6.png" alt=" " width="800" height="242"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Like we can see in this exemple, the signal that we created is the Observable, and the effect is the one who is watching the change that happen in the Signal, so whenever the value of the count changed, the effect is here to execute an instruction.&lt;/p&gt;

&lt;p&gt;But importantly, the updates occur in real time. The Effect has already executed before we can log the following instruction.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Memos&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Memo we can consider it as an observer and a Observable in the same time, in other words it combines the Signal and the Effect, here is an exemple:&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%2Fveohow9furvosvmymhau.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%2Fveohow9furvosvmymhau.png" alt=" " width="800" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this exemple Memos represent a Signal for the the Effect that we created in line 5, so Memo here change if one of the first 2 signal changes, so it depends to its dependencies.&lt;/p&gt;

&lt;p&gt;As we can see this approach will save us a lot of work, and it’s not limited to giving values, we can do more of that, the Memo can have instructions (if…else) to have more control on the actions that we want to perform.&lt;/p&gt;

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

&lt;p&gt;SolidJS as we can see is a revolutionary Framework, a lot of work done in it, the present article doesn’t cover all the principle subjects in SolidJs, but it’s a sort of an Overview of the Framework and how it works. &lt;/p&gt;

&lt;p&gt;This article provided an overview of fine-grained reactivity, a notion that become a subject of lot of innovations in JavaScript front-end development.&lt;/p&gt;

</description>
      <category>solidjs</category>
      <category>javascript</category>
      <category>frontend</category>
      <category>development</category>
    </item>
    <item>
      <title>Astro Framework: Revolutionizing Web Development with Island Architecture and Zero-Javascript Approach</title>
      <dc:creator>Ayoub Alouane</dc:creator>
      <pubDate>Thu, 13 Jul 2023 14:06:31 +0000</pubDate>
      <link>https://dev.to/playfulprogramming/astro-framework-169m</link>
      <guid>https://dev.to/playfulprogramming/astro-framework-169m</guid>
      <description>&lt;p&gt;Astro is a tool known for making things easier by building a multi page application and shipping with no Javascript by default. Meaning, only the HTML file will be sent to the browser, with zero JS needed to get loaded on the browser and slow you down.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction to Astro
&lt;/h2&gt;

&lt;p&gt;Instead of heavy interactive apps, Astro is designed to target content-based websites. Astro is a really great option for that, as much as we want to publish some content. &lt;/p&gt;

&lt;p&gt;It's a kind of server-first, it privileges server-side rendering over client-side rendering as much as possible.&lt;/p&gt;

&lt;p&gt;Astro was created for creating webpages with lots of content. This covers the majority of e-commerce sites, blogs, publishing sites, documentation sites, and blogs.&lt;/p&gt;

&lt;p&gt;We need to know something crucial before beginning our review. The distinction between a web application and a website;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;WebSites (as opposed to web applications) lack dynamic content updates and are hence static. Visitors cannot engage with them or send messages back to the site.&lt;/li&gt;
&lt;li&gt;WebApps: Web apps are websites with interactive features and capabilities. A web application is computer software that is accessed through a web browser and frequently linked to a database to offer a customized interactive experience for the user.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Having said this, you should be aware that Astro might not be the ideal option for your project if you're trying to build a web application. &lt;/p&gt;

&lt;p&gt;For your web application-focused project, exploring over Next.js framework as an option would be more appropriate in your situation.&lt;/p&gt;

&lt;p&gt;Astro team made sure we can utilize any favorite UI component language that we already are familiar with. Frameworks such as Svelte, React, Vue, Lit, Solid, etc. are compatible for creating new UI components in Astro projects.&lt;/p&gt;

&lt;p&gt;All web developers should be able to use Astro, this is what the team behind Astro had in ming. Regardless your previous web development expertise or skill level, Astro is built with an easy to use approach.&lt;/p&gt;

&lt;h2&gt;
  
  
  Partial Hydration, what is it?
&lt;/h2&gt;

&lt;p&gt;The concept of partial hydration allows developers to determine what aspects are loaded and when, in order to provide fast interactivity. This is done by being able to put some client-side JS only where it is needed using something referred as "island architecture".&lt;/p&gt;

&lt;p&gt;Partial hydration definitely is a wise and practical strategy. Our webpage initially is sent as pure HTML from the server to the client. JavaScript is not shipped by default. &lt;/p&gt;

&lt;p&gt;However, we know that JavaScript is what makes our page interactive. This is where hydration comes into play as the procedure of loading JavaScript.&lt;/p&gt;

&lt;p&gt;Hydration is cool, it’s in place only when we need it, for example, if we have a page that starts with content that doesn’t need interaction, javascript is not needed.&lt;/p&gt;

&lt;p&gt;So we load nothing, but if scroll down to the footer when we have a form-contact that need interaction with the user, here the hydration comes in place to hydrate our page with the javascript needed for the form.&lt;/p&gt;

&lt;h2&gt;
  
  
  How is Partial Hydration implemented in Astro?
&lt;/h2&gt;

&lt;p&gt;The guiding principle of Astro is to build Islands of Interactivity that the browser can hydrate on its own. Astro Island is the solution.&lt;/p&gt;

&lt;p&gt;We can optimize how the page loads javascript by treating each component (Island) independently.&lt;/p&gt;

&lt;p&gt;We divide the page into multiple components, each element has its own case. Image carousels need javascript, text or image doesn’t need it, a comment section needs javascript, and so on.&lt;/p&gt;

&lt;p&gt;In Astro we are able to tell the component how to be rendered, it's up to us to choose, we can for exemple decide that the component's JavaScript code should be rendered in the initial load of the page, or maybe hydrate the component with JavaScript after finishing the first load, also we can be more precise ad say That the component should be hydrated only if it's visible to the user, that's some of the cases that we can choose fo rendering.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pros of Island Architecture
&lt;/h2&gt;

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

&lt;p&gt;The Islands design incorporates principles from several rendering approaches, including server-side rendering, static site generation, and partial hydration.&lt;/p&gt;

&lt;p&gt;The following are some of the major advantages of integrating islands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Pattern provides all of the benefits of component-based architecture, such as reusability and maintainability.&lt;/li&gt;
&lt;li&gt;Improves performance by decreasing the quantity of JavaScript code sent to the client. The code delivered only contains the script needed for interactive components, which is significantly less than the script required to build the virtual DOM for the full page and rehydrate all of the page's elements.&lt;/li&gt;
&lt;li&gt;Websites are SEO-friendly because all static content is rendered on the server.&lt;/li&gt;
&lt;li&gt;Using standard static HTML links to reach other pages helps to increase the website's accessibility.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Astro is MPA or SPA?
&lt;/h2&gt;

&lt;p&gt;Astro is unique in that it is both a static site generator and strives to keep JavaScript out of the final build as much as possible. It also prefers multi-page apps over single-page apps (SPAs).&lt;/p&gt;

&lt;p&gt;A website may be built in a variety of ways. The Single Page Applications (SPAs) concept promoted by Angular and React, has mostly overtaken MPAs, but Multi-Page Applications (MPAs) are making a comeback due to the amount of Javascript we transport to the browser using SPAs.&lt;/p&gt;

&lt;p&gt;Fast startup is crucial for many websites, for many sites and apps with little interactivity, a client-rendered framework like Angular is overkill.&lt;/p&gt;

&lt;p&gt;This generation of MPAs is distinct from earlier generations. Astro has a component-based approach employing the island's architecture.&lt;/p&gt;

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

&lt;p&gt;A lot of specialists in the field believe that Astro may probably completely change how websites are built. &lt;/p&gt;

&lt;p&gt;The fact that astro build websites without a client-side JavaScript by default will have a major impact on the performance because it removes all the unused JavaScript code.&lt;/p&gt;

</description>
      <category>astro</category>
      <category>javascript</category>
      <category>frontend</category>
      <category>development</category>
    </item>
    <item>
      <title>A Brief History of Web Apps – Why Qwik is Innovative</title>
      <dc:creator>Ayoub Alouane</dc:creator>
      <pubDate>Wed, 12 Jul 2023 13:31:57 +0000</pubDate>
      <link>https://dev.to/playfulprogramming/a-brief-history-of-web-apps-why-qwik-is-innovative-456f</link>
      <guid>https://dev.to/playfulprogramming/a-brief-history-of-web-apps-why-qwik-is-innovative-456f</guid>
      <description>&lt;p&gt;Let us together see how web applications were built over different generational approaches. Before talking about Qwik, there is a history before it, which we can split by generations, each generation has a concept that changed everything.&lt;/p&gt;

&lt;p&gt;Before starting here is our &lt;a href="https://dev.to/this-is-learning/qwik-the-post-modern-framework-3c5o"&gt;first article&lt;/a&gt; about Qwik. &lt;/p&gt;

&lt;h2&gt;
  
  
  1st Generation of Web Apps
&lt;/h2&gt;

&lt;p&gt;The first generation of rendering, as Hevery (The Creator of Angular and Qwik) said, was done on the server with technologies such as PHP. The server rendering was made interactive on the client with javascript (JQuery.) The role of the server here is to send a template every time it is called. &lt;/p&gt;

&lt;p&gt;The server renders a sort of document that contains HTML and javascript. We use JQuery as a tool to add interactivity within the template. &lt;/p&gt;

&lt;p&gt;So what’s the problem with this approach? &lt;/p&gt;

&lt;p&gt;The issue is that we have to deal with two languages, one on the server (such as PHP) and another on the client side, which is undoubtedly Javascript which may cause confusion between the element that was written in PHP and its behavior in javascript and that leads to writing a functionality multiple times. &lt;/p&gt;

&lt;p&gt;That's why this approach is hard to scale. &lt;/p&gt;

&lt;h2&gt;
  
  
  2nd Generation of Web Apps
&lt;/h2&gt;

&lt;p&gt;Here comes the second generation, the famous SPA (Single Page Application), the modern frameworks like AngularJS, Angular, React, or VueJS. &lt;/p&gt;

&lt;p&gt;The first generation had an MPA (Multiple Page Application) approaches. Now, let’s return to SPA. &lt;/p&gt;

&lt;p&gt;The concept is never reloading the page and only making calls to the server to update the state on the client side, but in the first launch, we load all the applications as a javascript code. &lt;/p&gt;

&lt;p&gt;That was a revolutionary approach in the history of web development, but the history of the idea started with AJAX, which gives us the possibility to update data without reloading the page. &lt;/p&gt;

&lt;p&gt;After that, JQuery came into play, which introduced an optimized approach to make dynamic pages or to give life to our pages, and other frameworks also, like KnockoutJS and BackboneJS, that tried to fix multiple issues. &lt;/p&gt;

&lt;p&gt;Still, if we want to talk about the first SPA framework, it is by far AngularJS that was the most complete, because it contained dependency injection, two-way data binding, and templating. &lt;/p&gt;

&lt;p&gt;All of that is based on an MVC (Model-View-Controller) architecture. The surprise here is what?&lt;/p&gt;

&lt;p&gt;Misko Hevery, who created Qwik, is the same who created AngularJS, the first SPA framework. &lt;/p&gt;

&lt;p&gt;So, what’s the problem with the SPA? It’s the first load, it will start with a blank page taking a long time to load, and it’s not scalable if we want to work on big applications. &lt;/p&gt;

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

&lt;h2&gt;
  
  
  Between 2nd &amp;amp; 3rd generation of Web Apps
&lt;/h2&gt;

&lt;p&gt;Before the third generation, we should talk about the second and a half-generation, and its SSR (Server Side Rendering) with frameworks like NextJS or SvelteKit. &lt;/p&gt;

&lt;p&gt;These ones introduced a different but not revolutionary approach. In SSR, we still build SPA applications but with a different concept.&lt;/p&gt;

&lt;p&gt;We pre-render HTML, and we hydrate it with javascript after that, so the result here is only to reduce the time of seeing a blank page. So, it’s not interactive until we hydrate it with the Javascript needed for the elements. &lt;/p&gt;

&lt;p&gt;For example in the process of loading JS, if the JS needed for a button is loaded we can interact with it, but the JS needed for a form is not loaded yet, the form is still not interactive.&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%2Faq5f2rh1xxq73y9xcvq2.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faq5f2rh1xxq73y9xcvq2.jpg" alt=" " width="800" height="297"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here comes another framework that tried to reduce the time consumed in this process, it’s the Astro framework.&lt;/p&gt;

&lt;p&gt;Astro has a concept called Partial Hydration, so it doesn’t hydrate the page with JS until it’s visible. &lt;/p&gt;

&lt;p&gt;For example, if we have a contact form at the bottom of the page and we are at the top of it, the contact form won’t be visible, and this way we don’t need to load the javascript needed for the form.&lt;/p&gt;

&lt;p&gt;Only if we scroll down to the section where we have the contact form, this is when the hydration takes place to hydrate the components in our form with the Javascript needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  3rd generation of Web Apps as the new era
&lt;/h2&gt;

&lt;p&gt;The revolution has already started after the first revolution created by Misko Hevery. Here is the second one he created, Qwik Framework introduces Resumability. &lt;/p&gt;

&lt;p&gt;We now have a solid understanding of hydration and partial hydration, but Resumability has an approach of “stop/resume,” resuming the application where the server left off in place of replaying all of the work. &lt;/p&gt;

&lt;p&gt;If you have the contact form at the bottom, we don’t call his javascript even if you scroll down, we call it only if you click on the send button. In order to understand this a bit further, let’s dive into some technical aspects. &lt;/p&gt;

&lt;p&gt;The secret here is about entry points. Unlike other frameworks, Qwik gives us the ability to stop and resume the application from everywhere, and because it’s not limited to one entry point like modern frameworks.&lt;/p&gt;

&lt;p&gt;The entry point provides us the possibility to download the code needed for a given interaction that we want to perform, whereas in the 2nd generation we can’t click on a button until all the application is loaded, and that’s the opposite of what resumability provides.&lt;/p&gt;

&lt;p&gt;We load the javascript needed for the interaction only if we click on the button. The challenge here is how we do that.&lt;/p&gt;

&lt;p&gt;The question is quickly answered: Listeners! &lt;/p&gt;

&lt;p&gt;Qwik has a global listener that ensures that every time an event happens, it searches for the specific listener needed and attaches it to the DOM in order to call the entry point needed. &lt;/p&gt;

&lt;p&gt;It does that with the serialized information that is attached to the click event, for example. &lt;/p&gt;

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

&lt;p&gt;In this article, we had a look at the evolution of rendering and how it used to impact the performance of web apps versus how it's impacting nowadays. &lt;/p&gt;

&lt;p&gt;Now, a new generation is here, and Qwik is one among those who represent it in the best way. Other modern frameworks do not have the same approach because the difference is fundamental. It’s all about having (n) entry points so we can provide resumability and lazy loading. &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>qwik</category>
      <category>frontend</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Qwik – The Post-Modern Framework</title>
      <dc:creator>Ayoub Alouane</dc:creator>
      <pubDate>Tue, 11 Jul 2023 10:38:57 +0000</pubDate>
      <link>https://dev.to/playfulprogramming/qwik-the-post-modern-framework-3c5o</link>
      <guid>https://dev.to/playfulprogramming/qwik-the-post-modern-framework-3c5o</guid>
      <description>&lt;h2&gt;
  
  
  Qwik introduction
&lt;/h2&gt;

&lt;p&gt;Modern frameworks face a big challenge of performance, they are not on top of what companies are looking for.&lt;/p&gt;

&lt;p&gt;Some of these frameworks have adapted performance as the real utility of them, for example, Svelte, but none of them have reached the real expectations because they are looking to make web apps faster in the run-time, but no one is looking for the source of the problem.&lt;/p&gt;

&lt;p&gt;Here comes Qwik, which adopted a different approach, the focus shift from "doing faster" to "doing less”. It’s a key difference that will change the game. Ultimately, the fastest tool is probably the one doing the least amount of (repetitive) work.&lt;/p&gt;

&lt;p&gt;Qwik is a framework created by the creator of Angular, Misko Hevery, with a collaboration of Adam Bradley, who created Ionic, and Manu Almeida, who created Gin Framework.&lt;/p&gt;

&lt;p&gt;These are pioneers of web development. I don’t think we are dealing with just another javascript framework. Maybe we should be prepared for a new framework that will change the paradigm.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Qwik?
&lt;/h2&gt;

&lt;p&gt;Qwik comes with a clear goal: achieving top performance, perfection, 0 javascript, and pure HTML. Yes, we are here. It’s time for that. Qwik is trying and also succeeding to go beyond what other frameworks can do.&lt;/p&gt;

&lt;p&gt;The last framework that came with a new concept was Astro, which introduced partial hydration, a revolution in javascript frameworks.&lt;/p&gt;

&lt;p&gt;For example, if we have a page that starts with a text that does not need javascript, we load nothing, but if we scroll down to a component that needs javascript for the interaction, we hydrate the page with the needed javascript.&lt;/p&gt;

&lt;p&gt;Qwik killed the game, with no partial hydration but zero hydration and 0 javascript on the first load.&lt;/p&gt;

&lt;p&gt;For instance, if we have a form contact at the bottom of a page, Angular, React, or VueJS will load the javascript needed on the first load, Astro will load it if we scroll down, Qwik will load it only and only if we click on the send button of the form, it loads javascript not when we have the form in front of us but if we interact with it.‍&lt;/p&gt;

&lt;h2&gt;
  
  
  Qwik key concept
&lt;/h2&gt;

&lt;p&gt;Qwik, the HTML first framework’s philosophy is clear: make the fastest possible time-to-interactive (to do it faster by doing nothing).&lt;/p&gt;

&lt;p&gt;The framework delays the invocation of the javascript as much as possible and invokes it only what is absolutely needed. The focus is on the first load.&lt;/p&gt;

&lt;p&gt;As such, it only loads pure HTML. To achieve this, Qwik is based on an important concept. In this paragraph, we will dive deep into it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resumability
&lt;/h2&gt;

&lt;p&gt;The modern frameworks now compete to improve hydration. Qwik is unique in that it has resumability.&lt;/p&gt;

&lt;p&gt;The name of the concept gives us a perception of what we are talking about, “stop/resume,” resume the application where the server left off in place of replaying all of the work.&lt;/p&gt;

&lt;p&gt;Serializing event handlers is the key to stopping and resuming the application. But doing this is not something new, we did it before through jQuery.&lt;/p&gt;

&lt;p&gt;For example, using pure javascript. The difference with Qwik is that working on Qwik is like working on React, it has adopted the modern DX.&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%2Fpkrg19c7ktxpj9gr0r5k.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%2Fpkrg19c7ktxpj9gr0r5k.png" alt=" " width="800" height="383"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If we try to think deeply about the figure above, we will understand the reel problem, scaling. If we have an extensive web application, it will take a lot of time to load with hydration.&lt;/p&gt;

&lt;p&gt;Even with Partial Hydration, it will be challenging to scale, Qwik with the resumability only loads HTML, which does not take a lot of time.&lt;/p&gt;

&lt;p&gt;It’s a fraction of a second and you have your application loaded in your browser.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prefetching
&lt;/h2&gt;

&lt;p&gt;To be precise, Qwik will not download every file only when you click, but after doing the first load to show the page (that is interactive), the framework will start automatically downloading the code necessary fo the web app using a service worker, and it will store it in the browser's cache, so we will not send a request to the server every time, but it will grab it instantly from the cache, if the code is not downloaded yet it will download it from the server, and that's what we call prefetching.&lt;/p&gt;

&lt;p&gt;So when we say "load the javascript" we are talking about getting the JavaScript code from the cache and executing it only when we need it, other frameworks download and execute the JavaScript code in the first load, and that's what cause a lot of performance issues. Qwik is interactive from the first load without the need to wait for all the javascript to be downloaded.&lt;/p&gt;

&lt;h2&gt;
  
  
  Qwik City
&lt;/h2&gt;

&lt;p&gt;On the 1st of May 2022, Hevery said in a podcast that their goal is building a router that offers the capability of doing MPA (multiple page application) routing with the benefits of SPA (Single page application) routing. In other words, doing MPA rooting without refreshing the page.&lt;/p&gt;

&lt;p&gt;Only render the parts that need refreshing. That may sound like fiction, but it’s already done, they did it, and its name is Qwik City.&lt;/p&gt;

&lt;p&gt;So Qwik is a mix of server-side rendering and client-side rendering. It takes advantage of the two of them.&lt;/p&gt;

&lt;p&gt;Qwik City is the meta-framework designed for Qwik, like Next.js for React.js. The routing in Qwik City is so simple, it’s based on the structure of our directories in the routes directories.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src/

└── routes/

    └── some/

        └── path/

            └── index.tsx       &amp;lt;https://example.com/some/path&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;With our 0 javascript meta-framework, the application is loaded without a single javascript dedicated to Qwik city, but there is more than that. It also offers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Directory-based routing&lt;/li&gt;
&lt;li&gt;Nested layouts&lt;/li&gt;
&lt;li&gt;File-based menus&lt;/li&gt;
&lt;li&gt;Breadcrumbs&lt;/li&gt;
&lt;li&gt;Support authoring content with .tsx or .mdx file formats&lt;/li&gt;
&lt;li&gt;Data endpoints&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;Modern frameworks download all the javascript, and after that, they execute all of it.&lt;/p&gt;

&lt;p&gt;Qwik downloads a little bit of javascript, and it doesn’t execute it until we need it. The framework is changing the mental model.&lt;/p&gt;

&lt;p&gt;We think that Qwik will be one of the pioneers in the JS frameworks. It has improved startup performance, which is a real problem of modern frameworks, but with Qwik, it’s not the case.&lt;/p&gt;

&lt;p&gt;Let us see the future and stay tuned because this is our first article about the framework, and of course, it’s not the last. In the coming articles, we will dive deep into the core concepts, and we will do some examples of building Qwik applications.&lt;/p&gt;

&lt;p&gt;This article has been reviewed kindly by Mr Havery Misko (The creator of Angular and Qwik), we thank him a lot for his contribution.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.adservio.fr/post/qwik-the-post-modern-framework" rel="noopener noreferrer"&gt;Link to Original Article.&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>qwik</category>
      <category>frontend</category>
      <category>typescript</category>
    </item>
  </channel>
</rss>
