Fireship · @fireship
Svelte 3 Reaction & QuickStart Tutorial
Uploaded April 25, 2019 · Length 14:46
Summary
Svelte 3 tutorial covering its unique approach to bundling, reactivity, and templating, with a hands-on example of building a real-time to-do list.
- svelte 3 tutorial
- javascript framework
- reactivity in svelte
- svelte templating
- server-side rendering
- native web components
- compiler-based framework
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
just when I discovered the meaning of
- 0:02
life they changed one of my favorite
- 0:05
things about JavaScript is that the
- 0:06
status quo never seems to last very long
- 0:08
react angular and view have dominated
- 0:10
the mind share of developers over the
- 0:11
last few years
- 0:12
salt has been around for a while but
- 0:14
they just released version three last
- 0:15
week and my initial experience with it
- 0:17
has been very positive and that's mostly
- 0:19
because it empowers you to solve
- 0:20
problems with less code in the first
- 0:22
half of this video we'll cover the basic
- 0:24
concepts in spelt and in the process
- 0:25
you'll see why it's such an awesome tool
- 0:27
in the second half of the video we'll
- 0:28
build a real-time to-do list with spelt
- 0:30
and firebase from scratch if you're new
- 0:32
here like and subscribe and you can find
- 0:33
the full source code on fire ship IO now
- 0:36
before you jump into spelt I'd recommend
- 0:37
watching this talk from its creator rich
- 0:39
harris that's what really got me excited
- 0:41
to start learning spell 3 let's go ahead
- 0:43
and just jump right into things will run
- 0:44
npx dig it and then point to these felt
- 0:47
j s template this is the equivalent to
- 0:48
create react app or ng new go ahead and
- 0:51
open it up in vs code and run npm
- 0:52
install then you can run npm dev to
- 0:54
serve it locally and that should give
- 0:56
you this hello world on localhost 5000
- 0:58
the first thing you'll see is the roll
- 0:59
up config dot j s this is what bundles
- 1:02
your code and it's an alternative to web
- 1:03
pack personally i prefer to use roll-up
- 1:05
but you can also use webpack here if you
- 1:07
want and while we're talking about
- 1:08
bundling there's two things you should
- 1:09
know and that's that spelt supports
- 1:11
server-side rendering as well as native
- 1:13
web components or custom elements so
- 1:15
that's cool but so far this might just
- 1:16
look like another JavaScript framework
- 1:18
but if we go into the package.json we
- 1:20
can see that something's different here
- 1:21
what's missing is dependencies we only
- 1:24
have development dependencies and that's
- 1:25
because spelt is a compiler it generates
- 1:28
all of your code at Build time which
- 1:29
means it doesn't need to include the
- 1:30
framework itself as a hard dependency in
- 1:32
your JavaScript bundle another framework
- 1:34
that also does this is stencil j/s and I
- 1:36
feel like this approach makes a lot more
- 1:38
sense than the current status quo and
- 1:40
that's because you only need to compile
- 1:41
the JavaScript from the framework that
- 1:42
you actually need so you don't have any
- 1:44
extra bloat in your JavaScript bundle
- 1:46
what I'm doing right now is just
- 1:47
exporting our entire app as a string and
- 1:49
if we go to the bundled output you can
- 1:51
see that it's just a function that
- 1:52
returns a string so in theory this
- 1:54
should result in smaller bundle sizes or
- 1:56
at least bundles that are optimized for
- 1:57
the code that you actually use if you're
- 1:59
using tree shakable libraries that's


