SvelteKit Crash Course

Talk for the Zühlke Client Technology Days 2023 by Lucas Schnüriger

A quick introduction to Svelte and SvelteKit

Agenda

01 History, Origin
02 People & Community
03 Concepts
04 Meta Frameworks
05 SvelteKit Overview
06 SvelteKit in action

History, Origin

Timeline

  • 2016: first release of Svelte by Rich Harris
  • 2019: version 3 brought large changes
  • 2020: SvelteKit announced as replacement for Sapper
  • 2022: Rich Harris gets hired by Vercel to work on Svelte
  • 2022: official SvelteKit 1.0 release in December

People & Community

Rich Harris

Rich Harris

  • creator of Ractive.js, Rollup and Svelte
  • worked at The Guardian and The New York Times
  • now at Vercel, working on Svelte full-time

Core Maintainers

There are now nearly 30 core maintainers working on Svelte in different capacities and areas (list as of January 2022).

Group selfie of some of the Svelte core maintainers in 2022
Some of the core members at Svelte Summit Fall 2022

Svelte + Vercel ▲

3 of the core members work at Vercel:

  • Rich Harris
  • Simon Holthausen (author of «Svelte: A Beginner's Guide»)
  • Dominic Gannaway (ex-React core member, Inferno, Lexical)

Contrary to Next.js, Svelte is not owned by Vercel or any company.

Some work is financed with donations through Open Collective.

Svelte Society Logo

Community

The community is smaller in comparison but very well organised.

A lot of activity is based around «Svelte Society».

Among the events is the biannual Svelte Summit conference.

Smaller talks and events are regularly held on their YouTube channel and in the official Svelte Discord server.

Svelte Sirens focus on supporting women and non-binary people.

Concepts

Key Concepts of Svelte

  • compiled to optimised vanilla JS, no runtime library
  • single-file components, with scoped CSS
  • syntax close to the native web (HTML, CSS, JS)
  • easy reactivity and state management
  • little to no boilerplate code

Svelte is often called

«the framework that disappears»

Example


        

        

        
      

Syntax

Svelte is a superset of the «web»:

  • extends HTML by adding JS expressions (curly braces)
  • extends CSS by adding scoping mechanisms
  • extends JS by making reactivity a language primitive

Fun fact: an empty *.svelte file is already a valid Svelte component.

Technically, one could argue:

Svelte is a language, not a framework

Meta Frameworks

Examples

a.k.a. «JavaScript full-stack frameworks».

What makes them «meta» is that they include other frameworks:

  • Next.js and Remix are built on top of React
  • Nuxt combines these concepts with Vue
  • SolidStart uses SolidJS
  • Astro is even framework-agnostic and allows integration with a whole range of technologies
  • SvelteKit is the official way to build Svelte apps

Typical Features

  • routing and layouting
  • Static Site Generation (SSG) and Server Side Rendering (SSR)
  • data fetching, server endpoints
  • sensible configuration defaults (zero config)

Use Cases

SSG/SSR are a major selling point for SEO and performance.

But you can easily build single-page applications (SPA) with them and still benefit from other advantages.

My 🔥? take: meta frameworks should be the default in most cases.

SvelteKit is the default way to create Svelte apps now. You don't get any additional complexity or difficulty if you don't need advanced features.

SvelteKit

Features

  • mix and matching rendering methods for each page
  • accessible client-side routing with automatic preloading
  • filesystem-based routes with nested layouts
  • environment variable handling
  • type-safe data loading
  • built-in form actions that work with or without JS
  • automatic CSRF protection
  • can be used for libraries as well as web apps
  • deploy anywhere with adapters

SvelteKit Demo app:

LineUpr clone

Sources & Resources

Sources

Additional Resources

Thank you for listening!

I'm always happy to answer questions regarding Svelte.