<?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: Brittney Postma</title>
    <description>The latest articles on DEV Community by Brittney Postma (@brittneypostma).</description>
    <link>https://dev.to/brittneypostma</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%2F130598%2Fe665596a-e2da-4426-8a43-4028ebed0413.png</url>
      <title>DEV Community: Brittney Postma</title>
      <link>https://dev.to/brittneypostma</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/brittneypostma"/>
    <language>en</language>
    <item>
      <title>Migrating Breaking Changes in SvelteKit</title>
      <dc:creator>Brittney Postma</dc:creator>
      <pubDate>Mon, 29 Aug 2022 18:16:38 +0000</pubDate>
      <link>https://dev.to/brittneypostma/migrating-breaking-changes-in-sveltekit-965</link>
      <guid>https://dev.to/brittneypostma/migrating-breaking-changes-in-sveltekit-965</guid>
      <description>&lt;p&gt;SvelteKit has gone through a few breaking changes recently including an entire routing overhaul, changes to the load API, and a switch to the Vite CLI. If you’ve used it in the past, it may look quite a bit different than it used to. Just looking at the &lt;a href="https://svelte.dev/blog/whats-new-in-svelte-august-2022"&gt;August updates&lt;/a&gt;, there were &lt;strong&gt;ten&lt;/strong&gt; breaking changes. It’s a lot to keep up with, so this post will review the biggest breaking changes and navigate you through migrating an app to get it up to date.&lt;/p&gt;

&lt;h2&gt;
  
  
  So Long File Based Routing
&lt;/h2&gt;

&lt;p&gt;By far the biggest change in SvelteKit is doing away with file-based routing. There is still a &lt;code&gt;routes&lt;/code&gt; directory where you will create your routes, but they are now directory based and require a &lt;code&gt;+&lt;/code&gt; prefix to generate a route. &lt;/p&gt;

&lt;h3&gt;
  
  
  Routing The Old Way
&lt;/h3&gt;

&lt;p&gt;Before, any file added to the &lt;code&gt;routes&lt;/code&gt; directory would create a route at that name. This made it difficult to colocate files without more confusing syntax. Double underscores, &lt;code&gt;__&lt;/code&gt; indicated a layout or error route, and a single underscore, &lt;code&gt;_&lt;/code&gt; would skip creating it as a route. Things were messy and nothing was grouped together.&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
  ├ 📄 index.svelte
  ├ 📄 about.svelte
  ├ 📄 __layout.svelte
  ├ 📄 __layout-nested.svelte
  ├ 📄 __error.svelte
  └ 📂 nested-route
    └ 📄 _component-for-nested.svelte  
    └ 📄 index@nested.svelte
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Routing The New Way
&lt;/h3&gt;

&lt;p&gt;Now all routes are directory based, other than the home or root route, all new routes need to be in a folder. The old &lt;code&gt;index.svelte&lt;/code&gt; has gone away in favor of &lt;code&gt;+page.svelte&lt;/code&gt; to indicate you are deliberately creating a route. You also no longer need the underscore, &lt;code&gt;_&lt;/code&gt;, to colocate a component to a route. It’s much clearer what route each file is attached to in the new routing structure.&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
  ├ 📄 +page.svelte
  ├ 📄 +layout.svelte
  ├ 📄 +error.svelte
  └  📂 about
     ├ 📄 coc.svelte
     ├ 📄 +page.svelte
     └ 📄 +layout.svelte
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;p&gt;To find out more about why these changes happened, there are some really good conversations that happened on GitHub and the documentation walks through the new setup.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://kit.svelte.dev/docs/routing"&gt;Routing Docs&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/sveltejs/kit/discussions/5748"&gt;RFC Discussion on Changes&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3294867"&gt;Overview of Routing Changes&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/sveltejs/kit/discussions/5748#discussioncomment-3282732"&gt;Comment from Rich on Routing Changes&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Layout Overhaul
&lt;/h2&gt;

&lt;p&gt;Layouts in Svelte have gone through a major overhaul. No longer do multiple layouts live in the root of the routes directory, then naming them on a file such as &lt;code&gt;index@nested.svelte&lt;/code&gt;. Basic layouts are now &lt;code&gt;+layout.svelte&lt;/code&gt; files and will inherit from the root layout no matter how nested they are. &lt;/p&gt;

&lt;h3&gt;
  
  
  Layouts The Old Way
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;📂 src
└ 📂 routes
  ├ 📄 index.svelte
  ├ 📄 __layout.svelte
  ├ 📄 __layout-nested.svelte
  └ 📂 nested-route
    └ 📄 index@nested.svelte
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Layouts The New Way
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;📂 src
└ 📂 routes
  ├ 📄 +page.svelte
  ├ 📄 +layout.svelte
  └  📂 about
     ├ 📄 +page.svelte
     └ 📄 +layout.svelte // will inherit the src/routes/+layout.svelte layout
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Group Layouts
&lt;/h3&gt;

&lt;p&gt;There is also a new convention to share layouts with a folder wrapped in parenthesis&lt;code&gt;()&lt;/code&gt;called a group directory. Group directories do not affect the URL pathname of the nested routes, it essentially acts as a root route. A &lt;code&gt;+page.svelte&lt;/code&gt; file can be added to a &lt;code&gt;(group)&lt;/code&gt; directory root if the &lt;code&gt;/&lt;/code&gt; or home route should be the group. Since layouts inherit all the way down, you may want to use a different layout in a nested route. To do that we can still use the named layout syntax of &lt;code&gt;+page@nested.svelte&lt;/code&gt; where nested is the name of the layout you wish to use. To opt out of a layout entirely and reset it, create a &lt;code&gt;+layout@.svelte&lt;/code&gt; file in the directory by the &lt;code&gt;+page.svelte&lt;/code&gt; file that needs reset.&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
  ├ 📄 +layout.svelte
  └  📂 (marketing) // group routes
     ├ 📂 about
       ├ 📂 embed
         ├ 📄 +page.svelte
         └ 📄 +layout@(marketing).svelte // this will skip the about layout
       └ 📄 +layout.svelte
     ├ 📂 coc
       ├ 📄 +page.svelte
       └ 📄 +layout@.svelte //this will opt out of all layouts
     ├ 📄 +page.svelte // lives at / not /marketing
     └ 📄 +layout.svelte
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;p&gt;These changes were not the most straightforward and even the documentation is a little difficult to parse right now, but it is there. I found the discussion of the changes on GitHub to be more helpful and easier to understand.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://kit.svelte.dev/docs/routing#layout"&gt;Layout Docs&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://kit.svelte.dev/docs/advanced-routing#advanced-layouts"&gt;Advanced Layout Docs&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/sveltejs/kit/pull/6174"&gt;RFC Discussion on Changes&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Removing Confusion on Load
&lt;/h2&gt;

&lt;p&gt;The load function is how a SvelteKit route receives outside data, such as from a database or 3rd party API. Before there was always confusion around whether the &lt;code&gt;load&lt;/code&gt; function ran on the server or the client and was never clear if secrets were leaking through to the client. The &lt;code&gt;load&lt;/code&gt; function has now moved out of the &lt;code&gt;.svelte&lt;/code&gt; file and into an &lt;em&gt;endpoint&lt;/em&gt; file. &lt;/p&gt;

&lt;h3&gt;
  
  
  Load The Old Way
&lt;/h3&gt;

&lt;p&gt;Before, the load function lived in the &lt;code&gt;context="module"&lt;/code&gt; script tag inside of the &lt;code&gt;.svelte&lt;/code&gt; file or the data for the route was magically returned from an endpoint. Not all that long ago, another change occurred to the way data was loaded into a component. While the official name was &lt;strong&gt;page endpoints&lt;/strong&gt;, us diehards kept fighting for the obviously cooler sounding &lt;strong&gt;shadow endpoints&lt;/strong&gt;. These automagically loaded the data from the endpoint directly into the &lt;code&gt;.svelte&lt;/code&gt; route by returning the data and then exporting a prop of the same name in the route.&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
  ├ 📄 index.svelte
  ├ 📄 index.js
  ├ 📄 about.svelte
  ├ 📄 about.js
  ├ 📄 __layout.svelte
  ├ 📄 __layout-nested.svelte
  ├ 📄 __error.svelte
  └ 📂 nested-route
    ├ 📄 index.js
    └ 📄 index@nested.svelte
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// in a .svelte route&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;script&lt;/span&gt; &lt;span class="na"&gt;context&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"module"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  export const load = () =&amp;gt; &lt;span class="si"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;propName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;arbitrary data&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;props&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;propName&lt;/span&gt;
      &lt;span class="p"&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;script&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;script&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  export let propName
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;script&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;Use the &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;propName&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;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Load The New Way
&lt;/h3&gt;

&lt;p&gt;Now the &lt;code&gt;load&lt;/code&gt; function has moved into the endpoint file and the magical loading of data into the &lt;code&gt;.svelte&lt;/code&gt; file still exists and passes to the route with the &lt;code&gt;data&lt;/code&gt; prop. There are two new files you can use to load data into a route. The &lt;code&gt;+page.js&lt;/code&gt; (or &lt;code&gt;+page.ts&lt;/code&gt; for TypeScript) runs on the server during server-side rendering and again in the client when client-side navigating. There is also a &lt;code&gt;+page.server.js&lt;/code&gt; that will &lt;strong&gt;only&lt;/strong&gt; run on the server making it safe for API keys and secure SDKs you don’t want leaked to the client. You also no longer need to return the data inside of a props object. You determine where that data loads, either only on the server or both the server and client. In the &lt;code&gt;+page.svelte&lt;/code&gt; route file, the prop is simply named &lt;code&gt;data&lt;/code&gt; now.&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
  ├ 📄 +page.svelte
  ├ 📄 +page.js
  ├ 📄 +layout.svelte
  ├ 📄 +error.svelte
  └  📂 about
     ├ 📄 +page.svelte
     ├ 📄 +page.server.js
     └ 📄 +layout.svelte
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// in a +page.js or +page.server.js endpoint&lt;/span&gt;
&lt;span class="c1"&gt;// copy over your load function from before&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;load&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;propName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;arbitrary data&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// remove the props object &lt;/span&gt;
    &lt;span class="nx"&gt;propName&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;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// in a +page.svelte route&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;script&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  export let data
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;script&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;Use the &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;propName&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;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Page Behavior
&lt;/h3&gt;

&lt;p&gt;The exports that dictated a pages behavior have also moved from the &lt;code&gt;&amp;lt;script context="module"&amp;gt;&lt;/code&gt; into the endpoint file &lt;code&gt;+page.js&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;export const prerender = true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt; overrides &lt;a href="https://kit.svelte.dev/docs/configuration#prerender"&gt;config.kit.prerender.default&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;export const hydrate = true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt; overrides &lt;a href="https://kit.svelte.dev/docs/configuration#browser"&gt;config.kit.browser.hydrate&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;export const router = true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt; overrides &lt;a href="https://kit.svelte.dev/docs/configuration#browser"&gt;config.kit.browser.router&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;p&gt;Here are some links to the documentation for the new endpoint files and loading data.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://kit.svelte.dev/docs/routing#page-page-js"&gt;+page.js Docs&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://kit.svelte.dev/docs/routing#page-page-server-js"&gt;+page.server.js Docs&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://kit.svelte.dev/docs/load"&gt;Loading Data Docs&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  All in on Vite
&lt;/h2&gt;

&lt;p&gt;SvelteKit has gone all in on the Vite ecosystem by pulling out the Vite config and becoming a Vite plugin. Way back in the day SvelteKit ran on Snowpack. They made the decision to switch after Vite version 2 came out in 2021 and added support for other frameworks besides Vue. That was just the underlying build tool and SvelteKit was still passing along the Vite configuration through its own &lt;code&gt;svelte.config.js&lt;/code&gt; file and using its own &lt;code&gt;sveltekit&lt;/code&gt; CLI command for running the dev and build scripts. This was using an experimental method and the goal was to move to a more standard way that frameworks typically interact with Vite, through a plugin. This allows for first-party support for tools like Vitest and Storybook that look for a Vite config file. With the new changes, SvelteKit is just a Vite project that uses the &lt;code&gt;@sveltejs/kit/vite&lt;/code&gt; plugin and switched to the Vite CLI for the dev and build scripts. There is now a &lt;code&gt;vite.config.js&lt;/code&gt; file at the root of a SvelteKit project, that includes the plugin along with any other &lt;a href="https://vitejs.dev/config/"&gt;Vite configuration&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Vite The Old Way
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// svelte.config.js&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;adapter&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;@sveltejs/adapter-auto&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="nx"&gt;preprocess&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;svelte-preprocess&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="cm"&gt;/** @type {import('@sveltejs/kit').Config} */&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="c1"&gt;// Consult https://github.com/sveltejs/svelte-preprocess&lt;/span&gt;
&lt;span class="c1"&gt;// for more information about preprocessors&lt;/span&gt;
&lt;span class="na"&gt;preprocess&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;preprocess&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;

  &lt;span class="na"&gt;kit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;adapter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;adapter&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="na"&gt;vite&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// vite config stuff&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;config&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;package.json&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"dev"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"svelte-kit dev"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"svelte-kit build"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"preview"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"svelte-kit preview"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Vite The New Way
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// vite.config.js&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;sveltekit&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;@sveltejs/kit/experimental/vite&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="nx"&gt;sveltekit&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;package.json&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"dev"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"vite dev"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"vite build"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"preview"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"vite preview"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Migrating Changes
&lt;/h2&gt;

&lt;p&gt;With big change always comes a lot of frustration for users. The maintainers of SvelteKit took this in mind and created an entire &lt;a href="https://github.com/sveltejs/kit/discussions/5774"&gt;migration guide&lt;/a&gt; and a command, &lt;code&gt;npx svelte-migrate routes&lt;/code&gt;, that attempts to make a lot of the changes for you. The script will rename the files inside the routes directory, comments out anything in a context module script tag, and throws errors to tell you to update to the &lt;code&gt;data&lt;/code&gt; prop. However, no tool can take care of everything and there &lt;strong&gt;will&lt;/strong&gt; still be manual changes that need to updated.  Depending on how long it’s been since you’ve upgraded, you may have several things to change. Here are the overview steps to follow.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Remove old lock files and node_modules.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;-rf&lt;/span&gt; node_modules package-lock.json &lt;span class="c"&gt;# or yarn-lock or pnpm-lock&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Update dependencies through your package manager.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i &lt;span class="c"&gt;# or yarn or pnpm&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run the migration command. The routes will be renamed and placed in the new directory structure and endpoint files will attempt to move to the appropriate type.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx svelte-migrate routes
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Update any props in &lt;code&gt;+page.svelte&lt;/code&gt; files to &lt;code&gt;data&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;propName&lt;/span&gt;
&lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Remove any &lt;code&gt;&amp;lt;script context="module"&amp;gt;&lt;/code&gt; stuff over to an endpoint file.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// in a +page.js or +page.server.js endpoint&lt;/span&gt;
&lt;span class="c1"&gt;// copy over your load function from the .svelte file&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;load&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;propName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;arbitrary data&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// remove the props object &lt;/span&gt;
      &lt;span class="nx"&gt;propName&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;/li&gt;
&lt;li&gt;
&lt;p&gt;Make sure your scripts have been updated to the Vite CLI in the &lt;code&gt;package.json&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;package.json&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"dev"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"vite dev"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"vite build"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"preview"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"vite preview"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Try to run it!&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;npm&lt;/span&gt; &lt;span class="nx"&gt;run&lt;/span&gt; &lt;span class="nx"&gt;dev&lt;/span&gt; &lt;span class="err"&gt;#&lt;/span&gt; &lt;span class="nx"&gt;or&lt;/span&gt; &lt;span class="nx"&gt;yarn&lt;/span&gt; &lt;span class="nx"&gt;or&lt;/span&gt; &lt;span class="nx"&gt;pnpm&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

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

&lt;p&gt;These steps are just a general overview of the biggest changes. Depending on when you last upgraded, there may be other steps to follow. SvelteKit errors are pretty good and may help walk you through any other changes you need to make. There may also be unique situations in your app that will need more work. With the addition of the &lt;code&gt;+page.server.js&lt;/code&gt; file, ensure you are loading your data where you need it. This will hopefully get you most of the way there.&lt;/p&gt;

&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;p&gt;To find out more information about the migration, check out the migration guide and you can always view the most recent updates in the SvelteKit Docs.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/sveltejs/kit/discussions/5774"&gt;Migration Guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kit.svelte.dev/docs/introduction"&gt;SvelteKit Docs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Moving Forward
&lt;/h2&gt;

&lt;p&gt;With so many changes lately in SvelteKit, a lot of us are hoping to see the light at the end of the tunnel soon. Let’s hope these rapid changes mean we are getting close to 1.0. Hopefully this post helped bridge the gap to the latest changes. Go forth and migrate!&lt;/p&gt;

&lt;h3&gt;
  
  
  Other Resources
&lt;/h3&gt;

&lt;p&gt;Here are a few extra resources to continue getting up to date with everything in SvelteKit.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://svelte.dev/blog/whats-new-in-svelte-august-2022"&gt;Newsletter August Updates in Svelte&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://kit.svelte.dev/docs/project-structure"&gt;Project Structure&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://kit.svelte.dev/docs/project-structure"&gt;Routing Changes Discussion&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/sveltejs/kit/pull/6174"&gt;Layout Changes Discussion&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A few podcasts have been talking about the recent changes. If you prefer listening to reading check out these Svelte Radio and SyntaxFM episodes.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Svelte Radio - &lt;a href="https://www.svelteradio.com/episodes/sveltekit-is-changing-fast"&gt;SvelteKit is changing Fast&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Svelte Radio - &lt;a href="https://www.svelteradio.com/episodes/lets-talk-routing-with-rich-harris"&gt;Let’s talk about Routing with Rich Harris&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;SyntaxFM - &lt;a href="https://syntax.fm/show/499/supper-club-rich-harris-author-of-svelte"&gt;Supper Club x Rich Harris, Author of Svelte&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>svelte</category>
      <category>sveltekit</category>
    </item>
    <item>
      <title>Easy HTML Forms in SvelteKit with Netlify Forms</title>
      <dc:creator>Brittney Postma</dc:creator>
      <pubDate>Wed, 10 Aug 2022 11:43:21 +0000</pubDate>
      <link>https://dev.to/brittneypostma/easy-html-forms-in-sveltekit-with-netlify-forms-1m21</link>
      <guid>https://dev.to/brittneypostma/easy-html-forms-in-sveltekit-with-netlify-forms-1m21</guid>
      <description>&lt;p&gt;Forms are a necessary evil in web development. We may not want to deal with them, but sometimes we have to. Netlify makes this easy with &lt;a href="https://www.netlify.com/products/forms/"&gt;built-in form handling&lt;/a&gt;. This is done at build time by parsing static html files, with no extra API calls or server-side logic needed. These are standard &lt;strong&gt;&lt;a href="https://docs.netlify.com/forms/setup/#html-forms"&gt;HTML forms&lt;/a&gt;&lt;/strong&gt; with a data attribute for Netlify’s bots to detect it. We can utilize this great feature in new meta-frameworks like SvelteKit too by creating a prerendered route and using the HTML form. Let’s go through the steps to get your own Netlify form setup on SvelteKit.&lt;/p&gt;

&lt;p&gt;| Updated for latest SvelteKit changes as of 8/22/22&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up SvelteKit
&lt;/h2&gt;

&lt;p&gt;To start up a new SvelteKit project, run &lt;code&gt;npm init svelte@next your-site-name&lt;/code&gt; in a terminal where you want the directory to live. It’s important to mention that at the time of writing, SvelteKit is still in beta, meaning some things will probably change. The &lt;code&gt;@next&lt;/code&gt; will be dropped when it hits an official 1.0. This command will prompt a command line interface, CLI, asking what things you want setup in your project. Step through the CLI, setting up your project with the Skeleton application. Once you hit enter on the last prompt, your new SvelteKit app is created and it prints a list of next steps.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;cd your-site-name&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;npm install&lt;/code&gt; (or pnpm, or yarn, etc)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git init &amp;amp;&amp;amp; git add -A &amp;amp;&amp;amp; git commit -m "Initial commit"&lt;/code&gt; (optional)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;npm run dev -- --open&lt;/code&gt; (or your package manager of choice)&lt;/li&gt;
&lt;li&gt;To close the dev server, hit &lt;code&gt;Ctrl+C&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Netlify Adapter
&lt;/h2&gt;

