Apparently I Don't Understand Svelte...

Поделиться
HTML-код
  • Опубликовано: 7 июн 2024
  • When working with SvelteKit I always assumed that my "+page.svelte" would always just be run on the client. I. Was. Wrong.
    CHECKOUT THE SVELTEKIT TUTORIAL: learn.svelte.dev/tutorial/pag...
    JOIN THE DISCORD: / discord
    my stuff
    twitter (x): / benjamin41902
    timestamps
    intro 0:00
    ssr 0:45
    csr 6:45
    #webdev #svelte
  • НаукаНаука

Комментарии • 36

  • @engageintellect
    @engageintellect 9 месяцев назад +20

    So stoked to see you continuing to dig in to svelte/sveltekit. It’s painful every time I have to go back to react now that I’m so comfortable with how svelte works. It just makes sense.

  • @lazyh0rse
    @lazyh0rse 9 месяцев назад +4

    I'm using sveltekit for 6 weeks now, and this is new to me. Thanks for pointing this out.

  • @tomich20
    @tomich20 8 месяцев назад

    Awesome video! Question please!!!: if i have an API with express, and i use SvelteKIT as an SPA, are there any BENEFITS to use the node adapter and run a new node script on my server, instead of using the static adapter in my regular VPS with apache?

  • @dom8429
    @dom8429 5 месяцев назад +1

    this was really helpful! thank you

  • @joan_ferre
    @joan_ferre 9 месяцев назад +4

    Great video. Consider watching it yourself to see where your editing fails.
    You are repeating yourself and the user can’t see the console log because of your cam.
    Thanks for making the video, I learned a lot!

    • @bmdavis419
      @bmdavis419  9 месяцев назад +1

      Yea I completely missed a cut toward the end, but by the time I found it it was uploaded and with my internet I figure its not the end of the world lol

    • @r-i-ch
      @r-i-ch 9 месяцев назад

      I miss the log outputs!

  • @peepeepoo3432
    @peepeepoo3432 9 месяцев назад +1

    i would point out that this is the same gotcha with every ssr framework. in remix and nextjs code inside the component does run on the server too so top-level console logs are visible. the only code that doesn't get ran in react is code inside a useEffect, which is more or less the same as onMount for svelte.

  • @codefork94
    @codefork94 9 месяцев назад +1

    Great video and well explained!

  • @BorisBarroso
    @BorisBarroso 9 месяцев назад +2

    That is really great to know. SvelteKit is more complicated then I expected but I really like it. Would you make a tutorial migrating a project from nodejs to bun?

    • @bmdavis419
      @bmdavis419  9 месяцев назад +5

      Probably will at some point, but it is SUPER easy, litterally just delete your node modules, delete your lock file, run bun install, and its done. THATS IT, bun is dope lol

    • @shubhambhattacharjee1111
      @shubhambhattacharjee1111 7 месяцев назад

      ​@@bmdavis419Bun seems to be what I wanted deno to be.

  • @Glitch-txs
    @Glitch-txs 5 месяцев назад

    Small comment, fetching data outside onMount function while having SSR disabled might be better in some cases since onMount function adds a little bit of delay, (it won't trigger the callback until the component is mounted on the DOM) similar to what useEffect does

  • @Adanjakub
    @Adanjakub 9 месяцев назад +2

    thank you Ben

  • @jimjones26
    @jimjones26 9 месяцев назад +1

    Does this concept effect anything in your SvelteKit and Supabase Deep Dive video? I am going through that video now and was wondering.

    • @bmdavis419
      @bmdavis419  9 месяцев назад

      Nope, just what I said at the beginning where I said +page.svelte is client side which is only partly true

  • @JorgeMartinez-xb2ks
    @JorgeMartinez-xb2ks 8 месяцев назад +1

    I´ve had the same feeling, thanks for the video.

  • @SRG-Learn-Code
    @SRG-Learn-Code 9 месяцев назад +1

    That's a great gotcha! Thanks for sharing.

  • @adamtak3128
    @adamtak3128 9 месяцев назад

    awesome video as always. brother, what theme, font and icons are you using for vscode?

    • @bmdavis419
      @bmdavis419  9 месяцев назад

      Github theme, jetbrains mono font, no clue on the icons, I think default

  • @SzaboB33
    @SzaboB33 9 месяцев назад +1

    37s into the video but I learned it the hard way with client side libraries not working and I needed to import them in an onMount :D

  • @babakfp
    @babakfp 9 месяцев назад

    Link to the stream video? (the black and white video)

    • @bmdavis419
      @bmdavis419  9 месяцев назад

      Its part of an upcoming video!

  • @gyanaranjan6526
    @gyanaranjan6526 9 месяцев назад +1

    I probably knew it cause sveltekit is like next js every page.tsx will be server rendered unless you mention 'use client' on top

  • @JohnnyUtah269
    @JohnnyUtah269 9 месяцев назад +1

    Great hook

  • @kitastro
    @kitastro 8 месяцев назад +2

    export const ssr = false // ;) You are welcome

  • @quelchx
    @quelchx 9 месяцев назад +1

    When I first started using SK I thought (for some reason) it was a MPA not a SPA.

    • @bmdavis419
      @bmdavis419  9 месяцев назад

      It can be either which is interesting

    • @quelchx
      @quelchx 9 месяцев назад

      @@bmdavis419 ooo... I'd have to look into this.

    • @shubhambhattacharjee1111
      @shubhambhattacharjee1111 7 месяцев назад +1

      It's actually hybrid of the two. It by default technically is MPA, but as soon as js loads it becomes SPA. If you build you sites properly, for those with poor internet (thus not being able to load js) or those having js disabled it'd be MPA, while for normal users it'd be SPA.
      Also as mentioned here certain routes can be only server rendered, with no js shipped, which will make those pages act more like MPA while the pages having client render will be a combination of MPA and SPA, and the one's having only client render will be SPA.
      It's really interesting and sveltekit handles it very well. That's why you also have use:enhance, it's to make the client side experience even more SPA like while not completely disabling MPA.

  • @Beyram1501
    @Beyram1501 9 месяцев назад +4

    Did you think a server can call itself as an api route?? 😂

    • @bmdavis419
      @bmdavis419  9 месяцев назад

      I mean, you could maybe find a way, but I would just call the same function in both places

    • @scottserage9022
      @scottserage9022 9 месяцев назад +3

      There are frameworks/libraries that do something similar to this, at least in concept. FeathersJS exposes its services as routes but they can also be called internally by other services. It's not as ridiculous as you are making it out to be to misunderstand how Svelte works.