Hello World: Svelte

Get a brief introduction to Svelte, and learn how it can be a better choice over existing front-end frameworks.

We'll cover the following...

Before we start working with Svelte, let's discuss some of its core features and how it differs from other frameworks. Let's start with the same example from a previous lesson:

import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [svelte()],
  build: {
    outDir: 'build'
  }
})
Output variables in templates

Each Svelte component can have three different core elements:

  • A script tag that describes the lifecycle and functionality of the component.

  • The template, which is made up of HTML. We can write any HTML tags here or even reference other Svelte components, which we'll look at how to do in later lessons. We can output ...