> Canonical URL: https://codingcat.dev/post/lets-learn-svelte

# Let's Learn Svelte

✏️ Blog PostJune 1, 2022[![](/logos/tags/svelte-symbol-light.svg)![](/logos/tags/svelte-symbol-dark.svg)Svelte](/topic/svelte)[![](/logos/tags/javascript-symbol-light.svg)![](/logos/tags/javascript-symbol-dark.svg)JavaScript](/topic/javascript)[![](/logos/tags/css-symbol-light.svg)![](/logos/tags/css-symbol-dark.svg)CSS](/topic/css)[![](/logos/tags/github-symbol-light.svg)![](/logos/tags/github-symbol-dark.svg)GitHub](/topic/github)[![](/logos/tags/html-symbol-light.svg)![](/logos/tags/html-symbol-dark.svg)HTML](/topic/html)[#Serverless](/topic/serverless)[![](/logos/tags/auth0-symbol-light.svg)![](/logos/tags/auth0-symbol-dark.svg)Auth0](/topic/auth0)[![](/logos/tags/sveltekit-symbol-light.svg)![](/logos/tags/sveltekit-symbol-dark.svg)SvelteKit](/topic/sveltekit)

# Let's Learn Svelte

![](https://cdn.sanity.io/media-libraries/mlttp0BZbCpV/images/df234899a342359c323e924fd218f8c83b377f79-1920x1080.png?w=1920&h=1080&q=82&fit=max&auto=format)[@CodingCatDev62.5K / 100K Subscribers Goal](https://www.youtube.com/@codingcatdev?sub_confirmation=1)[Subscribe on YouTube→](https://www.youtube.com/@codingcatdev?sub_confirmation=1)[Watch on YouTube App ↗](https://www.youtube.com/watch?v=fOD_3iSiwTQ&list=UUnKZ8gEb78zXKMi1ns-IQ2g)[![Alex Patterson](https://cdn.sanity.io/media-libraries/mlttp0BZbCpV/images/a606dfaa381aab08ddbe16a33fe1d3e1fb37c927-400x400.jpg?w=96&h=96&q=82&fit=max&auto=format)Alex Patterson](/author/alex-patterson)

Learn how to build modern web applications with SvelteKit, a quickly growing framework for generating static web pages (SSG) as well as Server Side Rendered content (SSR). In this crash course, you'll learn all the basics including file-based routing, API routes, dynamic routes, global and scoped CSS, and much more!

## Source Code

[https://github.com/brittneypostma/sveltekit-starter](https://github.com/brittneypostma/sveltekit-starter)

## What is Svelte?

- Svelte is a component framework that allows you to break up your application into reusable chunks.
- Svelte is similar to React & Vue, with one key difference, no virtual DOM. Instead of letting the browser do the work, Svelte compiles itself away during the build process into vanilla html, css, and javascript.
- Easy global state management with Svelte stores.

## Why SvelteKit?

- The goal with SvelteKit is to have a single recommended path for building everything from high performing web apps to static blog pages.
- With SvelteKit we get file-system based routing, optional rendering (SSR & SSG), code-splitting, CSS scoping by default, the ability to completely disable JavaScript and more.

## Getting Started with a new SvelteKit app

Copied! 🐾

```
npm create svelte
```

> At the time of recording, SvelteKit is in a release candidate phase, which means there are no more planned breaking changes.

Here we create a skeleton project without the TypeScript, ESLint, or Prettier configurations.

Copied! 🐾

```
cd my-app
npm install
npm run dev -- --open
```

### Aliases

SvelteKit with Vite provides the ability to setup aliases to folders within your app to make it easier to path to different areas. I have an [article](/post/make-pathing-easier-with-aliases-in-sveltekit) on how to set those up if you want to learn more.

Create the `lib` folder within the `src` folder and add a new file, `header.svelte` to it. Inside `header.svelte`, we are going to add a navigation bar for the site.

Copied! 🐾

```

- [Home](/)

- [About](/about)

- [Blog](/blog)

```

Now we need to create the routes that go to these respective links.

## Routes

Inside the routes folder, we already have an `+page.svelte` file that matches to the home or `/` route. We need to add the `/about` route by creating a new folder named `about` and a new file inside `+page.svelte`. We will add the `/blog` route later since it is a *dynamic* route.

## Layout

We don't want to have to copy and paste our header onto each page. SvelteKit provides a wrapper file named `+layout.svelte` that will wrap the entire application in whatever is in that file. Inside of the routes folder, create a new file named `+layout.svelte` and your app will disappear off your screen if you are running the dev server. This is because Svelte needs a `` component to know where to insert the child content to. Add this code to your `+layout.svelte` file to see the header and content on the page.

Copied! 🐾