Scott Teaches Wes Svelte and Sapper

May 20, 2020, 1 p.m. (3 years, 10 months ago)
0 Comments

In this episode of Syntax, Scott teaches Wes about Svelte and Sapper — general premise, best practices, and more!

Sanity - Sponsor

Sanity.io is a real-time headless CMS with a fully customizable Content Studio built in React. Get a Sanity powered site up and running in minutes at sanity.io/create. Get an awesome supercharged free developer plan on sanity.io/syntax.

Stackbit - Sponsor

Stackbit offers developers tools that enable things like inline content editing, live previewing of content changes, and collaboration features on your Jamstack site, without code changes. That's why Stackbit is the best way to Jamstack. stackbit.com

Show Notes

03:14 - General premise

  • Sapper compiles away, removing framework code from build
  • Component & Props based
  • Easy reactivity
  • Built-in tools like animation
  • Template-based

07:57 - Svelte 101

  • .svelte files
  • Files can include , , and straight-up CSS
  • Variables are used in templates via {var} - even works
  • Import component and use just like React and Vue

10:49 - Stylin’

  • All styles are scoped by default
  • global() to wrap around global declarations
  • Language type sass to use sass

12:22 - Reactivity

  • Baked in
    • let count = 0
    • count = count + 1 will reactively update in template
    • variables are essentially state
    • $: double = count + 2 - to create a reactive variable that updates when another variable updates
    • $: console.log(count) = will run whenever count is update a-la useEffect
    • $: if (count >10) = same… reactive if
    •  updates let name in script

15:55 - Props

  • Same was React, but need to be exported before they can be used
  • Seems counterintuitive, but you get over it quickly
  • EZ defaults export let answer = 'a mystery';
import Nested from './Nested.svelte'; export let answer = 'a mystery';

The answer is {answer}

20:08 - Template logic

  • If statements {#if user._id} {/if}

  • Loops {#each cats as kittens}

  • Promise tags

{#await promise}

...waiting

{:then number}

The number is {number}

{:catch error}

{error.message}

{/await}

23:12 - Events

  • On directive
  • Functions can also be inline
  • Modifiers
Click me

26:11 - Baked-in goodies

  • Animation
  • Dimensions
{text}
  • Lifecycle methods
  • Advanced State Via Stores
    • A store is simply an object with a subscribe method that allows interested parties to be notified whenever the store value changes.
  • import { writable } from ‘svelte/store’;
  • export const count = writable(0);
  • count.update(0)
  • Slots
  • React helmet like stuff, ie

36:39 - Sapper

  • Similar to Next.js
  • Folder routes
  • Static export with all of the good stuff like service workers and preloading
Links ××× SIIIIICK ××× PIIIICKS ××× Shameless Plugs Tweet us your tasty treats!
Login to Add New Comment
No comments have been posted yet, be the first one to comment.
Similar Podcasts
What the EU's GDPR Means to Web Developers What the EU's GDPR Means to Web Developers
In this episode we have Andrew Fairlie from Mutual to discuss the new European Union General Data Protection Regulation aka the GDPR. We discuss what the GDPR means specifically to web designers and developers both in terms of the work we do, and the work proposals we draft. We discuss the GDPR fro...
Spelunking into the VueJS Frontend JavaScript Framework Spelunking into the VueJS Frontend JavaScript Framework
On this episode, we talk with special guest Adam Wathan about the VueJS JavaScript framework. We talk about what VueJS is, and how its Laissez-faire approach lets you pick and choose how much of it makes sense to use in a project. We go into why using a framework like VueJS can help you write bette...
JAMstack development, carpe JavaScript! JAMstack development, carpe JavaScript!
On this episode, we’re joined by Paulo Elias from IDEO to discuss JAMstack: Modern web development architecture based on client-side JavaScript, reusable APIs, and prebuilt Markup. Paulo talks about his journey from doing traditional LAMP/LEMP stack work to building things using JavaScript as the h...
Leveraging Laravel for Truly Custom Projects Leveraging Laravel for Truly Custom Projects
In this episode, we talk to Phil Zaengle from Zaengle Corp about leveraging the PHP framework Laravel to build truly custom web applications. We discuss when a CMS like Craft makes sense, and when it makes sense to utilize Laravel in addition to or instead of a CMS. We go on to discuss the importan...
CSS & CMS Musings with Eric Meyer CSS & CMS Musings with Eric Meyer
On this episode we have on the CSS legend Eric Meyer to talk about the early days of CSS, and how it almost died, and also onto where CSS is today. We discuss utility-first CSS, CSS in JavaScript, and talk about the Flexbox and the awesomeness that is CSS Grid. We then also talk about the move of E...
Similar Tutorials
How to Install Deno on macOS
How to Install Deno on macOS
Deno is a simple, modern and secure runtime for JavaScript and TypeScript, by the creator of Node.js himself, Ryan Dahl. Deno uses the Chrome v8 engine and is built with Rust. The project just reach version 1.0 and got many people in the JavaScript community interested. In this tutori...
How to Build a Movie Database & API with Strapi
How to Build a Movie Database & API with Strapi
Strapi is an awesome headless CMS built with Node.js that can speed up the process of building an API quiet dramatically. It's perfect for people who enjoy the frontend more than the backend, and it allows you to build complex database structures with out writing any code. Magic, if y...
How to Verify Your Svelte/Sapper Application With Google Search Console
How to Verify Your Svelte/Sapper Application With Google Search Console
Google Search Console is one of those must have tools to get a better understanding of your Google Search Engine rankings are discoverability. So in today's tutorial I will show you how to verify your Svelte / Sapper application with Google Search Console. The process should be fairly...