&lt;p&gt;SvelteKit uses the concept of adapters to &lt;em&gt;adapt&lt;/em&gt; the application to the platform you are deploying to. For Netlify, we can use the &lt;code&gt;adapter-static&lt;/code&gt; or &lt;code&gt;adapter-netlify&lt;/code&gt;. The static adapter will prerender your entire site. The Netlify adapter gives you more flexibility by allowing you to decide how to render each route, including &lt;a href="https://www.netlify.com/blog/sveltekit-with-netlify-edge-functions/"&gt;putting them on the *edge&lt;/a&gt;.* For this demo, we’ll be using the &lt;code&gt;adapter-netlify&lt;/code&gt;. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Install the adapter.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i &lt;span class="nt"&gt;-D&lt;/span&gt; @sveltejs/adapter-netlify
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Open up the &lt;code&gt;svelte.config.js&lt;/code&gt; file and edit the adapter import.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;adapter&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;@sveltejs/adapter-auto&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;adapter&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;@sveltejs/adapter-netlify&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

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

&lt;h3&gt;
  
  
  Netlify TOML files
&lt;/h3&gt;

&lt;p&gt;Netlify uses a &lt;code&gt;netlify.toml&lt;/code&gt; file to hold information about build, dev, and function configuration and setup. Create a &lt;code&gt;netlify.toml&lt;/code&gt; file at the root of your SvelteKit site. Inside add the following build configurations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="nn"&gt;[build]&lt;/span&gt;
    &lt;span class="py"&gt;command&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"npm run build"&lt;/span&gt;
    &lt;span class="py"&gt;publish&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"build/"&lt;/span&gt;
    &lt;span class="py"&gt;functions&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"functions/"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In SvelteKit, the &lt;code&gt;routes&lt;/code&gt; directory is where the pages of your site live. A route file is created by adding a folder and prefixing the file with a &lt;code&gt;+&lt;/code&gt;. The types of route files can be a &lt;code&gt;+page.svelte&lt;/code&gt; and either a &lt;code&gt;+page.server.js&lt;/code&gt; or a &lt;code&gt;+page.js&lt;/code&gt; endpoint. The &lt;code&gt;+page.svelte&lt;/code&gt; file is for the markup and the other files load the data into it and tell the page how to behave. The &lt;code&gt;+page.server.js&lt;/code&gt; will only run on the server while the &lt;code&gt;+page.js&lt;/code&gt; will run on the server and hydrate on the client. If you chose the skeleton project from the CLI, you will only have a &lt;code&gt;+page.svelte&lt;/code&gt; file inside the routes directory as the &lt;code&gt;/&lt;/code&gt; route. We'll create a &lt;code&gt;+page.js&lt;/code&gt; file beside it to prerender the home route. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PQMZj3ml--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/f84c4ed6125e35a3c49baac76047bb37c102abaf-426x190.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PQMZj3ml--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/f84c4ed6125e35a3c49baac76047bb37c102abaf-426x190.png%3Fw%3D450" alt="folder structure with +page.svelte and +page.js inside the route directory" width="450" height="201"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;prerender&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now over in the &lt;code&gt;+page.svelte&lt;/code&gt; file we can add the markup for the Netlify form.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"netlify-form-example"&lt;/span&gt; &lt;span class="na"&gt;method=&lt;/span&gt;&lt;span class="s"&gt;"POST"&lt;/span&gt; &lt;span class="na"&gt;netlify-honeypot=&lt;/span&gt;&lt;span class="s"&gt;"bot-field"&lt;/span&gt; &lt;span class="na"&gt;data-netlify=&lt;/span&gt;&lt;span class="s"&gt;"true"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"hidden"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"form-name"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"netlify-form-example"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"name"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Name&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"name"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"name"&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt; &lt;span class="na"&gt;placeholder=&lt;/span&gt;&lt;span class="s"&gt;"Name"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"email"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Email&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"email"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"email"&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt; &lt;span class="na"&gt;placeholder=&lt;/span&gt;&lt;span class="s"&gt;"Email"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"email"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"message"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Message&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"message"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"message"&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt; &lt;span class="na"&gt;placeholder=&lt;/span&gt;&lt;span class="s"&gt;"Message"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"Submit"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is a lot to take in here, so let’s look at it line by line.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;The form element has several attributes on it, name, method, netlify-honeypot, and data-netlify.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"netlify-form-example"&lt;/span&gt; &lt;span class="na"&gt;method=&lt;/span&gt;&lt;span class="s"&gt;"POST"&lt;/span&gt; &lt;span class="na"&gt;netlify-honeypot=&lt;/span&gt;&lt;span class="s"&gt;"bot-field"&lt;/span&gt; &lt;span class="na"&gt;data-netlify=&lt;/span&gt;&lt;span class="s"&gt;"true"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;ol&gt;
&lt;li&gt;The name can be whatever you want to call your form and will be what you see in your Netlify dashboard once the form is deployed. &lt;/li&gt;
&lt;li&gt;The method must be &lt;code&gt;"POST"&lt;/code&gt; to allow it to post to Netlify’s servers.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;netlify-honeypot&lt;/code&gt; attribute is optional, but will attempt to catch bots and filter them out.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;data-netlify="true"&lt;/code&gt; is the secret sauce. This is what Netlify’s bots will look for when crawling the static output of your site.&lt;/li&gt;
&lt;/ol&gt;


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

&lt;p&gt;The hidden input element is the other piece of magic for Netlify to detect the form correctly&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"hidden"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"form-name"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"netlify-form-example"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;



&lt;ol&gt;
&lt;li&gt;The &lt;code&gt;type="hidden"&lt;/code&gt; attribute ensures it isn’t seen by visual users or screen readers.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;name="form-name"&lt;/code&gt; must be kept as is. Do &lt;strong&gt;NOT&lt;/strong&gt; change the name to your actual form name.&lt;/li&gt;
&lt;li&gt;The value attribute is where you match the name of your form up to the input. Whatever value you set the form name attribute to is what should be set to value in the hidden input field.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;All the other inputs in the form are any valid HTML inputs that you would use in a regular form to get data from your user.&lt;/p&gt;


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

&lt;h2&gt;
  
  
  Deploy to Netlify
&lt;/h2&gt;

&lt;p&gt;Now that the form is setup and is ready to be deployed to Netlify, we can finish the steps to deploy the site. If you are not already a Netlify user, go ahead and &lt;a href="https://app.netlify.com/signup"&gt;sign up for free&lt;/a&gt;. &lt;/p&gt;

&lt;h3&gt;
  
  
  Git Setup
&lt;/h3&gt;

&lt;p&gt;If you didn’t setup the &lt;code&gt;git init&lt;/code&gt; in the SvelteKit setup, now is the time to put your site on your favorite git provider.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git init &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; git add &lt;span class="nt"&gt;-A&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Initial commit"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Create a repository, either using the CLI or by going directly to github.com. Link the new repository to your local site by copying the URL.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QvFzSNfY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/ed69d489227e342a785683e1efed515bcee5aa8b-386x372.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QvFzSNfY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/ed69d489227e342a785683e1efed515bcee5aa8b-386x372.png%3Fw%3D450" alt="Arrow pointing to copy button on repository url" width="450" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Run the command to add the remote origin pasting your URL at the end.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git remote add origin https://github.com/brittneypostma/sveltekit-netlify-forms
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Push your code to GitHub using the current branch, which is typically &lt;code&gt;main&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git push origin main
&lt;/code&gt;&lt;/pre&gt;

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

&lt;h3&gt;
  
  
  Link to Netlify
&lt;/h3&gt;

&lt;p&gt;Now that the site is on a git provider, head to your &lt;a href="https://app.netlify.com/"&gt;Netlify dashboard&lt;/a&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click on the &lt;strong&gt;Add new site&lt;/strong&gt; button that drops down and click on &lt;strong&gt;Import an existing project&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BfDRHFSc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/2f9f6cf5c2ab102b78df20c42c5043386fd51ff0-434x356.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BfDRHFSc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/2f9f6cf5c2ab102b78df20c42c5043386fd51ff0-434x356.png%3Fw%3D450" alt="Add new site button clicked pointing to Import an existing project." width="450" height="369"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Choose your Git provider.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5nl9AhMQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/22fa5c88c619f2902f685e7ff5828586cae3bdc7-1400x976.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5nl9AhMQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/22fa5c88c619f2902f685e7ff5828586cae3bdc7-1400x976.png%3Fw%3D450" alt="Import an existing project from a Git repository. Connect to Git provider" width="450" height="314"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use the search box to find your repo.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TuidtfF2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/42406bdff724ebf5551c2276a6a3bab55dca1b26-726x300.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TuidtfF2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/42406bdff724ebf5551c2276a6a3bab55dca1b26-726x300.png%3Fw%3D450" alt="Pick a repository from GitHub - sveltekit-netlify-forms searched" width="450" height="186"&gt;&lt;/a&gt;    &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Since we set up a &lt;code&gt;netlify.toml&lt;/code&gt; earlier, the build settings should populate automatically. So just click the &lt;strong&gt;Deploy site&lt;/strong&gt; button and Netlify’s robots will start building your site.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Checking the form
&lt;/h2&gt;

&lt;p&gt;Once the site is deployed, head to your site URL. Fill in the form and click the &lt;strong&gt;Submit&lt;/strong&gt; button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LEh9peyH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/015ad9bf6b0a8c16d8e028f6595f30aeae76f1aa-393x248.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LEh9peyH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/015ad9bf6b0a8c16d8e028f6595f30aeae76f1aa-393x248.png%3Fw%3D450" alt="Info filled into a form" width="450" height="284"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When the form is submitted successfully, you will be redirected to a Netlify page that says your form submission has been received.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--78l3NAb0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/95266230cee5ec651cea14cffb75082a1d26c397-706x329.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--78l3NAb0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/95266230cee5ec651cea14cffb75082a1d26c397-706x329.png%3Fw%3D450" alt="Thank you! Your form submission has been received. Back to our site." width="450" height="210"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Back in your &lt;a href="https://app.netlify.com/"&gt;Netlify dashboard&lt;/a&gt;, click on the &lt;strong&gt;Forms&lt;/strong&gt; tab,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9znKy-RS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/8851990b24af4fd370a994a8b76a2c1ca6945b40-686x292.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9znKy-RS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/8851990b24af4fd370a994a8b76a2c1ca6945b40-686x292.png%3Fw%3D450" alt="Forms tab in Netlify - 1 form collecting data" width="450" height="192"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Down below the forms section will be a list of active forms with the names you set in your HTML.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XAg3vzwY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/e6b84e98a1037871828b88ee3e269c61e5ff5902-1203x250.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XAg3vzwY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/e6b84e98a1037871828b88ee3e269c61e5ff5902-1203x250.png%3Fw%3D450" alt="Active forms - netlify-form-example" width="450" height="94"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click into the form to see your submission.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ucrn2uhp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/f41ce97422aae228549373951c59c8af82df6174-507x521.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ucrn2uhp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/f41ce97422aae228549373951c59c8af82df6174-507x521.png%3Fw%3D450" alt="Submissions from netlify-form-example with a Verified submission listed" width="450" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And that is it, no backend logic or complicated API calls, just straightforward form management with a pure HTML form. Happy form making!&lt;/p&gt;

</description>
      <category>forms</category>
      <category>html</category>
      <category>javascript</category>
      <category>svelte</category>
    </item>
    <item>
      <title>How to Use Tailwind CSS with Remix</title>
      <dc:creator>Brittney Postma</dc:creator>
      <pubDate>Tue, 09 Aug 2022 22:57:52 +0000</pubDate>
      <link>https://dev.to/brittneypostma/how-to-use-tailwind-css-with-remix-2k63</link>
      <guid>https://dev.to/brittneypostma/how-to-use-tailwind-css-with-remix-2k63</guid>
      <description>&lt;p&gt;Tailwind CSS has become a very popular option for styling applications. It uses atomic utility classes that are preconfigured with good defaults to get started easily. Remix is a JavaScript framework that aims to make creating a production ready application easier than ever. It uses React for the UI layer. Using &lt;a href="//remix.run"&gt;Remix&lt;/a&gt; and &lt;a href="https://tailwindcss.com/"&gt;Tailwind CSS&lt;/a&gt; together is a really powerful option to get your applications built quickly. To get started with Tailwind CSS in a fresh Remix application, we’ll run the following commands to create the Remix app or skip directly to the Tailwind setup.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up Remix
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Run the command to start the CLI.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx create-remix@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Name your project and select “Just the basics”.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0WC9re8s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/9312748b62fb3e4214a558bea0cd08a5e534095c-1134x118.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0WC9re8s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/9312748b62fb3e4214a558bea0cd08a5e534095c-1134x118.png%3Fw%3D450" alt="Where would you like to create your app? rad-remix-app What type of app do you want to create? Just the basics." width="450" height="47"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Select Netlify from the list of deployment targets.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RWM4Kch6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/01ccb94a159ac07607f0123498fd854b57ae1d9f-1396x528.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RWM4Kch6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/01ccb94a159ac07607f0123498fd854b57ae1d9f-1396x528.png%3Fw%3D450" alt="Where do you want to deploy? A list of deploy targets, Netlify is highlighted" width="450" height="170"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use either TypeScript or JavaScript, it’s your choice.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gDpppnAz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/fe004289a4c06c91c8df6f222b228ead81615a57-860x178.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gDpppnAz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/fe004289a4c06c91c8df6f222b228ead81615a57-860x178.png%3Fw%3D450" alt="TypeScript of JavaScript? TypeScript is highlighted." width="450" height="93"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Run &lt;code&gt;npm install&lt;/code&gt; by hitting Y.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gbnqlz-5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/50491be6c0194c4e223bc13a17d6ba13b17ae967-928x70.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gbnqlz-5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/50491be6c0194c4e223bc13a17d6ba13b17ae967-928x70.png%3Fw%3D450" alt="Do you want me to run  raw `npm install` endraw ? (Y/n) Y" width="450" height="34"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Now your Remix project is set up. You can open it in your favorite code editor and start setting up Tailwind CSS.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Setting up Tailwind CSS
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Install the required packages for Tailwind.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-D&lt;/span&gt; tailwindcss postcss autoprefixer concurrently
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run the command to initialize Tailwind, this will generate a &lt;code&gt;tailwind.config.js&lt;/code&gt; file in the root of your project.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx tailwindcss init
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Open the newly created &lt;code&gt;tailwind.config.js&lt;/code&gt; file and add the file paths to the content section.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// tailwind.config.js&lt;/span&gt;
&lt;span class="cm"&gt;/** @type {import('tailwindcss').Config} */&lt;/span&gt; 
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./app/**/*.{js,ts,jsx,tsx}&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;extend&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;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Replace the scripts in the &lt;code&gt;package.json&lt;/code&gt; with the new Tailwind scripts. These add two scripts to generate the Tailwind CSS files and updates the &lt;code&gt;build&lt;/code&gt; and &lt;code&gt;dev&lt;/code&gt; scripts to use the new CSS scripts. The path to the CSS files can be configured as needed, but by default it puts the initial file in the root &lt;code&gt;styles/app.css&lt;/code&gt; file and the generated output goes to &lt;code&gt;app/styles/app.css&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;package.json&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npm run build:css &amp;amp;&amp;amp; remix build"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"build:css"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tailwindcss -m -i ./styles/app.css -o app/styles/app.css"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"dev"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"concurrently &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;npm run dev:css&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;remix dev&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"dev:css"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tailwindcss -w -i ./styles/app.css -o app/styles/app.css"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Where you set the path of your CSS to or the default location &lt;code&gt;styles/app.css&lt;/code&gt;, create the initial location for the CSS. From the root of your project, run the following commands.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;styles
&lt;span class="nb"&gt;touch &lt;/span&gt;styles/app.css
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add the &lt;code&gt;@tailwind&lt;/code&gt; directives to the newly created &lt;code&gt;app.css&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;components&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;utilities&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run &lt;code&gt;npm run dev&lt;/code&gt; to generate the output CSS file in &lt;code&gt;app/styles/app.css&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Import the generated CSS file into the &lt;code&gt;app/root.tsx&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;styles&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;./styles/app.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;links&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt; &lt;span class="na"&gt;rel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;stylesheet&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;href&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;styles&lt;/span&gt; &lt;span class="p"&gt;}]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;blockquote&gt;
&lt;p&gt;One thing I ran into that I wanted to note here. Make sure your Remix app includes the &lt;code&gt;&amp;lt;Links /&amp;gt;&lt;/code&gt; component from &lt;code&gt;@remix-run/react&lt;/code&gt; inside your &lt;code&gt;app/root.tsx&lt;/code&gt; file or the links will not be added.&lt;/p&gt;


&lt;/blockquote&gt;
&lt;pre class="highlight jsx"&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;Links&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;@remix-run/react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;styles&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;./styles/app.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="cm"&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;function&lt;/span&gt; &lt;span class="nx"&gt;links&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt; &lt;span class="na"&gt;rel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;stylesheet&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;href&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;styles&lt;/span&gt; &lt;span class="p"&gt;}]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* ... */&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;Root&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;html&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;head&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;Links&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="cm"&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;head&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="cm"&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;html&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;/li&gt;
&lt;li&gt;
&lt;p&gt;Now you are setup to start using Tailwind classes inside of your components. Try it in the &lt;code&gt;app/routes/index.tsx&lt;/code&gt; file. Remove the inline style from the wrapper &lt;code&gt;div&lt;/code&gt; element and add in the Tailwind classes, &lt;code&gt;className="font-sans leading-5 m-4"&lt;/code&gt;. And give the &lt;code&gt;h1&lt;/code&gt; some styles, &lt;code&gt;className="text-3xl font-bold text-teal-600"&lt;/code&gt;. Make sure your dev server is running, &lt;code&gt;npm run dev&lt;/code&gt;, and open &lt;a href="http://localhost:3000/"&gt;localhost://3000&lt;/a&gt; to see your Tailwind styles applied.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;Index&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"font-sans leading-5 m-4"&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="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"text-3xl font-bold text-teal-600"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Welcome to Remix&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="nt"&gt;ul&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;li&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;a&lt;/span&gt;
            &lt;span class="na"&gt;target&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"_blank"&lt;/span&gt;
            &lt;span class="na"&gt;href&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"https://remix.run/tutorials/blog"&lt;/span&gt;
            &lt;span class="na"&gt;rel&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"noreferrer"&lt;/span&gt;
          &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            15m Quickstart Blog Tutorial
          &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;a&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;li&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;li&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;a&lt;/span&gt;
            &lt;span class="na"&gt;target&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"_blank"&lt;/span&gt;
            &lt;span class="na"&gt;href&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"https://remix.run/tutorials/jokes"&lt;/span&gt;
            &lt;span class="na"&gt;rel&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"noreferrer"&lt;/span&gt;
          &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            Deep Dive Jokes App Tutorial
          &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;a&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;li&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;li&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;a&lt;/span&gt; &lt;span class="na"&gt;target&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"_blank"&lt;/span&gt; &lt;span class="na"&gt;href&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"https://remix.run/docs"&lt;/span&gt; &lt;span class="na"&gt;rel&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"noreferrer"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            Remix Docs
          &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;a&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;li&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;ul&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

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

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JclSFU29--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/588aff48eacf8d9d9400b99b4601e9ce0208a96e-576x246.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JclSFU29--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/588aff48eacf8d9d9400b99b4601e9ce0208a96e-576x246.png%3Fw%3D450" alt="what is shown on the webpage of a starter remix app with the h1 Welcome to Remix styled with Tailwind CSS" width="450" height="192"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  K-Pop Stack
&lt;/h2&gt;

&lt;p&gt;Another option with Tailwind CSS already preconfigured is the &lt;a href="https://www.netlify.com/blog/deploy-your-remix-supabase-app-today/"&gt;K-Pop Stack&lt;/a&gt;. Netlify's templates team has created this stack that is already configured with Tailwind and it uses Supabase for the database. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://kpop-stack.netlify.app/"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mgdddCU3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.sanity.io/images/o0o2tn5x/production/6bef9bba58f6357a13e094b1bcb20e876e595dc2-2952x1734.png%3Fw%3D450" alt="Netlify's K-Pop Stack Homepage built with Remix, Supabase, and Tailwind CSS" width="450" height="264"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>tailwindcss</category>
      <category>remix</category>
      <category>css</category>
    </item>
    <item>
      <title>Intro to Serverless Functions</title>
      <dc:creator>Brittney Postma</dc:creator>
      <pubDate>Mon, 25 Jul 2022 12:30:53 +0000</pubDate>
      <link>https://dev.to/brittneypostma/intro-to-serverless-functions-4nko</link>
      <guid>https://dev.to/brittneypostma/intro-to-serverless-functions-4nko</guid>
      <description>&lt;p&gt;Serverless is a term we hear a lot in this industry, but what does serverless really mean? Serverless doesn’t really mean you don’t have servers, it’s more like servers as a service. Instead of owning and maintaining your own servers, you let a service do the work for you. You can focus on the business needs and developing a better quality application instead of worrying about the infrastructure and maintenance of a traditional server.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Serverless functions give developers superpowers and enables them to do things that would not otherwise have been possible. —Jason Lengstorf&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Serverless Functions on Netlify
