Fireship · @fireship

Svelte 3 Reaction & QuickStart Tutorial

Uploaded April 25, 2019 · Length 14:46

Svelte 3 Reaction & QuickStart Tutorial

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.

  1. 0:00

    just when I discovered the meaning of

  2. 0:02

    life they changed one of my favorite

  3. 0:05

    things about JavaScript is that the

  4. 0:06

    status quo never seems to last very long

  5. 0:08

    react angular and view have dominated

  6. 0:10

    the mind share of developers over the

  7. 0:11

    last few years

  8. 0:12

    salt has been around for a while but

  9. 0:14

    they just released version three last

  10. 0:15

    week and my initial experience with it

  11. 0:17

    has been very positive and that's mostly

  12. 0:19

    because it empowers you to solve

  13. 0:20

    problems with less code in the first

  14. 0:22

    half of this video we'll cover the basic

  15. 0:24

    concepts in spelt and in the process

  16. 0:25

    you'll see why it's such an awesome tool

  17. 0:27

    in the second half of the video we'll

  18. 0:28

    build a real-time to-do list with spelt

  19. 0:30

    and firebase from scratch if you're new

  20. 0:32

    here like and subscribe and you can find

  21. 0:33

    the full source code on fire ship IO now

  22. 0:36

    before you jump into spelt I'd recommend

  23. 0:37

    watching this talk from its creator rich

  24. 0:39

    harris that's what really got me excited

  25. 0:41

    to start learning spell 3 let's go ahead

  26. 0:43

    and just jump right into things will run

  27. 0:44

    npx dig it and then point to these felt

  28. 0:47

    j s template this is the equivalent to

  29. 0:48

    create react app or ng new go ahead and

  30. 0:51

    open it up in vs code and run npm

  31. 0:52

    install then you can run npm dev to

  32. 0:54

    serve it locally and that should give

  33. 0:56

    you this hello world on localhost 5000

  34. 0:58

    the first thing you'll see is the roll

  35. 0:59

    up config dot j s this is what bundles

  36. 1:02

    your code and it's an alternative to web

  37. 1:03

    pack personally i prefer to use roll-up

  38. 1:05

    but you can also use webpack here if you

  39. 1:07

    want and while we're talking about

  40. 1:08

    bundling there's two things you should

  41. 1:09

    know and that's that spelt supports

  42. 1:11

    server-side rendering as well as native

  43. 1:13

    web components or custom elements so

  44. 1:15

    that's cool but so far this might just

  45. 1:16

    look like another JavaScript framework

  46. 1:18

    but if we go into the package.json we

  47. 1:20

    can see that something's different here

  48. 1:21

    what's missing is dependencies we only

  49. 1:24

    have development dependencies and that's

  50. 1:25

    because spelt is a compiler it generates

  51. 1:28

    all of your code at Build time which

  52. 1:29

    means it doesn't need to include the

  53. 1:30

    framework itself as a hard dependency in

  54. 1:32

    your JavaScript bundle another framework

  55. 1:34

    that also does this is stencil j/s and I

  56. 1:36

    feel like this approach makes a lot more

  57. 1:38

    sense than the current status quo and

  58. 1:40

    that's because you only need to compile

  59. 1:41

    the JavaScript from the framework that

  60. 1:42

    you actually need so you don't have any

  61. 1:44

    extra bloat in your JavaScript bundle

  62. 1:46

    what I'm doing right now is just

  63. 1:47

    exporting our entire app as a string and

  64. 1:49

    if we go to the bundled output you can

  65. 1:51

    see that it's just a function that

  66. 1:52

    returns a string so in theory this

  67. 1:54

    should result in smaller bundle sizes or

  68. 1:56

    at least bundles that are optimized for

  69. 1:57

    the code that you actually use if you're

  70. 1:59

    using tree shakable libraries that's