Apparently I Don't Understand Svelte...

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ต.ค. 2024

ความคิดเห็น • 38

  • @engageintellect
    @engageintellect ปีที่แล้ว +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.

  • @kitastro
    @kitastro ปีที่แล้ว +2

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

  • @lazyh0rse
    @lazyh0rse ปีที่แล้ว +4

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

  • @phoenixshell3772
    @phoenixshell3772 2 หลายเดือนก่อน +1

    This is the one gripe I have with using Sveletekit. As someone new to sveletekit its not really clear what code runs server or client-side. This is especially due to security reasons, some code you want definitely don't want to run on client and it could cause state issues if you think you are on client but it turns out it's server. Not to mention some libraries assume you are running a SPA as well. Whish they would be more clear with maybe a Macro or something

    • @bmdavis419
      @bmdavis419  2 หลายเดือนก่อน

      Yea it definitely has a learning curve. It gives you a lot of power, but u really do have to know what you are doing. Some better debugging tools would be extremely helpful to see exactly what is rendered when/where

  • @Glitch-txs
    @Glitch-txs 9 หลายเดือนก่อน

    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

  • @SzaboB33
    @SzaboB33 ปีที่แล้ว +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

  • @peepeepoo3432
    @peepeepoo3432 ปีที่แล้ว +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.

  • @gyanaranjan6526
    @gyanaranjan6526 ปีที่แล้ว +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

  • @dom8429
    @dom8429 9 หลายเดือนก่อน +1

    this was really helpful! thank you

  • @JorgeMartinez-xb2ks
    @JorgeMartinez-xb2ks ปีที่แล้ว +1

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

  • @Adanjakub
    @Adanjakub ปีที่แล้ว +2

    thank you Ben

  • @SRG-Learn-Code
    @SRG-Learn-Code ปีที่แล้ว +1

    That's a great gotcha! Thanks for sharing.

  • @jimjones26
    @jimjones26 ปีที่แล้ว +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  ปีที่แล้ว

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

  • @BorisBarroso
    @BorisBarroso ปีที่แล้ว +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  ปีที่แล้ว +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 11 หลายเดือนก่อน

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

  • @Beyram1501
    @Beyram1501 ปีที่แล้ว +4

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

    • @bmdavis419
      @bmdavis419  ปีที่แล้ว

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

    • @scottserage9022
      @scottserage9022 ปีที่แล้ว +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.

  • @joan_ferre
    @joan_ferre ปีที่แล้ว +5

    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  ปีที่แล้ว +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 ปีที่แล้ว

      I miss the log outputs!

  • @tomich20
    @tomich20 ปีที่แล้ว

    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?

  • @codefork94
    @codefork94 ปีที่แล้ว +1

    Great video and well explained!

  • @JohnnyUtah269
    @JohnnyUtah269 ปีที่แล้ว +1

    Great hook

  • @quelchx
    @quelchx ปีที่แล้ว +1

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

    • @bmdavis419
      @bmdavis419  ปีที่แล้ว

      It can be either which is interesting

    • @quelchx
      @quelchx ปีที่แล้ว

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

    • @shubhambhattacharjee1111
      @shubhambhattacharjee1111 11 หลายเดือนก่อน +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.

  • @babakfp
    @babakfp ปีที่แล้ว

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

    • @bmdavis419
      @bmdavis419  ปีที่แล้ว

      Its part of an upcoming video!

  • @adamtak3128
    @adamtak3128 ปีที่แล้ว

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

    • @bmdavis419
      @bmdavis419  ปีที่แล้ว

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