&lt;/h2&gt;

&lt;p&gt;Serverless functions, branded as &lt;a href="https://www.netlify.com/products/functions" rel="noopener noreferrer"&gt;Netlify Functions&lt;/a&gt; when running on Netlify, are a way to deploy server-side code as API endpoints. These will spin up automatically when triggered by an event, handle and process server ran code, and then spin down until the next event. Using Netlify for your serverless functions creates a seamless workflow that allows you to write and test your functions locally with the &lt;a href="https://www.netlify.com/products/cli/" rel="noopener noreferrer"&gt;Netlify CLI&lt;/a&gt;, build and deploy your applications, and avoid the setup, cost, and maintenance of a physical server.&lt;/p&gt;

&lt;p&gt;On Netlify, there are several options when it comes to using serverless functions. This post is going to focus on traditional serverless functions, but you may also want to explore &lt;a href="https://www.netlify.com/blog/2021/01/07/what-are-background-functions/" rel="noopener noreferrer"&gt;background functions&lt;/a&gt; or the new &lt;a href="https://www.netlify.com/blog/edge-functions-explained/" rel="noopener noreferrer"&gt;edge functions&lt;/a&gt; that can be distributed closer to your users.&lt;/p&gt;

&lt;h3&gt;
  
  
  Traditional Serverless Functions
&lt;/h3&gt;

&lt;p&gt;What’s thought of as a traditional serverless function, is a short running synchronous function written in JavaScript, TypeScript, or Go that is hosted as an endpoint. It performs some server side code and then returns a response to the client immediately. These are AWS Lambda functions with a default region of &lt;code&gt;us-east-1&lt;/code&gt;. They have a 10 second time limit and a memory limit of 1024 megabytes. &lt;/p&gt;

&lt;p&gt;Everything that we do in technology has a tradeoff, there are pros and cons no matter what it is. Let’s look at both for serverless functions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pros
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;lowers barrier to entry for devs&lt;/li&gt;
&lt;li&gt;inexpensive&lt;/li&gt;
&lt;li&gt;faster iteration&lt;/li&gt;
&lt;li&gt;quick deployments&lt;/li&gt;
&lt;li&gt;abstracts away the setup and maintenance of a physical server&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Cons
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;not built for long running processes (10 sec limit)&lt;/li&gt;
&lt;li&gt;stateless - does not maintain data&lt;/li&gt;
&lt;li&gt;cold starts - referring to the time it takes to start up when a function is invoked or ephemeral containers&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;Now we are going to walk through the steps to get a serverless function up and running on Netlify. To get started with this project, having some understanding of HTML, JavaScript, the command line, npm, and git will be helpful. Also, if you don’t already have a Netlify account, you can &lt;a href="https://app.netlify.com/signup" rel="noopener noreferrer"&gt;sign up for free here&lt;/a&gt;. &lt;/p&gt;

&lt;h3&gt;
  
  
  Project Setup
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Open the &lt;strong&gt;&lt;a href="https://github.com/netlify/explorers-up-and-running-with-serverless-functions" rel="noopener noreferrer"&gt;explorers up and running with serverless functions repository on Netlify’s GitHub&lt;/a&gt;&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;Use this template&lt;/strong&gt; button in order to create this repo inside of your own account.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F6c938686e66266a03a6c44f6861652c946494128-2570x970.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F6c938686e66266a03a6c44f6861652c946494128-2570x970.png%3Fw%3D450" alt="Explorers up and running with serverless functions GitHub repo - Use this template button"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Give your cloned repo a name and click the &lt;strong&gt;Create repository from template&lt;/strong&gt; button.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F6a2eb6d9900334f1a176eca52e08ec91f35804b7-1770x1428.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F6a2eb6d9900334f1a176eca52e08ec91f35804b7-1770x1428.png%3Fw%3D450" alt="Create repository from template button"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Once you have created the new repository, click the &lt;strong&gt;Code&lt;/strong&gt; button and copy the link to clone the repository.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F3cdfa9f8af774c845a8737c3640f712841173d04-2234x1078.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F3cdfa9f8af774c845a8737c3640f712841173d04-2234x1078.png%3Fw%3D450" alt="Copy button to grab repo url to clone"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Setting up the Project Locally
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Open up a terminal to the location you want the project to be placed at, then run the &lt;code&gt;git clone&lt;/code&gt; command and paste your link that you copied in the last step.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/brittneypostma/new-cloned-serverless-functions-repo
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You can change directory with &lt;code&gt;cd&lt;/code&gt; into your new project folder directly from the terminal or open your folder in your favorite code editor.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;new-cloned-serverless-functions-repo
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Currently there is only a &lt;code&gt;[README.md](http://README.md)&lt;/code&gt; and &lt;code&gt;.gitignore&lt;/code&gt; file and a &lt;code&gt;public&lt;/code&gt; folder inside.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Netlify CLI
&lt;/h3&gt;

&lt;p&gt;Now that you have the project cloned and up setup locally, we need to install the packages needed to run the serverless functions locally. First, make sure you have &lt;a href="https://nodejs.org/en/" rel="noopener noreferrer"&gt;Node.js&lt;/a&gt; installed on your machine. You can check if you have it and what version by running &lt;code&gt;npm --version&lt;/code&gt;. Now, we need to install the Netlify Command Line Interface, or CLI. Run the following command in the terminal to install it globally on your machine.&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;netlify-cli &lt;span class="nt"&gt;--global&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can either use the &lt;code&gt;netlify&lt;/code&gt; or the shorthand &lt;code&gt;ntl&lt;/code&gt; to run cli commands. I’ll be using the shorthand versions for the remainder of the tutorial. Check the version you are running of the cli with &lt;code&gt;ntl --version&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you don’t already have a Netlify account, you can &lt;a href="https://app.netlify.com/signup" rel="noopener noreferrer"&gt;sign up for free here&lt;/a&gt;. Then you can login with the CLI by running &lt;code&gt;ntl login&lt;/code&gt; and authorize the application.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2Fe9725fdf09d55d495e3cb6edaae763ebf61147d5-1085x322.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2Fe9725fdf09d55d495e3cb6edaae763ebf61147d5-1085x322.png%3Fw%3D450" alt="Authorize Application for Netlify CLI"&gt;&lt;/a&gt;&lt;br&gt;
Now we need to initialize the application by running &lt;code&gt;ntl init&lt;/code&gt; and go through the steps to create a new site on Netlify.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Run &lt;code&gt;ntl init&lt;/code&gt; and select &lt;code&gt;Create &amp;amp; configure a new site.&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F26c31abef2bcf5919ebb75303ffdcdf1daafc6fe-1660x374.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F26c31abef2bcf5919ebb75303ffdcdf1daafc6fe-1660x374.png%3Fw%3D450" alt="Create and configure a new site"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Select the team you want to use.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F2bd693b55a9b8cbdc351f2f0a68bd5c8290af3f3-528x142.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F2bd693b55a9b8cbdc351f2f0a68bd5c8290af3f3-528x142.png%3Fw%3D450" alt="Team: Brittney Postma's team"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Name your site or leave it blank for a random name.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F1d8282cbc0c06f551b266797ebbaa99d5d775ed8-1428x86.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F1d8282cbc0c06f551b266797ebbaa99d5d775ed8-1428x86.png%3Fw%3D450" alt="site name (optional)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The site is now created. You should see your admin URL, the main URL, and the site id listed in the terminal.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F71fcc6bc21186a02ef4761adeb2a6ac4b78127f6-1762x308.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F71fcc6bc21186a02ef4761adeb2a6ac4b78127f6-1762x308.png%3Fw%3D450" alt="Site Created, list of URLs and site id"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The CLI will prompt us for the build command, leave this blank and the CLI will fill in &lt;code&gt;# no build command&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F2cfaef97e903f5ba5dc47031f2c6f333907c1619-1422x68.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F2cfaef97e903f5ba5dc47031f2c6f333907c1619-1422x68.png%3Fw%3D450" alt="Your build command (hugo build/yarn run build/etc): # no build command"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fill in the directory to deploy as the &lt;code&gt;public&lt;/code&gt; folder.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F501aee66078f05c853de6b70685224557dd18ed1-1068x72.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F501aee66078f05c853de6b70685224557dd18ed1-1068x72.png%3Fw%3D450" alt="Directory to deploy (blank for current)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In this step, leave the default &lt;code&gt;netlify/functions&lt;/code&gt; folder.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F130a6d6331b335df252b965600f331032ad435c4-914x72.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F130a6d6331b335df252b965600f331032ad435c4-914x72.png%3Fw%3D450" alt="Netlify functions folder: netlify/functions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;And since we haven’t created a &lt;code&gt;netlify.toml&lt;/code&gt; file yet, in this step, enter &lt;code&gt;Y&lt;/code&gt; to generate one with the settings you specified.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F4254a6a620df12f0f511e938c02febc9368b698c-1702x72.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F4254a6a620df12f0f511e938c02febc9368b698c-1702x72.png%3Fw%3D450" alt="No netlify.toml detected. Would you like to create one with these build settings? Y"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Once you see the Success! message, your site is ready to deploy. There are some next steps listed, &lt;code&gt;git push&lt;/code&gt; to trigger a deploy or run &lt;code&gt;ntl open&lt;/code&gt; to open your new site’s dashboard.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F501678863fd45603b970178f82b1f1480fb017d6-1718x466.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F501678863fd45603b970178f82b1f1480fb017d6-1718x466.png%3Fw%3D450" alt="Success! Netlify CI/CD Configurred! Next steps for deploying."&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Anatomy of a Serverless Function
&lt;/h2&gt;

&lt;p&gt;The basic anatomy of any serverless function has three basic parts. It must export a handler asynchronous function and then return an object with a &lt;code&gt;statusCode&lt;/code&gt; and &lt;code&gt;body&lt;/code&gt; property, which typically has a JSON object that needs to be converted to a string using the &lt;code&gt;JSON.stringify()&lt;/code&gt; method for the &lt;code&gt;message&lt;/code&gt; to be read.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handler&lt;/span&gt; &lt;span class="o"&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;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
            &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;This is what will be returned!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
        &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Project Overview
&lt;/h2&gt;

&lt;p&gt;Now that the project is set up locally and linked to a Netlify url, we can start looking through the project. &lt;/p&gt;

&lt;h3&gt;
  
  
  index.html
&lt;/h3&gt;

&lt;p&gt;Open up the directory you created in your favorite code editor and navigate inside the public directory to the &lt;code&gt;index.html&lt;/code&gt; file and open it up.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2Ff2a78f83fdbfe4556a97c0942f6be62891e01c64-606x328.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2Ff2a78f83fdbfe4556a97c0942f6be62891e01c64-606x328.png%3Fw%3D450" alt="new-cloned-serverless-functions-repo with list of files"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you look inside the &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; tag, you should see an &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; tag, a &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; with an &lt;code&gt;id="fetch-btn"&lt;/code&gt;, and a &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; placeholder for the response. In the &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag below, there is an event listener that listens for a click on the button and inserts the response into the placeholder area.&lt;/p&gt;

&lt;h3&gt;
  
  
  netlify.toml
&lt;/h3&gt;

&lt;p&gt;The next file to look at is the &lt;code&gt;netlify.toml&lt;/code&gt; file that we setup with the Netlify CLI. The build settings should be set up as follows.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;
&lt;span class="nn"&gt;[build]&lt;/span&gt;
    &lt;span class="py"&gt;command&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"# no build command"&lt;/span&gt;
    &lt;span class="py"&gt;functions&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"netlify/functions"&lt;/span&gt;
    &lt;span class="py"&gt;publish&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"public"&lt;/span&gt;

&lt;span class="nn"&gt;[functions]&lt;/span&gt;
        &lt;span class="py"&gt;node_bundler&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"esbuild"&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;The directory for the functions defined in the toml file hasn’t been created yet. At the root of your project, create a new folder named netlify and another folder inside it named functions. The new project structure should look like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F42a1a66c65f02e66b05740f418405ff5f6e64077-278x282.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F42a1a66c65f02e66b05740f418405ff5f6e64077-278x282.png%3Fw%3D450" alt="netlify.toml file highlighted in list of files"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating Your First Serverless Function
&lt;/h2&gt;

&lt;p&gt;Inside of the new &lt;code&gt;netlify/functions&lt;/code&gt; directory, create a new file &lt;code&gt;hello-world.js&lt;/code&gt;. Use the &lt;code&gt;export&lt;/code&gt; syntax and create an async function called &lt;code&gt;handler&lt;/code&gt;, that returns a &lt;code&gt;statusCode&lt;/code&gt; of 200 and a &lt;code&gt;body&lt;/code&gt; with the &lt;code&gt;message&lt;/code&gt; that is stringified with the &lt;code&gt;JSON.stringify&lt;/code&gt; method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handler&lt;/span&gt; &lt;span class="o"&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;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello World!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}),&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Fetching the Response
&lt;/h3&gt;

&lt;p&gt;Now, let’s configure the client side JavaScript we will use to fetch the response over in the &lt;code&gt;index.html&lt;/code&gt; file. In the &lt;code&gt;script&lt;/code&gt; tag below the markup, there is a &lt;code&gt;fetchBtn&lt;/code&gt; event listener set up to listen for a click on the button in the markup. Here we need to make the function &lt;code&gt;async&lt;/code&gt;, create a variable to fetch the serverless function endpoint, and return the response. One interesting thing to point out, is when we fetch the serverless function, we need to call it at the directory &lt;code&gt;.netlify&lt;/code&gt;, with a dot in front of it. This is to avoid name collisions with other APIs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;fetchBtn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&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;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/.netlify/functions/hello-world&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="nx"&gt;responseText&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the function is setup, we can run &lt;code&gt;ntl dev&lt;/code&gt; in the console to run the development server and test the function. Open up &lt;code&gt;[localhost:8888](http://localhost:8888)&lt;/code&gt; in the browser, open the developer console, and navigate to the network panel.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F760f24c5816436a0c13fc7edd521bfa742dd072e-1216x1218.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F760f24c5816436a0c13fc7edd521bfa742dd072e-1216x1218.png%3Fw%3D450" alt="Network panel showing in dev tools in Chrome browser with page running above"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you click on the fetch button, you will see the &lt;code&gt;hello-world&lt;/code&gt; call come into the network panel.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F2b6c79333856ef618bf5d74320081247c6080955-1290x700.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F2b6c79333856ef618bf5d74320081247c6080955-1290x700.png%3Fw%3D450" alt="Network request for hello-world"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see the &lt;code&gt;200&lt;/code&gt; status and if you click on the function and navigate to the Preview tab, you can see the object message of “Hello World!”.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F9f6c3cd393c54a2066e61b85c2d261ab5e658ef7-1022x690.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F9f6c3cd393c54a2066e61b85c2d261ab5e658ef7-1022x690.png%3Fw%3D450" alt="Preview panel with message: "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You may notice the text is printing &lt;code&gt;[object Object]&lt;/code&gt;, this is because we need to stringify the response in the &lt;code&gt;fetchBtn&lt;/code&gt; event listener function. Add the &lt;code&gt;JSON.stringify(response)&lt;/code&gt; method and save the file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;fetchBtn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&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;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/.netlify/functions/hello-world&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="nx"&gt;responseText&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you reload the site and click the Fetch button again, now the message will display correctly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2Fd93d4c2f5a4b81a13e228a2c20e3eabab20b682c-1206x282.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2Fd93d4c2f5a4b81a13e228a2c20e3eabab20b682c-1206x282.png%3Fw%3D450" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Calling an API from a Serverless Function
&lt;/h2&gt;

&lt;p&gt;External APIs can be integrated with a serverless function to grab data, that can then be used in the response. We are going to work with the &lt;a href="https://pokeapi.co/" rel="noopener noreferrer"&gt;Poke API&lt;/a&gt;, which allows you to get all kinds of information about the Pokémon world.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating a New Endpoint
&lt;/h3&gt;

&lt;p&gt;Back in the code editor, we need to create a new file in our &lt;code&gt;netlify/functions&lt;/code&gt; directory named &lt;code&gt;pokedex.js&lt;/code&gt; that will house our new endpoint. This time, create a constant for the &lt;code&gt;POKE_API&lt;/code&gt; url &lt;code&gt;https://pokeapi.co/api/v2/pokedex/kanto&lt;/code&gt;, await the fetch call to the url, and create a new constant, &lt;code&gt;data&lt;/code&gt;, and await the &lt;code&gt;response.json()&lt;/code&gt;. Next, we’ll return the &lt;code&gt;statusCode: 200,&lt;/code&gt; and stringify the data response in the body.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handler&lt;/span&gt; &lt;span class="o"&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;POKE_API&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://pokeapi.co/api/v2/pokedex/kanto&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;POKE_API&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;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="nx"&gt;data&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Fetch the Pokédex Endpoint
&lt;/h3&gt;

&lt;p&gt;Back in the &lt;code&gt;index.html&lt;/code&gt; file, first we will need to add a new button to fetch the &lt;code&gt;pokedex.js&lt;/code&gt; endpoint we just created. Add a new button to the markup, with the id &lt;code&gt;fetch-pokedex-btn&lt;/code&gt; and the text Fetch Pokedex.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"fetch-pokedex-btn"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Fetch Pokedex&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F1b7e99fcfed7f6b821b4a421b47e5938ec240f2e-1012x304.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F1b7e99fcfed7f6b821b4a421b47e5938ec240f2e-1012x304.png%3Fw%3D450" alt="button with id of fetch-pokedex-btn highlighted"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next in the &lt;code&gt;script&lt;/code&gt; tag, create a constant and add the element selector.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fetchPokedexBtn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fetch-pokedex-btn&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F803f2c2571adeada58336c8324116bb56ca80fc8-1304x262.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F803f2c2571adeada58336c8324116bb56ca80fc8-1304x262.png%3Fw%3D450" alt="fetchPokedexBtn variable line highlighted"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And finally, create a new event listener function for a click on the &lt;code&gt;fetch-pokedex-btn&lt;/code&gt; to add the stringified data to the &lt;code&gt;innerText&lt;/code&gt; of the variable set to the &lt;code&gt;p&lt;/code&gt; tag.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;fetchPokedexBtn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&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;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/.netlify/functions/pokedex&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;

  &lt;span class="nx"&gt;responseText&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&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;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2Fd51720150193c55eaa5e079aaf1a7965838fb863-1248x360.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2Fd51720150193c55eaa5e079aaf1a7965838fb863-1248x360.png%3Fw%3D450" alt="fetchPokedexBtn event listener highlighted"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this point, if you run the server with &lt;code&gt;ntl dev&lt;/code&gt;, you will see both of the buttons we created, but the Fetch Pokedex button will return an error. Checking the network panel and the terminal for the issue, we’ll see a 500 error and an &lt;code&gt;errorMessage: "fetch is not defined"&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F77ebfa9f3eb52a9841590e3802c472d4916e674b-1658x702.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F77ebfa9f3eb52a9841590e3802c472d4916e674b-1658x702.png%3Fw%3D450" alt="dev tools 500 error on the network panel"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F92d8ebaa27bcbde57cddbdb19eeb028cf4ecfdea-1596x176.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F92d8ebaa27bcbde57cddbdb19eeb028cf4ecfdea-1596x176.png%3Fw%3D450" alt="terminal error with errorMessage fetch is not defined."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This happens because the serverless function running at the &lt;code&gt;pokedex.js&lt;/code&gt; endpoint is on a &lt;a href="https://nodejs.org/en/" rel="noopener noreferrer"&gt;Node.JS&lt;/a&gt; server. Node does not have access to the native fetch API provided inside the browser. As a result, we need to install a dependency that will allow us to run fetch on a Node server. Shut down the server with &lt;code&gt;ctrl+C&lt;/code&gt; and follow the next steps to set up server-side fetch.&lt;/p&gt;

&lt;h3&gt;
  
  
  Initializing NPM
&lt;/h3&gt;

&lt;p&gt;To install packages inside of our application, we need to create initialize this as a &lt;code&gt;npm&lt;/code&gt; project. To do that, run &lt;code&gt;npm init&lt;/code&gt; in the root directory of your project. This will walk through steps to create a &lt;code&gt;package.json&lt;/code&gt; file. You can leave everything as default by hitting &lt;code&gt;Enter&lt;/code&gt; through each step or change anything by typing it in and then hitting &lt;code&gt;Enter&lt;/code&gt;. Once complete, it will ask you “Is this OK?” and you hit &lt;code&gt;Enter&lt;/code&gt; for yes or type no if you wish to start over.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F7b1c15af2848f830849cce674c6889eaa508bb45-1808x1162.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F7b1c15af2848f830849cce674c6889eaa508bb45-1808x1162.png%3Fw%3D450" alt="the npm init printout with Is this OK? (yes) at the bottom"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you say yes and hit &lt;code&gt;Enter&lt;/code&gt;, a new &lt;code&gt;package.json&lt;/code&gt; file will be created at the root of your project with the above information. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F431b28defebd89c15ed9bc4cb3433ec8ada04324-280x418.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F431b28defebd89c15ed9bc4cb3433ec8ada04324-280x418.png%3Fw%3D450" alt="package.json file highlighted in list of files"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This file is responsible for keeping track of any dependencies and some basic details of the project. &lt;/p&gt;

&lt;h3&gt;
  
  
  ESM Support in Node
&lt;/h3&gt;

&lt;p&gt;As of &lt;a href="https://nodejs.org/en/" rel="noopener noreferrer"&gt;Node.js&lt;/a&gt; version &lt;code&gt;17.0.0&lt;/code&gt;, ESM, or ECMAScript modules, support became available in any Node.js application. Some libraries, like the one we will be installing next, have made the ESM migration. While you can use libraries with or without ESM, you can’t pick and choose the syntax you use. You must completely convert your application to ESM or stick with the old syntax. The &lt;a href="https://explorers.netlify.com/learn/up-and-running-with-serverless-functions" rel="noopener noreferrer"&gt;original videos this tutorial is based on&lt;/a&gt; used the older syntax for the serverless functions. We have since updated the &lt;a href="https://github.com/netlify/explorers-up-and-running-with-serverless-functions" rel="noopener noreferrer"&gt;repo&lt;/a&gt; and this guide is using the newer ESM supported syntax. To convert over to ESM, add a &lt;code&gt;"type": "module"&lt;/code&gt; to the &lt;code&gt;package.json&lt;/code&gt; file and switch the &lt;code&gt;exports.handler = async function ()&lt;/code&gt; to &lt;code&gt;const handler = async () =&amp;gt;&lt;/code&gt;. If you have any imports using the &lt;code&gt;require()&lt;/code&gt; syntax, they will also need to be converted to &lt;code&gt;import name from 'package'&lt;/code&gt; syntax.&lt;/p&gt;

&lt;p&gt;Replace the CommonJS syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fetch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;node-fetch&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nx"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;handler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;function &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;with the ESM syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;fetch&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;node-fetch&lt;/span&gt;&lt;span class="dl"&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;handler&lt;/span&gt; &lt;span class="o"&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We also need to update the &lt;code&gt;netlify.toml&lt;/code&gt; file to tell Netlify to use &lt;code&gt;esbuild&lt;/code&gt; for the serverless functions when they are deployed. Add the setting &lt;code&gt;node_bundler = "esbuild"&lt;/code&gt; under &lt;code&gt;[functions]&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;functions&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="nx"&gt;node_bundler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;esbuild&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F2dee5b40cc86da947b322872f9c3caf96d26d0f4-594x320.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F2dee5b40cc86da947b322872f9c3caf96d26d0f4-594x320.png%3Fw%3D450" alt="toml file with functions setting"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Installing Packages
&lt;/h3&gt;

&lt;p&gt;Now that we have the &lt;code&gt;package.json&lt;/code&gt; file created, we can install a Node fetch library. In the terminal, run the command &lt;code&gt;npm install --save-dev node-fetch&lt;/code&gt;. Once it is completed, you will see a new &lt;code&gt;devDependencies&lt;/code&gt; property with the &lt;code&gt;node-fetch&lt;/code&gt; library in the &lt;code&gt;package.json&lt;/code&gt; file and a new &lt;code&gt;package-lock.json&lt;/code&gt; file created automatically. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2Fe8f11717d5cbdbf7891bc1335cc2adfea377584e-1388x274.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2Fe8f11717d5cbdbf7891bc1335cc2adfea377584e-1388x274.png%3Fw%3D450" alt="package.json showing node-fetch as a dev dependency"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Your version will probably look different than mine. If you run into any issues, try removing &lt;code&gt;node-fetch&lt;/code&gt; with the &lt;code&gt;npm rm node-fetch&lt;/code&gt; command and then install &lt;code&gt;npm install --save-dev node-fetch@3.2.8&lt;/code&gt; to install the save version.&lt;/p&gt;

&lt;h3&gt;
  
  
  Import Packages
&lt;/h3&gt;

&lt;p&gt;Head back to the &lt;code&gt;netlify/functions/pokedex.js&lt;/code&gt; file where we need to import and use the &lt;code&gt;node-fetch&lt;/code&gt; library we just installed. We’ll need to use the &lt;code&gt;import&lt;/code&gt; syntax, since version 3 and greater of the &lt;code&gt;node-fetch&lt;/code&gt; library uses ESM syntax. Add this line to the beginning of the file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;fetch&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;node-fetch
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Don’t forget, you also have to update the &lt;code&gt;package.json&lt;/code&gt; file with a &lt;code&gt;"type": "module"&lt;/code&gt; property if you didn’t already to tell it to use ESM as well.&lt;/p&gt;

&lt;p&gt;Now if you start the server again with &lt;code&gt;ntl dev&lt;/code&gt; and navigate to &lt;code&gt;[localhost:8888](http://localhost:8888)&lt;/code&gt; in the browser, you can see the function run successfully.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deploying Serverless Functions
&lt;/h2&gt;

&lt;p&gt;Earlier we setup and linked a site to Netlify with the Netlify CLI. Any time we make a &lt;em&gt;push&lt;/em&gt; to the git repository that is linked to the Netlify site, a deploy will automatically trigger. Let’s go ahead and run the commands to push our code and trigger a deploy.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Shut down your server, if it isn’t already, with &lt;code&gt;Ctrl+C&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Add all of the files with the &lt;code&gt;git add .&lt;/code&gt; command, I have 7 changes to commit. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2Ff159ca53b40e96fe446a52227655e215167a057e-444x418.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2Ff159ca53b40e96fe446a52227655e215167a057e-444x418.png%3Fw%3D450" alt="7 staged changes in files"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Commit the files with a message about what was changed.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;git&lt;/span&gt; &lt;span class="nx"&gt;commit&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;m&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Set up a Netlify site with 2 serverless functions.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Push the changes up to your git provider with &lt;code&gt;git push&lt;/code&gt; or &lt;code&gt;git push origin main&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That &lt;em&gt;push&lt;/em&gt; will have set off a deployment on &lt;a href="https://app.netlify.com" rel="noopener noreferrer"&gt;Netlify&lt;/a&gt;. You can run &lt;code&gt;ntl open&lt;/code&gt; to open the Netlify dashboard linked to your site. Once there, you can click directly on the &lt;a href="https://brittney-explorers-intro-to-serverless-functions.netlify.app/" rel="noopener noreferrer"&gt;url&lt;/a&gt; to open the site or click on the &lt;strong&gt;Deploys&lt;/strong&gt; tab to see the last deployment log.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2Fd7ce90447a9b47585a842564c9be94603437b803-792x628.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2Fd7ce90447a9b47585a842564c9be94603437b803-792x628.png%3Fw%3D450" alt="Deploys tab highlighted in nav"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To see the serverless functions we created, click on the &lt;strong&gt;Functions&lt;/strong&gt; tab.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2Fe77e1d2fe01b8bbdb0743fc5e1c35b8fe8e7a505-792x628.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2Fe77e1d2fe01b8bbdb0743fc5e1c35b8fe8e7a505-792x628.png%3Fw%3D450" alt="Functions tab highlighted in nav"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should then see the 2 functions listed by the name of the files.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2Fc3c956f1bf9b9e495f68f996570855d645147333-878x964.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2Fc3c956f1bf9b9e495f68f996570855d645147333-878x964.png%3Fw%3D450" alt="Function tab with hello-world and pokedex functions listed"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can further click into each function to see the times and logs from when they were ran.&lt;/p&gt;

&lt;h2&gt;
  
  
  Customizing the Serverless Functions Request
&lt;/h2&gt;

&lt;p&gt;Any serverless function can &lt;em&gt;do stuff&lt;/em&gt; to the data before it returns to the frontend. It can be customized in whatever way you need it and only return the things you want to use. In our example the &lt;code&gt;pokedex.js&lt;/code&gt; is returning all of the data about every Pokémon and wasting space on information we probably don’t need. Back in the &lt;code&gt;pokedex.js&lt;/code&gt; file in your code editor, customize the &lt;code&gt;data&lt;/code&gt; object being returned in the &lt;code&gt;body&lt;/code&gt; to limit it to only the &lt;code&gt;pokemon_entries&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;fetch&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;node-fetch&lt;/span&gt;&lt;span class="dl"&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;handler&lt;/span&gt; &lt;span class="o"&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;POKE_API&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://pokeapi.co/api/v2/pokedex/kanto&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;POKE_API&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;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;pokemon&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pokemon_entries&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will limit what is returned to just a list of the Pokémon without some of the extra data. &lt;/p&gt;

&lt;h3&gt;
  
  
  Fetching Different Data
&lt;/h3&gt;

&lt;p&gt;Back in the &lt;code&gt;index.html&lt;/code&gt; file, we’ll add another button and update our current one to grab 2 different types of data. Update the button with the id &lt;code&gt;fetch-pokedex-btn&lt;/code&gt; to the id &lt;code&gt;fetch-kanto-btn&lt;/code&gt;. Then add a new button with an id of &lt;code&gt;feetch-hoenn-btn&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"fetch-kanto-btn"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Fetch Kanto Pokedex&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"fetch-hoenn-btn"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Fetch Hoenn Pokedex&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We’ll also need to update the variables and functions in the script tag. Replace the &lt;code&gt;fetchPokedexBtn&lt;/code&gt; line with the new variables that grab the new ids.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fetchKantoBtn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fetch-kanto-btn&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;fetchHoennBtn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fetch-hoenn-btn&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, we have to update the event listener functions to grab the different data types. First, update the name on the current &lt;code&gt;fetchPokedexBtn&lt;/code&gt; event listener to be &lt;code&gt;fetchKantoBtn&lt;/code&gt;. Now we can edit the data coming back by using the native fetch API, which takes an options object as a second parameter, to pass a &lt;code&gt;POST&lt;/code&gt; method and send the custom data back to the serverless function. Here we want to specify the kanto region for the Pokémon API.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;fetchKantoBtn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&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;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/.netlify/functions/pokedex&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;POST&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
            &lt;span class="na"&gt;region&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;kanto&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="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;

    &lt;span class="nx"&gt;responseText&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;&lt;span class="nx"&gt;fetchKantoBtn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&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;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/.netlify/functions/pokedex&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;POST&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
            &lt;span class="na"&gt;region&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;kanto&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="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;

    &lt;span class="nx"&gt;responseText&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&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;We also need an event listener function for the “Fetch Hoenn Pokedex” button. We’ll do the same thing, but switch out the &lt;code&gt;kanto&lt;/code&gt; region for &lt;code&gt;hoenn&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;fetchHoennBtn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&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;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/.netlify/functions/pokedex&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;POST&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
            &lt;span class="na"&gt;region&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hoenn&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="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;

    &lt;span class="nx"&gt;responseText&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Event and Context Parameters
&lt;/h3&gt;

&lt;p&gt;All serverless functions accept two parameters, &lt;code&gt;event&lt;/code&gt; and &lt;code&gt;context&lt;/code&gt;. The &lt;code&gt;event&lt;/code&gt; object includes information about the request and the &lt;code&gt;context&lt;/code&gt; parameter includes information about the context that the function was called in. We can use the &lt;code&gt;event&lt;/code&gt; object to grab the custom headers we are sending along with the requests we added to our &lt;code&gt;index.html&lt;/code&gt; code. In the &lt;code&gt;pokedex.js&lt;/code&gt; file, add the two parameters to the handler function and log the event and context with &lt;code&gt;console.log(event, context)&lt;/code&gt; I like to wrap the variables I am logging in an object, &lt;code&gt;{}&lt;/code&gt;, to see the name when it comes through.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// pokedex.js&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;fetch&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;node-fetch&lt;/span&gt;&lt;span class="dl"&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;handler&lt;/span&gt; &lt;span class="o"&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;event&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;context&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;POKE_API&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://pokeapi.co/api/v2/pokedex/kanto&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;POKE_API&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;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;pokemon&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pokemon_entries&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save the file and run &lt;code&gt;ntl dev&lt;/code&gt;, click on one of the Fetch Kanto Pokedex button and in the terminal you will see a lot of data coming back. The important part here is the &lt;code&gt;event.body&lt;/code&gt;, which you will see is the region of the Pokémon that we sent through the &lt;code&gt;POST&lt;/code&gt; method. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F54e9d4d5faf75ec56e793bf1a7a09f6ac8f957fd-580x72.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F54e9d4d5faf75ec56e793bf1a7a09f6ac8f957fd-580x72.png%3Fw%3D450" alt="body region kanto printout"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We are going to use this information by creating a variable to hold the parsed &lt;code&gt;event.body&lt;/code&gt; and then update the url that is fetched to dynamically update depending on the region sent.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;fetch&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;node-fetch&lt;/span&gt;&lt;span class="dl"&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;handler&lt;/span&gt; &lt;span class="o"&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;event&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;context&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;eventBody&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&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;POKE_API&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://pokeapi.co/api/v2/pokedex/kanto&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;eventBody&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;region&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;POKE_API&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;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;pokemon&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pokemon_entries&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now if you refresh the page and click the two Pokedex buttons, you will see two separate sets of data based on the region specified. You can &lt;em&gt;add&lt;/em&gt;, &lt;em&gt;commit&lt;/em&gt;, and &lt;em&gt;push&lt;/em&gt; your code to git to kick off a &lt;a href="https://brittney-explorers-intro-to-serverless-functions.netlify.app/" rel="noopener noreferrer"&gt;new deploy of the site&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next Steps with Serverless Functions
&lt;/h2&gt;

&lt;p&gt;Great job! You have experienced how serverless functions can give developers superpowers to build and customize functionality in their applications. This allows you to solve business needs with a wider range of tools and techniques without needing to manage any infrastructure. Now there’s a whole realm of possibilities for you to explore with serverless functions. To learn more about how you can get the most out of serverless functions with Netlify be sure to &lt;a href="https://docs.netlify.com/functions/build-with-javascript/" rel="noopener noreferrer"&gt;check out the official docs&lt;/a&gt; where you can learn more about other solutions, such as &lt;a href="https://docs.netlify.com/functions/build-with-javascript/" rel="noopener noreferrer"&gt;background functions&lt;/a&gt;, which allow you to execute longer running scripts, using serverless techniques. I can't wait to see what you build with Netlify functions. Remember, if your experience is different from anything written here or something didn’t work as expected, please &lt;a href="https://answers.netlify.com/" rel="noopener noreferrer"&gt;let us know about it here&lt;/a&gt; and we will help you or answer any questions you have.&lt;/p&gt;

</description>
      <category>serverless</category>
      <category>javascript</category>
      <category>netlify</category>
      <category>functions</category>
    </item>
    <item>
      <title>How to Deploy the Qwik JavaScript Framework</title>
      <dc:creator>Brittney Postma</dc:creator>
      <pubDate>Wed, 22 Jun 2022 10:37:47 +0000</pubDate>
      <link>https://dev.to/brittneypostma/how-to-deploy-the-qwik-javascript-framework-ecd</link>
      <guid>https://dev.to/brittneypostma/how-to-deploy-the-qwik-javascript-framework-ecd</guid>
      <description>&lt;p&gt;In this tutorial, I will show you how to deploy a &lt;a href="https://qwik.builder.io/docs/overview" rel="noopener noreferrer"&gt;Qwik&lt;/a&gt; application on Netlify. There is a great &lt;a href="https://www.netlify.com/blog/2016/09/29/a-step-by-step-guide-deploying-on-netlify/" rel="noopener noreferrer"&gt;step-by-step guide to deploying on Netlify&lt;/a&gt; for general use, but this guide is specifically to show you how to deploy Qwik applications. &lt;/p&gt;

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

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://qwik.builder.io" rel="noopener noreferrer"&gt;Qwik&lt;/a&gt; is currently in Beta at the time of writing and may have changes. It is being developed by &lt;a href="https://twitter.com/mhevery" rel="noopener noreferrer"&gt;Miško Hevery&lt;/a&gt; and the team at &lt;a href="https://builder.io" rel="noopener noreferrer"&gt;Builder.io&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Qwik is a &lt;strong&gt;&lt;a href="https://qwik.builder.io/docs/concepts/resumable" rel="noopener noreferrer"&gt;resumable&lt;/a&gt;&lt;/strong&gt; JavaScript framework that renders server-side HTML to optimize performance. It completely removes the &lt;a href="https://dev.to/this-is-learning/why-efficient-hydration-in-javascript-frameworks-is-so-challenging-1ca3"&gt;hydration&lt;/a&gt; step that other frontend frameworks use. The core principle of Qwik is to load as little JavaScript up front as possible and delay the execution of any other JavaScript on the page until it is needed. This allows the application to &lt;a href="https://qwik.builder.io/docs/concepts/progressive" rel="noopener noreferrer"&gt;progressively download code without a big bundle right away&lt;/a&gt;. To make this work, Qwik uses an &lt;a href="https://qwik.builder.io/docs/advanced/optimizer" rel="noopener noreferrer"&gt;Optimizer&lt;/a&gt; written in Rust to transform the code at build time. &lt;a href="https://vitejs.dev/" rel="noopener noreferrer"&gt;Vite&lt;/a&gt; is used for Hot Module Replacement (HMR) and bundling code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Qwik Rendering
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.netlify.com/blog/the-acronyms-of-rendering/" rel="noopener noreferrer"&gt;Rendering on the web&lt;/a&gt; has swung like a pendulum from completely server-side to all static. We now have frameworks that can do hybrid rendering like Next.js and SvelteKit. However, because Qwik needs to progressively load JavaScript to improve the performance, it needs to be able to grab that from a server or server-side rendering (SSR). This may not fit into the true &lt;a href="https://whitep4nth3r.com/blog/what-is-jamstack/" rel="noopener noreferrer"&gt;Jamstack architecture&lt;/a&gt;, but that doesn’t mean it can’t be hosted on Netlify. Platforms like Netlify can take the server side code and use it as &lt;a href="https://whitep4nth3r.com/blog/what-is-the-edge-serverless-functions/#what-is-a-serverless-function" rel="noopener noreferrer"&gt;serverless or edge functions&lt;/a&gt;. This is typically done with some type of adapter or plugin during the build step. In Qwik’s case, it uses the Netlify Edge functions with a &lt;a href="https://github.com/netlify/vite-plugin-netlify-edge" rel="noopener noreferrer"&gt;Vite plugin&lt;/a&gt;. Read more about &lt;a href="https://www.netlify.com/products/edge/" rel="noopener noreferrer"&gt;Netlify Edge here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Getting Started with Qwik
&lt;/h3&gt;

&lt;p&gt;The quickest (pun intended 😁) way to get started with a Qwik app that will be deployed to Netlify, is to use the command line interface — or CLI — tool. Type the following into a terminal to start the Qwik CLI.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm init qwik@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command opens the CLI that will prompt you with the following. &lt;/p&gt;

&lt;h3&gt;
  
  
  Qwik CLI
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Choose your project type, we are choosing a blank starter app to keep it simple. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F8caea331320caed0765440744a86575b77946cd6-1102x494.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F8caea331320caed0765440744a86575b77946cd6-1102x494.png%3Fw%3D450" alt="Choose the Starter option from the select a starter options"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Choose Netlify as your hosting provider. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F24bd9153ab3a432aea24a9f74a00f54b4fdc5ad4-1102x494.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F24bd9153ab3a432aea24a9f74a00f54b4fdc5ad4-1102x494.png%3Fw%3D450" alt="Choose Netlify from the Select a server options"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Select packages you want configured automatically. Eslint and prettier for linting and code formatting, TailwindCSS is an option for styling.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F3c1562465f4e2cee4c04000f1d35e50aa471a054-1102x494.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F3c1562465f4e2cee4c04000f1d35e50aa471a054-1102x494.png%3Fw%3D450" alt="Select which packages you want configured with space bar, prettier, eslint, or tailwindcss."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Success! Your Qwik app is created. Follow the next steps to install the dependencies and run the project locally.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2Fb83046441091dd0a010b17b430c510b6cdf1070a-1102x586.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2Fb83046441091dd0a010b17b430c510b6cdf1070a-1102x586.png%3Fw%3D450" alt="Success! Project saved in directory and next steps."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Running the Qwik App
&lt;/h3&gt;

&lt;p&gt;Once you have completed the steps in the CLI, change directory (&lt;code&gt;cd&lt;/code&gt;), into your newly created project and install the dependencies with a package manager. The Qwik CLI suggests using npm.&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="nb"&gt;cd &lt;/span&gt;qwik-app-name
npm &lt;span class="nb"&gt;install&lt;/span&gt;  &lt;span class="c"&gt;# or yarn or pnpm&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then you can run the dev server to see the site locally with the &lt;code&gt;npm start&lt;/code&gt; 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;span class="c"&gt;# or yarn or pnpm&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Starter Application
&lt;/h3&gt;

&lt;p&gt;Once through the steps of creating the application and installing the dependencies, you are on your way to deploying the app. If you used the CLI and chose Netlify as the hosting provider, a &lt;code&gt;netlify.toml&lt;/code&gt; file already setup for you. If you happened to start here, you can create a &lt;code&gt;netlify.toml&lt;/code&gt; file in the root that has the code below in it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;build&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
&lt;span class="s"&gt;publish = "dist"&lt;/span&gt;
&lt;span class="s"&gt;command = "npm run build"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F3cb868366dbd70ce84463624f131a4a9b669ecc7-1342x1174.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F3cb868366dbd70ce84463624f131a4a9b669ecc7-1342x1174.png%3Fw%3D450" alt="netlify toml file and file structure of Qwik in VSCode"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Deploy Qwik Applications on Netlify
&lt;/h2&gt;

&lt;p&gt;Netlify is a web developer platform that is known for making the web better by &lt;a href="https://www.netlify.com/roi-calculator/" rel="noopener noreferrer"&gt;increasing productivity&lt;/a&gt;. If you are not already a Netlify user, go ahead and &lt;a href="https://app.netlify.com/signup" rel="noopener noreferrer"&gt;sign up for free&lt;/a&gt;. There are two ways we can deploy a Qwik site to Netlify, the Netlify CLI or a manual git deploy.&lt;/p&gt;

&lt;h3&gt;
  
  
  Netlify CLI deploy
&lt;/h3&gt;

&lt;p&gt;The &lt;a href="https://docs.netlify.com/cli/get-started/" rel="noopener noreferrer"&gt;Netlify CLI&lt;/a&gt; is a way to configure, build, test, and deploy your sites without leaving the command line. If you don’t have the Netlify CLI installed, run the following command to install it globally.&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;netlify-cli &lt;span class="nt"&gt;-g&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once installed, many commands can be ran with either the &lt;code&gt;netlify {command}&lt;/code&gt; or &lt;code&gt;ntl {command}&lt;/code&gt; for short. First, run the &lt;code&gt;netlify login&lt;/code&gt; command to authenticate your Netlify account to the CLI. This will open a browser window, asking you to log in with Netlify and grant access to Netlify CLI. &lt;/p&gt;

&lt;p&gt;To setup a new site using the CLI, run &lt;code&gt;netlify init&lt;/code&gt;. This will guide you through the steps to get your site connected and deployed. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;If you don’t have your app connected to git, the Netlify CLI will ask if you want to deploy it manually or connect to a repo. Deploying manually will add more steps, to avoid this you can &lt;a href="https://docs.netlify.com/configure-builds/repo-permissions-linking/" rel="noopener noreferrer"&gt;add your site to a git provider&lt;/a&gt; before running &lt;code&gt;netlify init&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2Fc21a7ffa7da963481565fda9e2ca1d60f4d528e1-1246x156.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2Fc21a7ffa7da963481565fda9e2ca1d60f4d528e1-1246x156.png%3Fw%3D450" alt="Connect to a GitHub or git provider first"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Either connect to an existing Netlify site, or create and configure a new site.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2Fef10ddb3d76b5b47ef23d3391e394da2253d5ce3-1090x112.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2Fef10ddb3d76b5b47ef23d3391e394da2253d5ce3-1090x112.png%3Fw%3D450" alt="Create &amp;amp; configure a new site"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Choose the team you would like to add the site to. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F36825292c018129a1ec4e9ba6a250fabd8717a2c-1190x166.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F36825292c018129a1ec4e9ba6a250fabd8717a2c-1190x166.png%3Fw%3D450" alt="Choose the team you would like to use."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Name your site or leave it blank for a random name. Once this is done, your site is created and your links are available, but the site is not yet deployed.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F82942ee052d68073db894a4f24ef237854e6c91b-994x238.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F82942ee052d68073db894a4f24ef237854e6c91b-994x238.png%3Fw%3D450" alt="Choose a unique site name or leave black for a random one."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Netlify will attempt to detect the build command and directory of the output for the app, but it can be customized in the next steps. For Qwik apps they are:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2Fcd1d267cbf0da9595db2af2e181e04ca8d6f23be-1300x108.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2Fcd1d267cbf0da9595db2af2e181e04ca8d6f23be-1300x108.png%3Fw%3D450" alt="Your build command and directory to deploy"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Specify your functions directory if you are using Netlify functions.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F01a1c3c0d4dfed68545d4a3a5609b1d9d9c53bf7-916x56.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F01a1c3c0d4dfed68545d4a3a5609b1d9d9c53bf7-916x56.png%3Fw%3D450" alt="Specify Netlify functions folder path"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;And success, your site is deployed!&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F6b2873c9af0d1605cf5f98a75f0c7e86f287e887-680x74.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F6b2873c9af0d1605cf5f98a75f0c7e86f287e887-680x74.png%3Fw%3D450" alt="Success! Netlify CI/CD Configured"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once configured, any new push to your git repository, &lt;code&gt;git push&lt;/code&gt;, will trigger a new site build or by running &lt;code&gt;netlify deploy --prod&lt;/code&gt;. Running &lt;code&gt;netlify open&lt;/code&gt; will open the Netlify admin URL for your new &lt;a href="https://deploy-qwik-ly-on.netlify.app/" rel="noopener noreferrer"&gt;Qwik app on Netlify&lt;/a&gt;!&lt;/p&gt;

&lt;h3&gt;
  
  
  Deploy a Qwik Site from Git
&lt;/h3&gt;

&lt;p&gt;If you choose to do so, you can also manually deploy a Qwik app on &lt;a href="https://app.netlify.com/start" rel="noopener noreferrer"&gt;Netlify&lt;/a&gt;. Once you have a git repository pushed, navigate to the &lt;strong&gt;Sites&lt;/strong&gt; page in your Netlify dashboard and click the button “Add new site”. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F1e6300bbdbfd9ce6b1fdb62abba8d7fe5146fe3e-1986x464.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F1e6300bbdbfd9ce6b1fdb62abba8d7fe5146fe3e-1986x464.png%3Fw%3D450" alt="Select Sites page from the nav bar"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A dropdown menu will appear that asks if you want to import an existing project, start from a template, or deploy manually. To get a site from git, you should choose the &lt;strong&gt;Import an existing project&lt;/strong&gt; option.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654771257%2Fblog%2Fimport.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654771257%2Fblog%2Fimport.png" alt="Select Import an existing project from Add new site dropdown"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That will bring you to a screen to connect your Git provider. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F6a4ef89b123e2922cb5a044dee877595a6dcd383-1400x976.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F6a4ef89b123e2922cb5a044dee877595a6dcd383-1400x976.png%3Fw%3D450" alt="Connect to your Git provider"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Choose the provider where the git repository for your app is located, then Netlify will authenticate and pop up a search for your available repos. Choose your repository, and Netlify will auto detect the framework and populate the build command and publish directory. If there is a custom build, you can edit the settings on this screen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F096a6d0c95ee02de67b0a12f9e77c78ea78c8bfe-1300x1718.png%3Fw%3D450" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fo0o2tn5x%2Fproduction%2F096a6d0c95ee02de67b0a12f9e77c78ea78c8bfe-1300x1718.png%3Fw%3D450" alt="Link your site to a Git repository and setup the build settings"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click the &lt;strong&gt;Deploy site&lt;/strong&gt; button and Netlify will begin deploying your application. Now your Qwik app is live!&lt;/p&gt;

&lt;p&gt;That’s it, now you have a &lt;a href="https://deploy-qwik-ly-on.netlify.app/" rel="noopener noreferrer"&gt;Qwik app deployed to Netlify&lt;/a&gt;. Remember, if your experience is different from anything written here or something didn’t work as expected, please &lt;a href="https://answers.netlify.com" rel="noopener noreferrer"&gt;let us know about it here&lt;/a&gt; and we will help you or answer any questions you have.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>ssr</category>
      <category>qwik</category>
      <category>deploy</category>
    </item>
    <item>
      <title>How to Deploy SolidJS</title>
      <dc:creator>Brittney Postma</dc:creator>
      <pubDate>Fri, 10 Jun 2022 14:08:30 +0000</pubDate>
      <link>https://dev.to/brittneypostma/how-to-deploy-solidjs-4hoi</link>
      <guid>https://dev.to/brittneypostma/how-to-deploy-solidjs-4hoi</guid>
      <description>&lt;h2&gt;
  
  
  Deploy SolidJS on Netlify
&lt;/h2&gt;

&lt;p&gt;In this guide, we will show you how to deploy a &lt;a href="https://www.solidjs.com/" rel="noopener noreferrer"&gt;SolidJS&lt;/a&gt; application on Netlify. Whether you are starting from scratch or switching from another platform, we have you covered when deploying Solid. There is a great &lt;a href="https://www.netlify.com/blog/2016/09/29/a-step-by-step-guide-deploying-on-netlify/" rel="noopener noreferrer"&gt;step-by-step guide to deploying on Netlify&lt;/a&gt; for general use, but this guide is specifically to show you how to deploy Solid applications.&lt;/p&gt;

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

&lt;p&gt;SolidJS is a reactive JavaScript library that uses declarative JSX code to create performant user interfaces. Solid follows many of the same philosophies React does and has an API similar to React Hooks. Rather than using a Virtual DOM as React does, Solid compiles its components into actual DOM nodes that update in a more performant manner with more precision. &lt;/p&gt;

&lt;h2&gt;
  
  
  Deploy Solid Applications to Netlify
&lt;/h2&gt;

&lt;p&gt;Netlify is a web developer platform that is known for making the web better by increasing productivity and deploying the fastest applications &lt;a href="https://www.netlify.com/jamstack/" rel="noopener noreferrer"&gt;using the Jamstack architecture&lt;/a&gt;. If you are not already a Netlify user, go ahead and &lt;a href="https://app.netlify.com/signup" rel="noopener noreferrer"&gt;sign up for free&lt;/a&gt; first.&lt;/p&gt;

&lt;p&gt;Otherwise, feel free to go directly to whichever section is most relevant to you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
Drag and Drop deploy - no git repository needed&lt;/li&gt;
&lt;li&gt;Netlify CLI deploy&lt;/li&gt;
&lt;li&gt;Manual Deploy from Git&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Getting Started with Solid
&lt;/h3&gt;

&lt;p&gt;The quickest way to get started with a Solid app, is to use the base template. Type one of the following into a terminal.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JavaScript Template&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx degit solidjs/templates/js my-app
&lt;span class="nb"&gt;cd &lt;/span&gt;my-app
npm i &lt;span class="c"&gt;# or yarn or pnpm&lt;/span&gt;
npm run dev &lt;span class="c"&gt;# or yarn or pnpm&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;TypeScript Template&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx degit solidjs/templates/ts my-app
&lt;span class="nb"&gt;cd &lt;/span&gt;my-app
npm i &lt;span class="c"&gt;# or yarn or pnpm&lt;/span&gt;
npm run dev &lt;span class="c"&gt;# or yarn or pnpm&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Drag and Drop deploy with Netlify
&lt;/h3&gt;

&lt;p&gt;With the new &lt;a href="https://app.netlify.com/drop" rel="noopener noreferrer"&gt;Drop deploy&lt;/a&gt;, you don’t even need a git repository to deploy your site. Within the terminal from the location you created your app, run the build command for the Solid app.&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 build &lt;span class="c"&gt;# or yarn or pnpm&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;dist&lt;/code&gt; folder is then created within the root of your project. Navigate to the folder that holds your new &lt;code&gt;dist&lt;/code&gt; folder in your Finder on Mac or File Explorer on Windows devices and also go to your &lt;a href="https://app.netlify.com/" rel="noopener noreferrer"&gt;Netlify team page&lt;/a&gt; and login. Once you are logged in, you can drag your &lt;code&gt;dist&lt;/code&gt; folder right onto the page and Netlify will generate a url and quickly deploy your Solid site.&lt;/p&gt;

&lt;h3&gt;
  
  
  Netlify CLI deploy
&lt;/h3&gt;

&lt;p&gt;The &lt;a href="https://docs.netlify.com/cli/get-started/" rel="noopener noreferrer"&gt;Netlify CLI&lt;/a&gt; is a way to configure, build, test, and deploy your sites all without leaving the command line. First, you need to have the Netlify CLI installed on your local machine. Run the following command to install it globally.&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;netlify-cli &lt;span class="nt"&gt;-g&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once installed, many commands can be ran with either the &lt;code&gt;netlify {command}&lt;/code&gt; or &lt;code&gt;ntl {command}&lt;/code&gt; for short. First, you will want to run the &lt;code&gt;netlify login&lt;/code&gt; command to authenticate your Netlify account to the CLI. This will open a browser window, asking you to log in with Netlify and grant access to Netlify CLI. You can then use the netlify init command to either connect a site without a git repository or connect your local repository for continuous deployment on Netlify. This will lead you through a few steps to get your site connected and deployed. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;If you don’t have your app connected to git, the Netlify CLI will ask if you want to deploy it manually or connect to a repo. Deploying manually will add more steps, to avoid this you can add your site to a git provider before running netlify init.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654772694%2Fblog%2Fgithub.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654772694%2Fblog%2Fgithub.png" alt="create without git repository or connect to GitHub"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Once connected to git, either connect to an existing Netlify site, or create and configure a new site.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654771257%2Fblog%2Fconnect.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654771257%2Fblog%2Fconnect.png" alt="create and configure a new site"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Choose the team you would like to add the site to. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654771257%2Fblog%2Fteam.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654771257%2Fblog%2Fteam.png" alt="Choose the team you would like to add the site to"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Name your site or leave it blank for a random name. Once this is done, your site is created and your links are available, but the site is not yet deployed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654773660%2Fblog%2Fname.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654773660%2Fblog%2Fname.png" alt="Name your site or leave it blank for a random name."&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Netlify will attempt to detect the build command and directory of the output for the app, but it can be customized in the next steps.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654773736%2Fblog%2Fbuild.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654773736%2Fblog%2Fbuild.png" alt="Netlify will attempt to detect the build command and directory of the output for the app"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Specify your functions directory if you are using Netlify serverless functions and create a netlify.toml configuration file if you don’t already have one.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654771257%2Fblog%2Ffunctions.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654771257%2Fblog%2Ffunctions.png" alt="Specify your functions directory if you are using Netlify serverless functions and create a netlify.toml configuration file if you don’t already have one."&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;And success, your site is configured!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654771257%2Fblog%2Fsuccess.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654771257%2Fblog%2Fsuccess.png" alt="your site is configured"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To deploy your site, run &lt;code&gt;netlify deploy&lt;/code&gt; in the terminal. Or head to the app.netlify.com dashboard to deploy manually. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Once configured, any new push to your git repository, &lt;code&gt;git push&lt;/code&gt;, will trigger a new site build or by running &lt;code&gt;netlify-deploy --prod&lt;/code&gt;. Running &lt;code&gt;netlify open&lt;/code&gt; will open the Netlify admin URL for your new &lt;a href="https://deploy-solid-with-netlify-cli.netlify.app/" rel="noopener noreferrer"&gt;Solid site&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654773938%2Fblog%2Fsolid-dash.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654773938%2Fblog%2Fsolid-dash.png" alt="Netlify Dashboard of the new deployed site"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Deploy a Solid Site from Git
&lt;/h3&gt;

&lt;p&gt;You can also manually deploy a Solid app on &lt;a href="https://app.netlify.com/start" rel="noopener noreferrer"&gt;Netlify&lt;/a&gt;. Once you have a git repository pushed, navigate to the &lt;strong&gt;Sites&lt;/strong&gt; page in your Netlify dashboard and click the button “Add new site”. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654771257%2Fblog%2Fsites.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654771257%2Fblog%2Fsites.png" alt="Sites page in the nav bar of Netlify's dashboard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A dropdown menu will appear that asks if you want to import an existing project, start from a template, or deploy manually. To get a site from git, you should choose the &lt;strong&gt;Import an existing project&lt;/strong&gt; option.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654771257%2Fblog%2Fimport.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654771257%2Fblog%2Fimport.png" alt="dropdown menu to import an existing project on Netlify dashboard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That will bring you to a screen to connect your Git provider. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654771257%2Fblog%2Fgit.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654771257%2Fblog%2Fgit.png" alt="connect your git provider"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Search the provider where the git repository for your app is located, then Netlify will authenticate and pop up a search for your available repos. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654774095%2Fblog%2Fsearch-git.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654774095%2Fblog%2Fsearch-git.png" alt="Search for the git repository"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you choose the correct repository, Netlify will auto detect the framework and populate the build command and publish directory. If there is a custom build, you can edit the settings on this screen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654774162%2Fblog%2Fauto-detect-build.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654774162%2Fblog%2Fauto-detect-build.png" alt="auto detect build settings"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click the &lt;strong&gt;Deploy site&lt;/strong&gt; button and Netlify will begin deploying your application. Now your &lt;a href="https://deploy-solid-on.netlify.app/" rel="noopener noreferrer"&gt;SolidJS app&lt;/a&gt; is live!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654774258%2Fblog%2Fsolid-site.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fnetlify%2Fimage%2Fupload%2Fv1654774258%2Fblog%2Fsolid-site.png" alt="Solid app"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That’s it, three different ways to deploy your SolidJS site to Netlify. Remember, if your experience is different from anything written here or something didn’t work as expected, please &lt;a href="https://answers.netlify.com" rel="noopener noreferrer"&gt;let us know about it here&lt;/a&gt; and we will help you or answer any questions you have.&lt;/p&gt;

</description>
      <category>solid</category>
      <category>jamstack</category>
      <category>netlify</category>
      <category>hosting</category>
    </item>
    <item>
      <title>The Acronyms of Rendering on the Web</title>
      <dc:creator>Brittney Postma</dc:creator>
      <pubDate>Wed, 01 Jun 2022 17:01:27 +0000</pubDate>
      <link>https://dev.to/brittneypostma/the-acronyms-of-rendering-on-the-web-3k1m</link>
      <guid>https://dev.to/brittneypostma/the-acronyms-of-rendering-on-the-web-3k1m</guid>
      <description>&lt;p&gt;Many frontend frameworks now offer the ability to choose how you want to deliver your website to users. Each will give the user a different experience depending on the way it is rendered. First, let’s break it down. What is rendering?&lt;/p&gt;

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

&lt;p&gt;Rendering is the process that turns the code you write an application in into something that users can interact with on a web page. Declarative code, even plain HTML files, cannot just be plopped into the browser and work properly. When a user requests a website it needs to be parsed into something usable by the JavaScript engine inside the browser before anything is rendered on the screen. The code has to be transformed before it can even start the process of the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/Performance/Critical_rendering_path"&gt;Critical Rendering Path (CRP)&lt;/a&gt;. These are the steps the browser takes to convert your code into actual pixels on the screen including the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model"&gt;Document Object Model (DOM)&lt;/a&gt;, &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/CSS_Object_Model"&gt;CSS Object Model (CSSOM)&lt;/a&gt;, the render tree, and layout. &lt;/p&gt;

&lt;h2&gt;
  
  
  Types of rendering
&lt;/h2&gt;

&lt;p&gt;When a user navigates to a website, a request is sent off to a server and data is returned before the CRP begins. How that data gets returned is the type of rendering that occurs. There are three different types. These include Client Side Rendering (CSR), Server Side Rendering (SSR), and Static Rendering or Static Site Generation (SSG).  Each will change the user experience of the website and how the performance or perceived performance is optimized. Many frontend frameworks give you the option to choose how to render different pages on your site.&lt;/p&gt;

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

&lt;p&gt;Client Side Rendering or CSR lets the browser do as much of the work as possible to render the page. The "client" is the current browser being used to view the site. Initially a request is sent to the server and a single HTML file with any JavaScript that is needed to load the rest of the site is returned. If your site contains JavaScript, then it will be ran completely inside the browser from that point on. Even plain HTML and JavaScript sites without a framework will be rendered on the client (CSR). Sites that use CSR commonly have a loading spinner or some indication that you are waiting on content to load. By delaying the initial load, once the site is on the screen everything is fully interactive and functional. In most cases, this requires extra JavaScript to be ran and can be hard to keep performant at scale.&lt;/p&gt;

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

&lt;p&gt;Server side rendering, SSR, is what the web of old was built on. Trends went far in the opposite direction with CSR with single page applications (SPAs) and popular libraries like React. Now SSR is starting to fall back into style. This puts most of the work back on the server. When the browser requests a page, the server builds the page, compile all the data, and return the entire HTML page back. Data is dynamically grabbed from the server every time a user visits the page. This causes the server to do the work all over again. Internet speed, server location, and too many users at once can impact the performance of these sites. &lt;/p&gt;

&lt;p&gt;SSR has become the new trend because Content Delivery Networks (CDNs) like Netlify, provide servers across the globe that distribute the content closer to the end user. That request to response trip is shorter in most cases than the traditional single server location. This is also where the term serverless comes in. You are able to build and deploy your applications without having to maintain the actual server infrastructure. SSR uses serverless functions under the hood on the Jamstack. On Netlify, serverless functions default to use a single server location. Static pages are still served from the CDN and SSR can be ran on the CDN with &lt;a href="https://www.netlify.com/blog/announcing-serverless-compute-with-edge-functions/"&gt;Edge Functions&lt;/a&gt;. &lt;/p&gt;

&lt;h3&gt;
  
  
  Static Rendering / Static Site Generation (SSG)
&lt;/h3&gt;

&lt;p&gt;Static rendering is when all of the data a page needs is generated when the site is built. Prerendering all of the content in your site emerged with frameworks like Jekyll and Gatsby. These sites do all of their data collection at build time and is cached at that moment in time. Any new data that changes on the site requires a rebuild of the entire application. This built the foundation for the original concept of the Jamstack architecture, a web development workflow that focuses on prerendering as much content as possible. Additionally making them dynamic through application programming interfaces (APIs) and serverless functions. Having to rebuild the entire site for any change led to long build times and new solutions emerged to lessen these.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rendering Techniques
&lt;/h2&gt;

&lt;p&gt;As sites started going in the direction of more prerendered content and build times started creeping up, new techniques were developed to help combat them. These focused on increasing the speed and the functionality of sites built on the Jamstack.&lt;/p&gt;

&lt;h3&gt;
  
  
  Distributed Persistent Rendering (DPR)
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.netlify.com/blog/2021/04/14/distributed-persistent-rendering-a-new-jamstack-approach-for-faster-builds/"&gt;Distributed Persistent Rendering (DPR)&lt;/a&gt; allows developers to defer the rendering of a route or asset until the first time a user visits the page and is then cached on the CDN. This sacrifices the load time somewhat for a single user to lower the build speed and have the newest content available. With this technique the most visited pages can be prerendered at build time and less popular pages can be built on-demand. When the page is built on demand, the cached page is immediately invalidated. That means if there is ever a need to rollback to a previous build, users would never see stale content.&lt;/p&gt;

&lt;h3&gt;
  
  
  Incremental Static Regeneration (ISR)
&lt;/h3&gt;

&lt;p&gt;Another technique that came from Next.js, a React framework, is &lt;a href="https://nextjs.org/docs/basic-features/data-fetching/incremental-static-regeneration"&gt;Incremental Static Regeneration (ISR)&lt;/a&gt;. Rather than deferring the rendering of the page, it is rendered at build time and cached. When a user requests the page, the cached page is shown for a time while a new build of the page is triggered in the background. The cached page is not invalidated until the new page is generated.&lt;/p&gt;

&lt;h3&gt;
  
  
  Edge Rendering
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.netlify.com/products/edge/"&gt;Edge rendering&lt;/a&gt; is a new term that is popping up everywhere. Most of this comes down to serving things at the CDN level, the “edge”. This piece comes in when a page has already been rendered and needs to be updated with personalization or locale data giving atomic updates to your application. There are a handful of vendors offering this in some form, but each has their own flavor. Netlify uses Deno, a runtime based on modern web standards, rather than Node.js for their implementation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;There are many choices when it comes to getting a page to a user and each comes with its own implications. It comes down to choosing the tool that is right for the job, but don’t be stuck in decision paralysis. One way to test if you need SSR or CSR is to disable JavaScript and load the web page. If your page is still functional, it can likely be prerendered. Using the Jamstack architecture allows you to start small and add in complexity where it is needed. Prerendering as much content as possible and using less JavaScript is better for everyone. Increased performance, portability, and maintainability are just a few of the reasons &lt;a href="https://jamstack.org/why-jamstack/"&gt;why to use the Jamstack&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>rendering</category>
      <category>ssg</category>
      <category>ssr</category>
      <category>csr</category>
    </item>
    <item>
      <title>Accessibility Best Practices for HTML &amp; CSS</title>
      <dc:creator>Brittney Postma</dc:creator>
      <pubDate>Thu, 19 Aug 2021 14:52:01 +0000</pubDate>
      <link>https://dev.to/brittneypostma/accessibility-best-practices-for-html-css-d51</link>
      <guid>https://dev.to/brittneypostma/accessibility-best-practices-for-html-css-d51</guid>
      <description>&lt;p&gt;&lt;a href="https://media.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%2Ff8hp85rkylwpu5wtib5g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Ff8hp85rkylwpu5wtib5g.png" alt="Accessibility Best Practices for HTML &amp;amp; CSS by @brittneypostma bDesigned"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Additional Links&lt;/li&gt;
&lt;li&gt;Foundation&lt;/li&gt;
&lt;li&gt;
Semantic HTML

&lt;ul&gt;
&lt;li&gt;Structural&lt;/li&gt;
&lt;li&gt;Content&lt;/li&gt;
&lt;li&gt;Language&lt;/li&gt;
&lt;li&gt;Forms&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

Styling

&lt;ul&gt;
&lt;li&gt;Contrast&lt;/li&gt;
&lt;li&gt;States&lt;/li&gt;
&lt;li&gt;Animations&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Accessibility Best Practices for HTML &amp;amp; CSS
&lt;/h2&gt;

&lt;p&gt;Great accessibility is not always an easy task and goes much more in depth than what is listed here. I still recommend having experienced screen readers and accessibility experts test your site and run your site through the &lt;a href="https://wave.webaim.org/" rel="noopener noreferrer"&gt;WebAIM  Web Accessibility Evaluation Tool&lt;/a&gt;, WAVE. If you see anything that should be added, updated, or removed, please get in touch with me either in the comments or &lt;a href="https://twitter.com/BrittneyPostma" rel="noopener noreferrer"&gt;@brittneypostma on Twitter&lt;/a&gt;. This article is here to serve as a starting point to summarize and guide your way to better accessibility. Having better accessibility isn't only the right thing to do, it also increases your Search Engine Optimization, SEO, which can rank you higher in Google's algorithm. Here are some links to provide more information on web accessibility.&lt;/p&gt;

&lt;h2&gt;
  
  
  Additional Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.w3.org/WAI/fundamentals/accessibility-intro/" rel="noopener noreferrer"&gt;Introduction to Web Accessibility&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.w3.org/WAI/WCAG21/quickref/" rel="noopener noreferrer"&gt;WCAG Quick Reference&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.w3.org/WAI/test-evaluate/preliminary/" rel="noopener noreferrer"&gt;Easy Checks for Web Accessibility&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Learn/Accessibility/HTML" rel="noopener noreferrer"&gt;MDN A good basis for accessibility&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Foundation
&lt;/h2&gt;

&lt;p&gt;Everything should start with a good foundation and with Hypertext Markup Language, HTML, that is the structure of your page. A huge part of web accessibility is just making sure the HTML elements are used correctly. A web page may be styled in many different ways to organize information visually, especially with different viewport sizes, but a blind user only hears the order defined in the HTML of a page. In my opinion, using semantic HTML along with mobile-first design  allows you to see the layout of a page &lt;em&gt;linearized&lt;/em&gt; into one column and the order of the markup to see if it makes sense. &lt;/p&gt;

&lt;h2&gt;
  
  
  Semantic HTML
&lt;/h2&gt;

&lt;p&gt;The word semantic relates to the meaning of something in a language or logic. In semantic HTML the HTML element used gives meaning to define its content and how it is classified. There are currently over one hundred different &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element" rel="noopener noreferrer"&gt;elements in HTML&lt;/a&gt;, but not all of them have a semantic meaning.  The layout of the page defines the &lt;a href="https://www.w3.org/WAI/tutorials/page-structure/regions/" rel="noopener noreferrer"&gt;page regions&lt;/a&gt; that are identified by web browsers and assistive technologies.&lt;/p&gt;

&lt;h3&gt;
  
  
  Structural
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Use the &lt;code&gt;header&lt;/code&gt; and &lt;code&gt;footer&lt;/code&gt; elements to define the top and bottom of a page, but also can define the top and bottom of an article or section.&lt;/li&gt;
&lt;li&gt;Use the &lt;code&gt;nav&lt;/code&gt; element for major blocks of links to allow assistive technologies to quickly and easily navigate through the site. The&lt;code&gt;nav&lt;/code&gt; element can be used around unordered lists, &lt;code&gt;ul&lt;/code&gt;, or around a block of content referring to multiple links. You can use the &lt;code&gt;aria-label&lt;/code&gt; property to identify different navigation areas.&lt;/li&gt;
&lt;li&gt;Use the &lt;code&gt;main&lt;/code&gt; tag to define the main content of the page and &lt;code&gt;aside&lt;/code&gt; to define anything related to the main content.&lt;/li&gt;
&lt;li&gt;Only use &lt;code&gt;div&lt;/code&gt;s and &lt;code&gt;span&lt;/code&gt;s for styling purposes. Use the  &lt;code&gt;section&lt;/code&gt; tag to group related elements with a heading and the &lt;code&gt;article&lt;/code&gt; tag to group a self-contained item that is independent or reusable. The &lt;code&gt;article&lt;/code&gt; element can be posts, news articles, product cards, comments, or any other form of independent items or content. Here is a great Smashing Magazine article on &lt;a href="https://www.smashingmagazine.com/2020/01/html5-article-section/" rel="noopener noreferrer"&gt;Why You Should Choose HTML5 article Over section&lt;/a&gt; explaining that &lt;code&gt;article&lt;/code&gt; can be used in almost all instances, but a &lt;code&gt;section&lt;/code&gt; with an aria-label can be helpful.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Content
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Use the correct levels for headings, from the most important as an &lt;code&gt;h1&lt;/code&gt; down through &lt;code&gt;h6&lt;/code&gt; and do not skip heading levels. Each page should have a heading level 1,  &lt;code&gt;h1&lt;/code&gt; , that represents the most important idea on the page. Any sub-headings should be an &lt;code&gt;h2&lt;/code&gt; , sub-sections can then be divided into &lt;code&gt;h3&lt;/code&gt;s and on down to &lt;code&gt;h6&lt;/code&gt; s based on the nested structure.&lt;/li&gt;
&lt;li&gt;Use the paragraph, &lt;code&gt;p&lt;/code&gt;, element to wrap self-contained blocks of text that focus on a single topic or theme. Also, the &lt;code&gt;strong&lt;/code&gt; and emphasized, &lt;code&gt;em&lt;/code&gt;, elements have semantic meaning where bold, &lt;code&gt;b&lt;/code&gt;, and italic, &lt;code&gt;i&lt;/code&gt;, are simply style differences.&lt;/li&gt;
&lt;li&gt;Use an &lt;code&gt;alt&lt;/code&gt; attribute on images &lt;strong&gt;if&lt;/strong&gt; the image is important to the content, such as information to understanding or interacting with something. Otherwise, if an image is decorative and adds no value to the content, the attribute can be declared &lt;code&gt;alt=""&lt;/code&gt; and it will not be read by assistive technologies.&lt;/li&gt;
&lt;li&gt;Try to provide alternative to audio and video content, such as captions or transcripts for those that are hard of hearing or using screen readers.&lt;/li&gt;
&lt;li&gt;Use the anchor, &lt;code&gt;a&lt;/code&gt;, tag for links that go somewhere else and the &lt;code&gt;button&lt;/code&gt; tag for an action like submitting a form or a click event.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Language
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Don't use dashes if you can avoid it. Instead of writing 5–7, write 5 to 7.&lt;/li&gt;
&lt;li&gt;Expand abbreviations — instead of writing Jan, write January.&lt;/li&gt;
&lt;li&gt;Expand acronyms, at least once or twice. Instead of writing HTML in the first instance, write Hypertext Markup Language.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Forms
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Forms are one of the most common problems for accessibility on sites. Make sure not to disable any of the default keyboard functionalities or tab order and use the proper markup. Also, consider keeping forms short and only ask users for the minimal information needed to complete the process. &lt;a href="https://www.w3.org/WAI/tutorials/forms/" rel="noopener noreferrer"&gt;https://www.w3.org/WAI/tutorials/forms/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Use the &lt;code&gt;label&lt;/code&gt; element with a &lt;code&gt;for&lt;/code&gt; attribute that matches an &lt;code&gt;id&lt;/code&gt; attribute on the accompanying &lt;code&gt;input&lt;/code&gt; or wrap the &lt;code&gt;label&lt;/code&gt; around the &lt;code&gt;input&lt;/code&gt;. &lt;a href="https://www.w3.org/WAI/tutorials/forms/labels/" rel="noopener noreferrer"&gt;https://www.w3.org/WAI/tutorials/forms/labels/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Make sure instructions needed to complete an input are listed before the input area and make clear if an input is required and any validation requirements. Make any errors that prevent completing a form known to the user.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Styling
&lt;/h2&gt;

&lt;p&gt;Styling, whether with CSS or JavaScript, can cause accessibility issues to occur when some browser defaults are removed or incorrectly changed. Including heading and text sizes, outline styling, color contrast, and more. The best practice is to leave the browser defaults if you don't know how to correctly restyle them. I've listed some of the most common issues below. &lt;a href="https://developer.mozilla.org/en-US/docs/Learn/Accessibility/CSS_and_JavaScript" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Learn/Accessibility/CSS_and_JavaScript&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Contrast
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;There should be sufficient contrast between any foreground text and the background color behind it. The minimum contrast ratio for normal sized text is &lt;strong&gt;4:5:1&lt;/strong&gt; and &lt;strong&gt;3:1&lt;/strong&gt; for larger text. These are &lt;strong&gt;AA&lt;/strong&gt; minimum contrast criteria.&lt;/li&gt;
&lt;li&gt;There are enhanced &lt;strong&gt;AAA&lt;/strong&gt; criteria at &lt;strong&gt;7:1&lt;/strong&gt; for regular text and &lt;strong&gt;4:5:1&lt;/strong&gt; for larger text. There are many extensions and plugins that check for contrast issues, but they can be inaccurate and inconsistent. The WebAIM provides a contrast checker at  &lt;a href="https://webaim.org/resources/contrastchecker/" rel="noopener noreferrer"&gt;https://webaim.org/resources/contrastchecker/&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;For non-text items the contrast ratio should be a minimum of &lt;strong&gt;3:1&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  States
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;focus&lt;/strong&gt; state shows when a user is focused, either by click, keyboard, or voice, on an element. Only interactive elements need to have a focus state. A common practice is to remove the default outline for focus states with CSS, &lt;strong&gt;never&lt;/strong&gt; do this without replacing it. A background should be &lt;strong&gt;3:1&lt;/strong&gt; contrast ratio for buttons and inputs and a minimum &lt;strong&gt;1.4.3&lt;/strong&gt; underline for links. More information and examples are listed here &lt;a href="https://www.w3.org/WAI/WCAG21/Understanding/non-text-contrast.html" rel="noopener noreferrer"&gt;https://www.w3.org/WAI/WCAG21/Understanding/non-text-contrast.html&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;hover&lt;/strong&gt; and &lt;strong&gt;active&lt;/strong&gt; states are sometimes styled similarly. The active state shows when something is activated, usually a button or a link, and the hover shows when it is being hovered on. The styles are not the important part for accessibility on these elements, but telling assistive technologies when an element is active is important.  Using the correct &lt;strong&gt;aria-pressed&lt;/strong&gt; attribute based on the state will tell a user whether the element is active or not. More info on states can be found here &lt;a href="https://www.w3.org/WAI/tutorials/menus/styling/#hover-and-focus-states" rel="noopener noreferrer"&gt;https://www.w3.org/WAI/tutorials/menus/styling/#hover-and-focus-states&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Animations
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Users should be able to control any moving, flashing, or blinking content on a page. Examples include ads, videos, auto-updating visuals, moving backgrounds, and more. Basically, anything that is initiated by the page without the user interacting with it. A good practice is to use a &lt;strong&gt;prefers-reduced-motion&lt;/strong&gt; media feature to turn off animations. If the animation is critical to understanding something, add it back in with a selector after turning down all animations. &lt;a href="https://css-tricks.com/revisiting-prefers-reduced-motion-the-reduced-motion-media-query/" rel="noopener noreferrer"&gt;https://css-tricks.com/revisiting-prefers-reduced-motion-the-reduced-motion-media-query/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="n"&gt;screen&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prefers-reduced-motion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; 
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;update&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;slow&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;animation-duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.001ms&lt;/span&gt; &lt;span class="cp"&gt;!important&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;animation-iteration-count&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="cp"&gt;!important&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* Hat tip Nick/cssremedy (https://css-tricks.com/revisiting-prefers-reduced-motion-the-reduced-motion-media-query/#comment-1700170) */&lt;/span&gt;
    &lt;span class="nl"&gt;transition-duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.001ms&lt;/span&gt; &lt;span class="cp"&gt;!important&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Make sure all animated content has pause, stop and hide capabilities and check the tab order to ensure it works correctly. &lt;a href="https://www.matuzo.at/blog/the-dark-side-of-the-grid-part-2/" rel="noopener noreferrer"&gt;The Dark Side of the Grid&lt;/a&gt; is a good post on how changing visual order can mess with the order in the Document Object Model, DOM. The &lt;a href="https://css-tricks.com/accessible-web-animation-the-wcag-on-animation-explained/" rel="noopener noreferrer"&gt;Accessible Web Animation Explained&lt;/a&gt; post from CSS Tricks has some good tips as well.&lt;/li&gt;
&lt;li&gt;Do &lt;strong&gt;NOT&lt;/strong&gt; have anything that flashes more than three times in a one second period as this is known to cause seizures. If you can't avoid flashing animations, see the &lt;a href="https://www.w3.org/TR/2008/REC-WCAG20-20081211/#general-thresholddef" rel="noopener noreferrer"&gt;W3C's detailed guide on how to meet the safe thresholds&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By no means is this the be all, end all of things that should be done for accessibility. It is an ongoing, ever-evolving process that is an extremely important aspect for inclusion and usability. These are some of the core fundamentals of good User Experience, UX, and helping others understand, navigate, and interact with your site. At a bare minimum, follow these best practices and run your site through the &lt;a href="https://wave.webaim.org/" rel="noopener noreferrer"&gt;WebAIM  Web Accessibility Evaluation Tool&lt;/a&gt;, WAVE. If you see anything that should be added, updated, or removed, please get in touch with me either in the comments or &lt;a href="https://twitter.com/BrittneyPostma" rel="noopener noreferrer"&gt;@brittneypostma on Twitter&lt;/a&gt;. &lt;/p&gt;

</description>
      <category>a11y</category>
      <category>html</category>
      <category>css</category>
    </item>
    <item>
      <title>Make Pathing Easier with Aliases in SvelteKit</title>
      <dc:creator>Brittney Postma</dc:creator>
      <pubDate>Thu, 05 Aug 2021 00:08:14 +0000</pubDate>
      <link>https://dev.to/brittneypostma/make-pathing-easier-with-aliases-in-sveltekit-37l0</link>
      <guid>https://dev.to/brittneypostma/make-pathing-easier-with-aliases-in-sveltekit-37l0</guid>
      <description>&lt;p&gt;UPDATE June '22:&lt;br&gt;
&lt;a href="https://kit.svelte.dev/docs/configuration#alias"&gt;SvelteKit Alias Docs&lt;/a&gt; were updated with an improved way of configuring aliases. Aliases can now be configured as top level under the &lt;code&gt;kit&lt;/code&gt; property in the &lt;code&gt;svelte.config.js&lt;/code&gt; file. This article is now updated to reflect this change.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const config = {
  kit: {
    alias: {
      $components: 'src/components',
      $utils: 'src/utils'
    }
  }
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you haven't heard about SvelteKit yet, go checkout the beautiful site over at &lt;a href="//kit.svelte.dev"&gt;kit.svelte.dev&lt;/a&gt;. SvelteKit is a component framework similar to React and Vue with one key difference, there is no virtual DOM. Svelte is a compiler that builds itself away into a sleek and fast end user experience. If you haven't tried Svelte or SvelteKit before, you can check out my quick intro &lt;a href="https://www.youtube.com/watch?v=fOD_3iSiwTQ"&gt;tutorial&lt;/a&gt; where we build a blog in 30 minutes 🤯 &lt;/p&gt;

&lt;p&gt;Links:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://kit.svelte.dev/docs"&gt;SvelteKit Docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://svelte.dev/docs"&gt;Svelte Docs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;TLDR: To setup an alias add the following lines to the &lt;code&gt;svelte.config.js&lt;/code&gt;. For the code editor you are using to understand the alias, we also need to add to the &lt;code&gt;jsconfig.json&lt;/code&gt; paths with the aliases you want to create.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;//svelte.config.js&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;path&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;path&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;kit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;alias&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
            &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@components&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./src/lib/components&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
                    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@lib&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./src/lib&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
                    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@utils&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./src/lib/utils&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
&lt;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;config&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// jsconfig.json&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;compilerOptions&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;baseUrl&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;paths&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
             &lt;span class="c1"&gt;// name and path to aliases&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@components&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;src/lib/components&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@lib&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;src/lib&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@utils&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;src/lib/utils&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;include&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;src/**/*.d.ts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;src/**/*.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;src/**/*.svelte&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Default Starter
&lt;/h2&gt;

&lt;p&gt;To start a new SvelteKit project run &lt;code&gt;npm init svelte@next app-name&lt;/code&gt; into the terminal where you want the folder to live. Change directory into your new app, &lt;code&gt;cd app-name&lt;/code&gt; and run &lt;code&gt;npm i&lt;/code&gt; to install the dependencies. Out of the box SvelteKit provides a &lt;code&gt;$lib&lt;/code&gt; alias setup for the &lt;code&gt;src/lib&lt;/code&gt; folder and a number of modules are available from &lt;code&gt;$app&lt;/code&gt; and &lt;code&gt;$service-worker&lt;/code&gt;. Outside of those, it is up to us to set up our own aliases and preferences on how to use them. These all use the &lt;code&gt;$&lt;/code&gt; syntax to use it, however, we are able to change the lib folder to &lt;code&gt;@&lt;/code&gt; or other symbol if preferred.&lt;/p&gt;

&lt;h2&gt;
  
  
  Change default alias
&lt;/h2&gt;

&lt;p&gt;To update the default &lt;code&gt;$lib&lt;/code&gt; alias to &lt;code&gt;@lib&lt;/code&gt;, we need to tell vite that we want to use it by updating the &lt;code&gt;svelte.config.js&lt;/code&gt; and the alias will work in our application. For the code editor to understand the alias, we need to edit the &lt;code&gt;jsconfig.json&lt;/code&gt; file. Inside the &lt;code&gt;svelte.config.js&lt;/code&gt; by default we see this setup.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="cm"&gt;/** @type {import('@sveltejs/kit').Config} */&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;kit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// hydrate the &amp;lt;div id="svelte"&amp;gt; element in src/app.html&lt;/span&gt;
    &lt;span class="na"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#svelte&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;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inside of the kit property, we need to add a an alias property to hold the aliases we are setting up. I prefer the &lt;code&gt;@&lt;/code&gt; symbol rather than the default &lt;code&gt;$&lt;/code&gt; and will show how to setup the &lt;code&gt;@lib&lt;/code&gt;, &lt;code&gt;@components&lt;/code&gt;, and &lt;code&gt;@utils&lt;/code&gt; aliases. We need to import the included path module from node at the top and add the alias property under the kit property. The new &lt;code&gt;svelte.config.js&lt;/code&gt; will look like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;//svelte.config.js&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;path&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;path&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;kit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;alias&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
            &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@components&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./src/lib/components&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
                    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@lib&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./src/lib&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
                    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@utils&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./src/lib/utils&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
&lt;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;config&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, we also need to set them up inside the &lt;code&gt;jsconfig.json&lt;/code&gt; file. By default that looks like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;compilerOptions&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;baseUrl&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;paths&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// here is the default $lib setup by SvelteKit&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;$lib/*&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;src/lib/*&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;include&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;src/**/*.d.ts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;src/**/*.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;src/**/*.svelte&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, the default &lt;code&gt;$lib&lt;/code&gt; is added to this config already. We need to update that and add the paths for our other two aliases. The updated file will look like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;compilerOptions&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;baseUrl&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;paths&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@components&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;src/lib/components&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@lib&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;src/lib&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@utils&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;src/lib/utils&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;include&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;src/**/*.d.ts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;src/**/*.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;src/**/*.svelte&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Under paths we have added the &lt;code&gt;@components&lt;/code&gt;, updated the &lt;code&gt;$lib&lt;/code&gt; to &lt;code&gt;@lib&lt;/code&gt;, and added &lt;code&gt;@utils&lt;/code&gt; with the corresponding paths.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using the aliases
&lt;/h2&gt;

&lt;p&gt;Now we need to use the aliases inside of a file. The skeleton starter doesn't come with any folders outside of the routes folder for the routes of the application. If you chose this option, you can simply add the &lt;code&gt;lib&lt;/code&gt; folder inside of the &lt;code&gt;src&lt;/code&gt; folder to use the &lt;code&gt;@lib&lt;/code&gt; alias. The other paths and aliases we setup are nested inside the lib folder. Add a &lt;code&gt;components&lt;/code&gt; folder and &lt;code&gt;utils&lt;/code&gt; folder inside of the lib folder. The folder structure should look like this.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Now any files created inside of &lt;code&gt;lib&lt;/code&gt;, &lt;code&gt;components&lt;/code&gt;, or &lt;code&gt;utils&lt;/code&gt; can be imported using the alias rather than having to type out the absolute path, like so.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;FileName&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;@lib/FileName.js`
import ComponentName from &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;components&lt;/span&gt;&lt;span class="sr"&gt;/ComponentName.svelte&lt;/span&gt;&lt;span class="err"&gt;'
&lt;/span&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;UtilName&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;@utils/UtilName.js`
&lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that's it 🥳 now you can use all of the aliases we created or create more of your own. I'm &lt;a href="https://twitter.com/BrittneyPostma"&gt;@brittneypostma&lt;/a&gt; on Twitter if you have more questions or just want to chat about Svelte 😃 Cheers!&lt;/p&gt;

</description>
      <category>svelte</category>
      <category>javascript</category>
      <category>vite</category>
    </item>
    <item>
      <title>CSS Grid Basics and Responsive Web Design Preview</title>
      <dc:creator>Brittney Postma</dc:creator>
      <pubDate>Tue, 10 Nov 2020 13:40:50 +0000</pubDate>
      <link>https://dev.to/brittneypostma/css-grid-basics-and-responsive-web-design-preview-5c7f</link>
      <guid>https://dev.to/brittneypostma/css-grid-basics-and-responsive-web-design-preview-5c7f</guid>
      <description>&lt;h2&gt;
  
  
  Responsive Layouts &amp;amp; Design
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;TLDR&lt;/strong&gt; This post has codepens and interactive content that cannot be added on dev. For the best viewing experience, visit &lt;a href="https://theconsolelogs.com/logs/responsive-web-design" rel="noopener noreferrer"&gt;The Console Logs - Responsive Web Design&lt;/a&gt; or see the full workshop at &lt;a href="https://academy.zerotomastery.io/courses/workshops/lectures/26936743?affcode=441520_gjue7n-1" rel="noopener noreferrer"&gt;ZTM Academy - Responsive Web Design Workshop&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Table of Contents&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Responsive Layouts &amp;amp; Design&lt;/li&gt;
&lt;li&gt;
Basic Design Principles

&lt;ul&gt;
&lt;li&gt;Mobile First Design&lt;/li&gt;
&lt;li&gt;Fluid Grids &amp;amp; Relative Units&lt;/li&gt;
&lt;li&gt;Media Queries&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Flexbox vs Grid&lt;/li&gt;

&lt;li&gt;

Grid Basics

&lt;ul&gt;
&lt;li&gt;Gap&lt;/li&gt;
&lt;li&gt;Placement&lt;/li&gt;
&lt;li&gt;Self&lt;/li&gt;
&lt;li&gt;Explicit Grid&lt;/li&gt;
&lt;li&gt;FR Unit&lt;/li&gt;
&lt;li&gt;Functions&lt;/li&gt;
&lt;li&gt;Fill vs Fit&lt;/li&gt;
&lt;li&gt;Workshop&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;
Hello, I'm Brittney Postma and I am happy to announce that I am joining the other amazing instructors at the &lt;a href="https://academy.zerotomastery.io/p/complete-web-developer-zero-to-mastery?affcode=441520_gjue7n-1" rel="noopener noreferrer"&gt;ZTM Academy&lt;/a&gt;! I did a live workshop on &lt;a href="https://academy.zerotomastery.io/courses/workshops/lectures/26936743?affcode=441520_gjue7n-1" rel="noopener noreferrer"&gt;Responsive Web Design&lt;/a&gt; that is available to all Academy students now! This article previews the workshop and gets you started on creating a beautiful and fluid web page.&lt;/strong&gt;
&lt;/p&gt;



&lt;blockquote&gt;
&lt;p&gt;"Every person, no matter what screen they are on, deserves a great user experience."&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Basic Design Principles
&lt;/h2&gt;

&lt;p&gt;What makes a good design? A good design should attract attention. Make it interesting and have a clear message that is present throughout the design. Have a consistent balance in margins and paddings to allow the eye to flow down the page. Then, when we break the rules (yes, there's a time to break the rules), it really makes a statement. There are 3 basic principles that I follow when creating responsive design. I start with the mobile design of the page, then create fluid grids and use relative units, and then add in media queries to adapt my layouts. &lt;/p&gt;

&lt;h3&gt;
  
  
  Mobile First Design
&lt;/h3&gt;

&lt;p&gt;By starting with the mobile view of a website, we can see what is actually necessary for the design and clutter that needs to be cut out. The layout is usually simpler and allows us to visualize the content at a small scale. Mobile sites also tend to have more usability issues with touch inputs and swiping. By starting with the mobile view, we can address these issues before they become a problem. &lt;/p&gt;

&lt;h3&gt;
  
  
  Fluid Grids &amp;amp; Relative Units
&lt;/h3&gt;

&lt;p&gt;Using modern CSS tools, we can create grids that flow as a screen gets larger. We take advantage of the powers of Flexbox and Grid to their full potential. Along with those, we use relative units throughout our design. Instead of basing everything on the inflexible pixel, we can use a range of units like vw, vh, rems, ems, ch, and percentages that create a fluid page that looks great on any device. &lt;/p&gt;

&lt;h3&gt;
  
  
  Media Queries
&lt;/h3&gt;

&lt;p&gt;There are &lt;strong&gt;far&lt;/strong&gt; too many screen sizes today to worry about creating a design for each screen. With mobile first design, media queries are only used to adapt the layouts. By using a breakpoint only when an element needs to be adapted, rather than the size of the users screen, we reduce the amount of media queries and create a more fluid page. I write all of my base css to style the mobile view of the page and then use a &lt;code&gt;min-width: 768px&lt;/code&gt; and &lt;code&gt;min-width: 1024px&lt;/code&gt; breakpoints to change the grids in certain elements. This means less code I have to write and a more beautiful page. &lt;/p&gt;




&lt;h2&gt;
  
  
  Flexbox vs Grid
&lt;/h2&gt;

&lt;p&gt;A question that keeps getting asked is should I use Flexbox or Grid? The answer is both! We should stop thinking about them as if we are choosing between frameworks like bootstrap or tailwind. Think about the pattern you need for the layout and use them in conjunction with one another. Flexbox is a one-dimensional system, it works either in a column or a row but not both. They are content-first and work well when distributing space and aligning content. Grid is two-dimensional working in both rows and columns. It is layout-first and works well on large scale layouts that aren't linear. Grid also allows you to define areas and the relationship between them. You can even next a grid in a flex container or the other way around. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Which layout method do you use the most?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
a. CSS Grid&lt;br&gt;&lt;br&gt;
b. Flexbox&lt;br&gt;&lt;br&gt;
c. Tables&lt;br&gt;&lt;br&gt;
d. Floats&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Grid Basics
&lt;/h2&gt;

&lt;p&gt;What happens when we put &lt;code&gt;display: grid&lt;/code&gt; on an element? At first glance, it looks like nothing changed. Well, that's because it is shorthand for &lt;code&gt;display: block grid&lt;/code&gt;. There is a lesser used rule, &lt;code&gt;display: inline-grid&lt;/code&gt; that would create an inline grid that is only the width of the content inside of it. Just by using &lt;code&gt;display: grid&lt;/code&gt; on an item makes it a grid container and we get access to all the other grid properties. Plus it makes all of the children grid items that become part of the grid layout. At this point, we just have an &lt;strong&gt;implicit&lt;/strong&gt; grid. To create a layout, we would need to define some columns and rows. By using &lt;code&gt;grid-template-rows&lt;/code&gt; and &lt;code&gt;grid-template-columns&lt;/code&gt; we can explicitly define that layout of the grid we want. Anything that falls outside of that, is still going to follow that implicit grid. Check out the codepen below and uncomment some of the properties to see how the grid changes.&lt;/p&gt;

&lt;p&gt;See the Pen &lt;a href="https://codepen.io/bdesigned/pen/OJXXyvN" rel="noopener noreferrer"&gt;CSS Grid Starter&lt;/a&gt; by bDesigned&lt;br&gt;
  (&lt;a href="https://codepen.io/bdesigned" rel="noopener noreferrer"&gt;@bdesigned&lt;/a&gt;) on &lt;a href="https://codepen.io" rel="noopener noreferrer"&gt;CodePen&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Gap
&lt;/h3&gt;

&lt;p&gt;Gap allows us to define the spacing or gutters between the items. The &lt;code&gt;gap&lt;/code&gt; property, previously &lt;code&gt;grid-gap&lt;/code&gt;, was renamed since it was added to the Flexbox spec as well. It can be defined for both rows and columns with &lt;code&gt;gap&lt;/code&gt; or used as &lt;code&gt;row-gap&lt;/code&gt; and &lt;code&gt;column-gap&lt;/code&gt; to differentiate between the two.&lt;/p&gt;

&lt;h3&gt;
  
  
  Placement
&lt;/h3&gt;

&lt;p&gt;Placement in grid at first glance can seem complicated, but let's break it down. There are two base properties for each axis, &lt;code&gt;justify&lt;/code&gt; and &lt;code&gt;align&lt;/code&gt;, then &lt;code&gt;content&lt;/code&gt; places the container, and &lt;code&gt;items&lt;/code&gt; places each grid item. The &lt;code&gt;justify&lt;/code&gt; property is along the inline axis, or horizontal in grid. The &lt;code&gt;align&lt;/code&gt; property is along the block axis, or vertical in grid. We can then combine &lt;code&gt;justify-content&lt;/code&gt; and &lt;code&gt;justify-items&lt;/code&gt; to place either the grid container or each item along the horizontal axis. Also, &lt;code&gt;align-content&lt;/code&gt; and &lt;code&gt;align-items&lt;/code&gt; can be used to place the container or each item along the vertical axis. Here's a list to visualize it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;◾ &lt;strong&gt;&lt;code&gt;justify-content&lt;/code&gt;&lt;/strong&gt; - places the container along the inline axis, horizontal in grid. Options are start, end, center, stretch, or space-around.&lt;/li&gt;
&lt;li&gt;◾ &lt;strong&gt;&lt;code&gt;justify-item&lt;/code&gt;&lt;/strong&gt; - places each item/child along the inline axis, horizontal in grid. Options are start, end, center, or stretch.&lt;/li&gt;
&lt;li&gt;◾ &lt;strong&gt;&lt;code&gt;align-content&lt;/code&gt;&lt;/strong&gt; - places the container along the block axis, vertical in grid. Options are start, end, center, stretch, or space-around.&lt;/li&gt;
&lt;li&gt;◾ &lt;strong&gt;&lt;code&gt;align-items&lt;/code&gt;&lt;/strong&gt; - places each item/child along the block axis, vertical in grid. Options are start, end, center, or stretch.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want to place the container or items into the same place along both axes, the shortcut &lt;code&gt;place-content&lt;/code&gt; or &lt;code&gt;place-items&lt;/code&gt; can be used. For example, putting &lt;code&gt;place-items: center&lt;/code&gt; on the grid will perfectly center each grid item and &lt;code&gt;place-content: center&lt;/code&gt; would center the container based on the width and the height.&lt;/p&gt;

&lt;h3&gt;
  
  
  Self
&lt;/h3&gt;

&lt;p&gt;Along with placing the entire grid container or the items as a whole, each child or grid item can define where it should be placed in the grid with &lt;code&gt;justify-self&lt;/code&gt; or &lt;code&gt;align-self&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.grid&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;gap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.grid-item&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c"&gt;/* place at the end of the inline/horizontal axis */&lt;/span&gt;
  &lt;span class="py"&gt;justify-self&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c"&gt;/* place at the end of the block/vertical axis */&lt;/span&gt;
  &lt;span class="nl"&gt;align-self&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;end&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;There is also the ability to span a grid item across grid columns or rows.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.col12&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c"&gt;/* span across 12 columns */&lt;/span&gt;
  &lt;span class="nl"&gt;grid-column&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;span&lt;/span&gt; &lt;span class="m"&gt;12&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c"&gt;/* span down 2 rows */&lt;/span&gt;
  &lt;span class="nl"&gt;grid-row&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;span&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.col6&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;grid-column&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;span&lt;/span&gt; &lt;span class="m"&gt;6&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.col4&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;grid-column&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;span&lt;/span&gt; &lt;span class="m"&gt;4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;grid-row&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;span&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.col2&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;grid-column&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;span&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Explicit Grid
&lt;/h3&gt;

&lt;p&gt;Everything we have talked about so far has fallen into the &lt;strong&gt;implicit&lt;/strong&gt; grid, we never defined what we wanted our grid to look like. The properties that do this are &lt;code&gt;grid-template-columns&lt;/code&gt; and &lt;code&gt;grid-template-rows&lt;/code&gt;, or &lt;code&gt;grid-template&lt;/code&gt; is the shortcut with rows / columns as the value. These are declared on the grid container and define what size of and how many columns and rows are wanted. Any unit can be used to define the size of each column and row. These create &lt;strong&gt;tracks&lt;/strong&gt;, the space between two grid lines, &lt;/p&gt;

&lt;h4&gt;
  
  
  FR Unit
&lt;/h4&gt;

&lt;p&gt;Grid also gives us access to another unit only useable in a grid container, the fr unit. The fr unit is short for fractional unit. Each fr unit defined is a fraction of the total size of the parent container. So if we had &lt;code&gt;grid-template-columns: 1fr 2fr 1fr&lt;/code&gt;, the first column is 1/4, the middle column would be 2/4 (or 1/2 reduced), and the last column would be 1/4 of the size. The first and last column would be the same size and the middle column would be double the size of those. &lt;/p&gt;

&lt;h4&gt;
  
  
  Functions
&lt;/h4&gt;

&lt;p&gt;There are functions that are only accessible in grid as well, the &lt;code&gt;repeat()&lt;/code&gt; and &lt;code&gt;minmax()&lt;/code&gt; functions are useable while defining the columns and rows. The &lt;code&gt;repeat(quantity, size)&lt;/code&gt; function takes 2 arguments, the quantity and size for either grid columns or rows. The &lt;code&gt;minmax(min-value, max-value)&lt;/code&gt; function also takes 2 arguments, but allows a minimum value and a maximum value to be defined for the columns and rows. &lt;/p&gt;

&lt;h4&gt;
  
  
  Fill vs Fit
&lt;/h4&gt;

&lt;p&gt;Another concept used only in grid is &lt;code&gt;auto-fill&lt;/code&gt; and &lt;code&gt;auto-fit&lt;/code&gt;. These are used with the &lt;code&gt;repeat()&lt;/code&gt; function and tell the grid algorithm to either automatically fill in more tracks or fit all the grid items across the container. This image shows what happens to the tracks between auto-fit and auto-fill.&lt;/p&gt;

&lt;p&gt;
  &lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fbxok4py813e0zaess5iv.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fbxok4py813e0zaess5iv.jpg" alt="tracks shown for auto-fit and auto-fill"&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;In fact, all of these things can be combined and used together into what is commonly referred to as the &lt;strong&gt;"ram"&lt;/strong&gt; function. That allows us to say either &lt;code&gt;grid-template-columns: repeat(auto-fill, minmax(min-size, max-size))&lt;/code&gt; or &lt;code&gt;grid-template-columns: repeat(auto-fit, minmax(min-size, max-size))&lt;/code&gt; depending on which layout method you want. This can be an extremely powerful function in making a layout responsive in one line of code. Here is a codepen showing auto-fill, auto-fit, and the ram function with auto-fit. Here is a codepen that shows the difference between ram with auto-fit and auto-fill. &lt;/p&gt;

&lt;p&gt;See the Pen &lt;a href="https://codepen.io/bdesigned/pen/NWrrOpJ" rel="noopener noreferrer"&gt;fit, fill, ram&lt;/a&gt; by bDesigned&lt;br&gt;
  (&lt;a href="https://codepen.io/bdesigned" rel="noopener noreferrer"&gt;@bdesigned&lt;/a&gt;) on &lt;a href="https://codepen.io" rel="noopener noreferrer"&gt;CodePen&lt;/a&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  Workshop
&lt;/h3&gt;

&lt;p&gt;Thank you for reading, I really hope this helped clear up any confusion with grid basics. There is so much more that we dive into in the &lt;a href=""&gt;workshop&lt;/a&gt;, creating a full responsive website using these concepts. It is focused on teaching you how to deliver a fluid, consistent design using modern CSS tools and responsive web design best practices. By the end of the workshop, you will be able to make that happen! &lt;/p&gt;

</description>
      <category>responsive</category>
      <category>webdesign</category>
      <category>css</category>
      <category>layouts</category>
    </item>
    <item>
      <title>The CSS Podcast: Episode Four - The Cascade</title>
      <dc:creator>Brittney Postma</dc:creator>
      <pubDate>Mon, 26 Oct 2020 16:43:56 +0000</pubDate>
      <link>https://dev.to/brittneypostma/the-css-podcast-episode-four-the-cascade-4191</link>
      <guid>https://dev.to/brittneypostma/the-css-podcast-episode-four-the-cascade-4191</guid>
      <description>&lt;p&gt;Hi, I'm Brittney and I'm an instructor over at &lt;a href="https://academy.zerotomastery.io/?affcode=441520_gjue7n-1"&gt;ZTM Academy&lt;/a&gt; and the owner, designer, and developer at &lt;a href="//www.bdesigned.dev"&gt;bDesigned&lt;/a&gt;. You can find more dev notes by me at &lt;a href="https://console-logs.netlify.com/"&gt;Console Logs&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://goo.gle/39jAEES"&gt;MDN on Cascade and Inheritance&lt;/a&gt;&lt;br&gt;
&lt;a href="https://goo.gle/2UhqIHV"&gt;CSS Cascade Interactive Article&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The "C" in CSS stands for cascade. Basically, this means that location and order matter when you are writing CSS rules. If rules have the same specificity, the one that is used last in the stylesheet will be used. The cascade is made up of 4 phases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1. &lt;strong&gt;Position&lt;/strong&gt; - The position of a rule with the same specificity in a stylesheet or where it is linked in the html matters. The one that appears last with the most specificity wins. An embedded style tag in the html and inline style are more specific than the stylesheets. You can think about their proximity to the code they are affecting; inline is the closest, then style tag, then linked styles, then browser.&lt;/li&gt;
&lt;li&gt;2. &lt;strong&gt;Origin&lt;/strong&gt; - Where the rules are coming from, 1st link tags, 3rd party link tags, embedded styles, inline-styles, browser (user-agent styles), client set styles&lt;/li&gt;
&lt;li&gt;3. &lt;strong&gt;Specificity&lt;/strong&gt; - user agent, client styles, your styles, your !important, client !important, user-agent !important&lt;/li&gt;
&lt;li&gt;4. &lt;strong&gt;Importance&lt;/strong&gt; - Depends on the type of rule and is in order from least to most specific; normal, animation, !important, transitions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bEUpvpb_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/k8fk0y0xwxqojrz8gk49.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bEUpvpb_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/k8fk0y0xwxqojrz8gk49.png" alt="CSS: Cascade Origin user agent, client styles, your styles, your !important, client !important, user-agent !important"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>cascade</category>
      <category>coding</category>
      <category>style</category>
    </item>
    <item>
      <title>Updated with Hooks How To GraphQL with React Apollo</title>
      <dc:creator>Brittney Postma</dc:creator>
      <pubDate>Wed, 26 Aug 2020 16:35:10 +0000</pubDate>
      <link>https://dev.to/brittneypostma/updated-with-hooks-how-to-graphql-with-react-apollo-12o</link>
      <guid>https://dev.to/brittneypostma/updated-with-hooks-how-to-graphql-with-react-apollo-12o</guid>
      <description>&lt;p&gt;Hi, I'm Brittney and I'm an instructor over at &lt;a href="https://academy.zerotomastery.io/?affcode=441520_gjue7n-1" rel="noopener noreferrer"&gt;ZTM Academy&lt;/a&gt; and the owner, designer, and developer at &lt;a href="//www.bdesigned.dev"&gt;bDesigned&lt;/a&gt;. You can find more dev notes by me at &lt;a href="https://console-logs.netlify.com/" rel="noopener noreferrer"&gt;Console Logs&lt;/a&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  How To GraphQL Updated Tutorial Part 1
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Frontend Setup&lt;/li&gt;
&lt;li&gt;
Into the code

&lt;ul&gt;
&lt;li&gt;index.js&lt;/li&gt;
&lt;li&gt;Server&lt;/li&gt;
&lt;li&gt;Frontend&lt;/li&gt;
&lt;li&gt;GraphQL Query&lt;/li&gt;
&lt;li&gt;Mutations&lt;/li&gt;
&lt;li&gt;React Router&lt;/li&gt;
&lt;li&gt;Header&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;




&lt;p&gt;TLDR: The &lt;a href="https://www.howtographql.com/react-apollo/0-introduction/" rel="noopener noreferrer"&gt;How To GraphQL&lt;/a&gt; with React Apollo is quiet outdated. This is part 1 of the updated hooks version.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frontend Setup
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;1. Create project
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn create react-app hackernews-react-apollo
&lt;span class="nb"&gt;cd &lt;/span&gt;hackernews-react-apollo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;2. Add git origin
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add remote origin URL
git add .
git commit -m 'init fresh repo'
git push --set-upstream origin master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;3. Restructure app
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;src/components src/styles
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;4. Move &lt;code&gt;App.js&lt;/code&gt; into components folder, then move index.css and App.css into styles folder.&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;5. Update imports.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// index.js&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./styles/index.css&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="nx"&gt;App&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;./components/App&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// App.js&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;logo&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;../logo.svg&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../styles/App.css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;6. Add tacheyons to &lt;code&gt;public/index.html&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- public/index.html under other links in head --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"https://unpkg.com/tachyons@4.2.1/css/tachyons.min.css"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;7. Replace CSS in &lt;code&gt;index.css&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* index.css */&lt;/span&gt;
&lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Verdana&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Geneva&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;sans-serif&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;input&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;max-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;500px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.gray&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#828282&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.orange&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#ff6600&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.background-gray&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;rgb&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;246&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;246&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;239&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.f11&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;11px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.w85&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;85%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.button&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;monospace&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10pt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;buttonface&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2px&lt;/span&gt; &lt;span class="m"&gt;6px&lt;/span&gt; &lt;span class="m"&gt;3px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;outset&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;buttonface&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;pointer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;max-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;250px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;8. Add Apollo and GraphQL packages
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn add @apollo/client graphql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it for the setup, we are now ready to start writing some code.&lt;/p&gt;




&lt;h3&gt;
  
  
  Into the code
&lt;/h3&gt;

&lt;h4&gt;
  
  
  index.js
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;1. Add packages to &lt;code&gt;index.js&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;createHttpLink&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;InMemoryCache&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;ApolloClient&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;ApolloProvider&lt;/span&gt;&lt;span class="p"&gt;,&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;@apollo/client&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;2. Create variables to connect ApolloClient.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;httpLink&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createHttpLink&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;http://localhost:4000&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;client&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;ApolloClient&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;link&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;httpLink&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;InMemoryCache&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;3. Change out wrapper component around &lt;code&gt;&amp;lt;App /&amp;gt;&lt;/code&gt; to the Apollo Provider.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ApolloProvider&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/ApolloProvider&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;,
&lt;/span&gt;  &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;root&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Server
&lt;/h4&gt;

&lt;p&gt;The code to download the backend of the server was not correct on the tutorial. In order to get the correct version, I cloned the &lt;a href="https://github.com/howtographql/react-apollo" rel="noopener noreferrer"&gt;React-Apollo Tutorial Repo&lt;/a&gt;. Then, I copied the &lt;strong&gt;server&lt;/strong&gt; folder and pasted it into the root of my project. This will add a directory called server to your application. Inside there are prisma files to connect to the database and inside the src folder is the GraphQL server files. We now need to deploy the Prisma database so the GraphQL server can access it.&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="nb"&gt;cd &lt;/span&gt;server
yarn &lt;span class="nb"&gt;install &lt;/span&gt;prisma1 global
yarn &lt;span class="nb"&gt;install
&lt;/span&gt;prisma1 deploy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After running &lt;strong&gt;&lt;code&gt;prisma1 deploy&lt;/code&gt;&lt;/strong&gt; navigate to Demo server + MySQL database, hit enter and then choose the location closest to you to create your database. Next, we need to run our backend locally. While still in the server directory run &lt;strong&gt;&lt;code&gt;yarn start&lt;/code&gt;&lt;/strong&gt; and leave it running. Now we can run two mutations to check our connection to the database. Navigate to &lt;a href="http://localhost:4000/" rel="noopener noreferrer"&gt;http://localhost:4000/&lt;/a&gt; and paste in the following mutations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight graphql"&gt;&lt;code&gt;&lt;span class="k"&gt;mutation&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;CreatePrismaLink&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="n"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Prisma turns your database into a GraphQL API 😎"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://www.prismagraphql.com"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;mutation&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;CreateApolloLink&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="n"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"The best GraphQL client for React"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://www.apollographql.com/docs/react/"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Press the play button and select each mutation once. It should return an id. If this worked, we can verify the links were added by running the following query.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight graphql"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="n"&gt;feed&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It should return the json data with the id, description, and url of the 2 links.&lt;/p&gt;

&lt;h4&gt;
  
  
  Frontend
&lt;/h4&gt;

&lt;p&gt;Now that the backend is working, we can implement the client side of the application. First, we are going to display a list of &lt;strong&gt;Link&lt;/strong&gt; elements. Inside of the components directory, create a file named &lt;strong&gt;&lt;code&gt;Link.js&lt;/code&gt;&lt;/strong&gt; and add the following code to it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Link&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="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;link&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;link&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;div&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;link&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;description&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; (&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;link&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;url&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;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="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;Link&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a React component that is being passed &lt;strong&gt;props&lt;/strong&gt; and then displaying the links from those props. Now we can create the component that will list the links. Add a new file in the components directory called &lt;strong&gt;&lt;code&gt;LinkList.js&lt;/code&gt;&lt;/strong&gt; and put the following code inside. For now, we will just hard-code some data do display.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Link&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;./Link&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ListLinks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;links&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;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Prisma turns your database into a GraphQL API 😎&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://www.prismagraphql.com&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;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;2&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;The best GraphQL client&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://www.apollographql.com/docs/react/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="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="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;links&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;link&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Link&lt;/span&gt; &lt;span class="na"&gt;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;link&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;link&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;link&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="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="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;ListLinks&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now to see the changes, we need to go to &lt;strong&gt;&lt;code&gt;App.js&lt;/code&gt;&lt;/strong&gt; and change the contents to the following.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;ListLinks&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;./ListLinks&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../styles/App.css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"App"&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;ListLinks&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="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;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now if we run &lt;strong&gt;&lt;code&gt;yarn start&lt;/code&gt;&lt;/strong&gt; from the root directory, we should see the 2 links displayed on the screen.&lt;/p&gt;

&lt;h4&gt;
  
  
  GraphQL Query
&lt;/h4&gt;

&lt;p&gt;Next, we'll need to actually query the database for the links stored so they are dynamic instead of hard-coded in. Head to &lt;strong&gt;&lt;code&gt;LinkList.js&lt;/code&gt;&lt;/strong&gt; and we are going to change a few things.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1. Import new packages
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;gql&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;graphql-tag&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useQuery&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;@apollo/client&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;2. Underneath the imports add in &lt;strong&gt;LINK_QUERY&lt;/strong&gt; and remove hard-coded links.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// export to be used later and create query for links&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;LINK_QUERY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;gql&lt;/span&gt;&lt;span class="s2"&gt;`
{
  feed {
    links {
      id
      url
      description
    }
  }
}
`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;3. Destructure off the &lt;strong&gt;useQuery&lt;/strong&gt; hook and update the return statement.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ListLinks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useQuery&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;LINK_QUERY&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
    &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* IF LOADING */&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;loading&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&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;Fetching...&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="si"&gt;}&lt;/span&gt;
    &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* IF ERROR */&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&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;There was an error fetching the data.&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="si"&gt;}&lt;/span&gt;
    &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* ELSE RETURN DATA FROM QUERY */&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;data&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="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;feed&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;links&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;link&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
          &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Link&lt;/span&gt; &lt;span class="na"&gt;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;link&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;link&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;link&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;)&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;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;/&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;If this worked correctly, we should now have a page that has different states able to be seen on the screen. One while loading, one if there is an error, and the list of links being returned.&lt;/p&gt;

&lt;h4&gt;
  
  
  Mutations
&lt;/h4&gt;

&lt;p&gt;To add new links to our list we need to add a new file in our components folder called &lt;strong&gt;&lt;code&gt;CreateLink.js&lt;/code&gt;&lt;/strong&gt; that includes the following code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;gql&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useMutation&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;@apollo/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;LINK_MUTATION&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;gql&lt;/span&gt;&lt;span class="s2"&gt;`
  mutation PostMutation($description: String!, $url: String!) {
    post(description: $description, url: $url) {
      id
      url
      description
    }
  }
`&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;CreateLink&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;description&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setDescription&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setUrl&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;createLink&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useMutation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;LINK_MUTATION&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;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;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"flex flex-column mt3"&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;input&lt;/span&gt;
          &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"mb2"&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;description&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
          &lt;span class="na"&gt;onChange&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setDescription&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&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;placeholder&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"A description for the link"&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;input&lt;/span&gt;
          &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"mb2"&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;url&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
          &lt;span class="na"&gt;onChange&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setUrl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&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;placeholder&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"The URL for the link"&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;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;
        &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="nf"&gt;createLink&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
            &lt;span class="na"&gt;variables&lt;/span&gt;&lt;span class="p"&gt;:&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;url&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="si"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        Submit
        &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="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="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;CreateLink&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This file includes the import to use gql and the useMutation hook, the GraphQL mutation, and some state to handle updating the url and description of the link. This can be tested by adding the component into &lt;strong&gt;&lt;code&gt;App.js&lt;/code&gt;&lt;/strong&gt; below &lt;strong&gt;&lt;code&gt;&amp;lt;ListLinks /&amp;gt;&lt;/code&gt;&lt;/strong&gt; component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;ListLinks&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;./ListLinks&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;CreateLink&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;./CreateLink&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../styles/App.css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"App"&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;ListLinks&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;CreateLink&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="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;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To actually see the update, the page needs to be refreshed or queried in the playground. To avoid this, we can add in React Router to the application to refresh the page.&lt;/p&gt;

&lt;h4&gt;
  
  
  React Router
&lt;/h4&gt;

&lt;p&gt;Make sure you are in the root directory of the application and run 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;yarn add react-router react-router-dom
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we need to add it to the application in &lt;strong&gt;&lt;code&gt;index.js&lt;/code&gt;&lt;/strong&gt;.Import &lt;strong&gt;&lt;code&gt;react-router-dom&lt;/code&gt;&lt;/strong&gt; and wrap the &lt;strong&gt;&lt;code&gt;ApolloProvider&lt;/code&gt;&lt;/strong&gt; in the router.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;BrowserRouter&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;Router&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-router-dom&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="nx"&gt;ReactDOM&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Router&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;ApolloProvider&lt;/span&gt; &lt;span class="na"&gt;client&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;client&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="nc"&gt;App&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;ApolloProvider&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;Router&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;,&lt;/span&gt;
  &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;root&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Header
&lt;/h4&gt;

&lt;p&gt;Now, lets create a Header component to hold the links. In the components folder create a new file called &lt;strong&gt;&lt;code&gt;Header.js&lt;/code&gt;&lt;/strong&gt;. The following code will import React and the Link component from react-router-dom and display a title and two links.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Link&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-router-dom&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Header&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"flex pa3 justify-between nowrap orange"&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="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"fw7 mr1 black"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Hacker News&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;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;'flex'&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;Link&lt;/span&gt; &lt;span class="na"&gt;to&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"/"&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"ml1 no-underline black"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
          new
          &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Link&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"ml1 white"&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;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Link&lt;/span&gt; &lt;span class="na"&gt;to&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"/create"&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"ml1 no-underline black"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
          submit
          &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Link&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&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;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="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;Header&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To see the header, we need to add it into &lt;strong&gt;&lt;code&gt;App.js&lt;/code&gt;&lt;/strong&gt;. We need to import the &lt;code&gt;Header&lt;/code&gt; and the &lt;code&gt;Switch&lt;/code&gt; and &lt;code&gt;Route&lt;/code&gt; components from &lt;code&gt;react-router-dom&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// add these imports&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;Switch&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Route&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-router-dom&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Header&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;./Header&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="c1"&gt;// update App component to the following&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"center w85"&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;Header&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="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"ph3 pv1 background-gray"&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;Switch&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;Route&lt;/span&gt; &lt;span class="na"&gt;exact&lt;/span&gt; &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"/"&lt;/span&gt; &lt;span class="na"&gt;component&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;ListLinks&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="nc"&gt;Route&lt;/span&gt; &lt;span class="na"&gt;exact&lt;/span&gt; &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"/create"&lt;/span&gt; &lt;span class="na"&gt;component&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;CreateLink&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="nc"&gt;Switch&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;&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Last, we need to update the &lt;strong&gt;&lt;code&gt;CreateLink&lt;/code&gt;&lt;/strong&gt; component so the browser will go back to the list after submitting a new link.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// add useHistory import and query to imports&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;LINK_QUERY&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;./ListLinks&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useHistory&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react-router-dom&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// initiate useHistory inside component&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;history&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useHistory&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// update cached links&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;updateCache&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;currentLinksList&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;readQuery&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;LINK_QUERY&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;updatedLinksList&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;currentLinksList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;feed&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;links&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;post&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="nx"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeQuery&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;LINK_QUERY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;feed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="na"&gt;__typename&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Feed&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;links&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;updatedLinksList&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;count&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;updatedLinksList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// update createLink variable&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;createLink&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useMutation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;LINK_MUTATION&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;onCompleted&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;history&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="na"&gt;onError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;history&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;"&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="nx"&gt;updateCache&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, the list of links and the create new link are on separate pages. You should have a page that looks similar to this.&lt;/p&gt;

&lt;p&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fylsg26def6d8baea9dng.png" class="article-body-image-wrapper"&gt;&lt;img alt="Hackernews Clone Page" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fylsg26def6d8baea9dng.png"&gt;&lt;/a&gt;
&lt;/p&gt;

</description>
      <category>gql</category>
      <category>graphql</category>
      <category>react</category>
      <category>apollo</category>
    </item>
  </channel>
</rss>
