SvelteKit and Supabase Deep Dive

Sdílet
Vložit
  • čas přidán 4. 06. 2024
  • Today we are going deep into a project build with SvelteKit and Supabase. This video does NOT focus on syntax or anything like that, but is rather a more conceptual breakdown to help you understand all of the things that make this app work. I would love feedback on what you guys think of this style of breakdown, if me writing the code as I go or focusing more on syntax would help please let me know!
    PROJECT REPO: github.com/bmdavis419/encelad...
    JOIN THE DISCORD: / discord
    USEFUL DOCS I HIGHLY RECOMMEND
    Sveltekit Routing: kit.svelte.dev/docs/routing
    Sveltekit Data Loading: kit.svelte.dev/docs/load
    Supabase CLI (VERY IMPORTANT): supabase.com/docs/guides/cli/...
    Supabase GitHub Auth: supabase.com/docs/guides/auth...
    Supabase & Sveltekit: supabase.com/docs/guides/auth...
    my stuff
    twitter (X): / benjamin41902
    insiderviz: www.insiderviz.com
    timestamps
    0:00 intro
    1:35 client/server discussion
    2:55 sveltekit files discussion
    14:03 supabase intro
    16:15 app intro
    18:50 database migrations
    25:20 drizzle setup
    28:00 auth
    36:30 profile creation
    39:10 generate image
    46:20 image details page
    50:30 outro
    #sveltejs #supabase #webdev
  • Věda a technologie

Komentáře • 104

  • @bmdavis419
    @bmdavis419  Před 9 měsíci +18

    Like I said I would love your thoughts on this format! I apologize this took so long to get out, I have been bed ridden with covid for the last week or so (I was just starting to come down with it while shooting this video lol). Also make sure to join the discord if you have questions, that is the best place for discussion, it is really hard to track back and forth replies in the comments on my end!

    • @greendsnow
      @greendsnow Před 9 měsíci

      Hey there, may I learn why you didn't choose a framework like pocketbase, a lot more concurrency, rps and size capacity?

    • @vladimirjaksic5883
      @vladimirjaksic5883 Před 9 měsíci

      It's awesome. It's always nice to see when anyone is trying to break down some architecture stuff and tech stack. Always a plenty to learn. It is packed with a lots of info, and delivered in relatively short amount of time. There is a repo with code to follow up for sure. Thank you for putting an effort!

    • @SRG-Learn-Code
      @SRG-Learn-Code Před 9 měsíci

      ​@@greendsnow For me is that PB doesn't offer hosting right away, also I want to learn about edge functions and that is not provided yet. But mainly, pocketbase is not v1 yet. I'll keep an eye on it as I think it's quite promising, but is a smaller project, maybe that's good and in the end it wins me.

    • @knoraziel
      @knoraziel Před 9 měsíci

      I just saw part of the video and then started to check the code in the repo and noticed that the main branch uses prisma, what made you decide to change from drizzle?

  • @r-i-ch
    @r-i-ch Před 9 měsíci +5

    Ben: Publishes the first long-form SvelteKit w/commercial-DB tutorial on CZcams and then apologizes about it being late.
    Bruh you're golden! No apologies necessary, especially for the zero we're paying you to do this!

    • @bmdavis419
      @bmdavis419  Před 9 měsíci

      Is it really the first lol? Is there really this big of a gap in content for Go/Svelte/Supabase past like “its neat here is a todo app”

    • @r-i-ch
      @r-i-ch Před 9 měsíci +2

      I haven't seen any others, but that's just me. Certainly nowhere nearly as much out there as there is for React...

    • @SRG-Learn-Code
      @SRG-Learn-Code Před 9 měsíci

      @Huntabyte & @JamesQQuick come to my mind in this regard, not with GO, but there is not much of it in this video. In any case, SB has made some changes and it is always nice to see and up to date video. Apart from that, I think is awesome to watch the thinking behind instead of just the implementation.

  • @Mindflays_
    @Mindflays_ Před 9 měsíci +19

    This is a good format honestly, it’s hard to find information about something and not have it be a step step hand hold of writing out code with no explanation

  • @prashlovessamosa
    @prashlovessamosa Před 9 měsíci +13

    Please make more
    longer videos.
    Just make it.
    Your way of explaining is awesome.

    • @sep1ol
      @sep1ol Před 9 měsíci

      real and true

  • @dheerajs2838
    @dheerajs2838 Před 9 měsíci +5

    I was earlier using drizzle or prisma for all thing database .. but in the end, I moved to using supabase migration approach and supabase libraries with typesafe generation.. Less things to handle, and follows RLS. I watched few videos where they compared performance between different orms .. supabase was the faster than prisma. so went supabase route. Overall great video.. Keep going

  • @KevinVandyTech
    @KevinVandyTech Před 9 měsíci +4

    You're one of my favorites to just listen to your take on all these developer topics

  • @antoneriksson208
    @antoneriksson208 Před 9 měsíci +4

    Been looking forward to this since your last supabase video, super excited to start watching!

  • @Raul-bc3zb
    @Raul-bc3zb Před 9 měsíci +1

    Went through the sveltekit tutorial these past few days and I have to say this is the absolute BEST complimentary material for learning the ins and outs of this meta-framework. Keep up the good work!

  • @sep1ol
    @sep1ol Před 9 měsíci +6

    seems like a pretty straight forward approach to web dev
    surely a lot less code compared to react
    thanks for the video and insights!

  • @kizo-niklas
    @kizo-niklas Před 3 měsíci +1

    Awesome stuff! This is a great format when looking to see some more advanced examples of code instead of just beginner tutorials, without having to spend like 5 hours on a tutorial. Really loved it! :)

  • @toddsampson6139
    @toddsampson6139 Před 9 měsíci +6

    Such an awesome video. I've been enjoying all of your SvelteKit/Supabase vids. You really helped me solve a few issues I was hitting with oAuth with Google and local development. Thanks so much.

  • @meaningmean
    @meaningmean Před 9 měsíci +1

    Subscribed. Love this format, looking forward for more.

  • @wizzl8513
    @wizzl8513 Před 8 měsíci +1

    Amazing content, much appreciated!

  • @paulclarke4099
    @paulclarke4099 Před 9 měsíci +2

    Really great video and information, format was excellent, thanks so much for all the time you spent on this very detailed video 💯😃👍

  • @charlesbcraig
    @charlesbcraig Před 9 měsíci +3

    Perfect timing! I’m looking at this stack rn

  • @IamI16
    @IamI16 Před 9 měsíci +1

    Thank you for the great video. It helps me so much on coding with SvelteKit. :)

  • @ralph5768
    @ralph5768 Před 9 měsíci +1

    Really helpful video Ben!

  • @acrunchberry
    @acrunchberry Před 9 měsíci +2

    Fun little easter egg because you mentioned it at 35:36.
    5173 is Leet speak for SITE.

  • @drien1993
    @drien1993 Před 6 měsíci

    Love your videos ! I also struggle choosing how to run my migrations. I agree with you on the single source of truth, which is the raw sql migration ! What i end up doing is still use my "orm" (in my case kysely) to run the migations but with a raw sql which works pretty well. You have the power of your migrations per env and with ups and downs and the raw sql file

  • @kirso
    @kirso Před 9 měsíci +4

    Loved it, thanks for doing this but still would prefer rather step by step as I like to type it out and follow along.

  • @_briantravis
    @_briantravis Před 7 měsíci

    Hey Ben, just found your channel and I really like the way you explain things! I've been enjoying the Next 13/14 + Supabase stack recently and I'm curious why you prefer svelte over other frameworks like Next?
    Great stuff, subscribed!

  • @user-gt9uw6jp3q
    @user-gt9uw6jp3q Před 3 měsíci +1

    Great work. Kudos

  • @kuatroka
    @kuatroka Před 9 měsíci

    Thanks for the tut. A bit of an architecture related question. For your insiderviz startup, what do you use as the backend db for the analytics part, is it still supabase/postgres or supabase is used only for auth, login, stripe subscriptions? I understand it's a tick unrelated to this video, but since you are discussing supabase I want to understand the use case for it. Is it for all aspects of a data heavy app or postgres would be slow for that and therefore is only used for auth and subscription? and for data and analytics part you use duckdb or clickhouse or some other fast db? Thanks

  • @21Guitars_
    @21Guitars_ Před 5 měsíci

    FYI, FWIW, I like this presentation style personally much better than someone just typing out code because and talking over it superficially because I like to understand things and this makes understanding easier and give really good explanations of what is happening. With the code examples, the explanation quality varies. For instance, Corey Schafer is super good at explaining and typing at the same time because he always takes a rest and explains what he's doing and why. That said, most people are not good at it, because they assume understanding on the viewer's end and go quickly/superficially but somebody coming at a video like this usually lack the understanding, so explaining is kinda the point. This is the first video of you that I watch and so far, so good, this one was excellent!

  • @rkhealey
    @rkhealey Před 3 dny +1

    Love this. Thank you so much. Have you done a video on why you switched out Drizzle for Prisma?

    • @bmdavis419
      @bmdavis419  Před 2 dny

      I actually have an updated version of this video coming out sometime this week which has a ton of updates to how this is done, as for drizzle I'm not sure if I have a video, the main reason for the switch is because its lighter weight and closer to SQL

  • @Ryguy12543
    @Ryguy12543 Před měsícem +1

    cant believe i'm just seeing this. 💯

    • @bmdavis419
      @bmdavis419  Před měsícem

      Going to have a new version soon!

  • @sinisaperovic3880
    @sinisaperovic3880 Před 9 měsíci +1

    Thank you for this great video. I like both the content and the format. As a kinda newbie in it all, I'm still missing the reason to use ORM over supabase-js. Is that just your preference or there's something more behind that decision.
    Cheers.

    • @bmdavis419
      @bmdavis419  Před 9 měsíci +1

      U can for sure use the supabase-js instead, I personally just prefer drizzle because it’s what I use regardless of database and it’s closer to SQL

  • @jerebenitez8542
    @jerebenitez8542 Před 9 měsíci

    As a non-beginner, this is a really useful format since I don't need to be taught how to write code (I can just check the docs for that), I need help understanding how everything fits together (something that, most of the time, is either not explained in the docs, or that is explained but difficult to grasp from it without seeing into an actual project).

  • @abdelali_zahi
    @abdelali_zahi Před 8 měsíci

    Great video Ben! Thank you for posting! I also love your vscode setup. Would you mind sharing the names of both the theme and the editor font you are using. If I am not mistaken, the terminal seems to be using Jetbrains Mono. Please correct me if it is not. 🙏🏼

  • @youbart100
    @youbart100 Před 9 měsíci

    Hi Ben. Thanks for the great video! I have a question about the login route (around the 28:50 mark). There in page.server.ts you are calling the getSession function coming from your hook to get the session, but you are also calling getSession in layout.server.ts which would then propagate down to the login route. So my question is are they really both necessary, or are we now getting the same session from Supabase twice for a single route. Wouldn’t it make more sense to get the session just once in the layout (or in hooks). Thanks!

    • @edwardspresume
      @edwardspresume Před 9 měsíci +2

      The getSession in login/page.server.ts is only there to redirect the user to the profiles page if they are login. So for that use case, yes it is necessary. Notice how he did not return that session in that file, since the session is already being returned in layout.server.ts to be accessible to all the +page.svelte routes
      Hope that made sense if not lmk

    • @youbart100
      @youbart100 Před 9 měsíci

      @@edwardspresume thank you! I now see the difference. I guess another part of my confusion came from thinking that the page.server.ts would automatically have access to data from parent server load functions (layout.server.ts), but I now see that is not the case to prevent waterfalls (unless you call await parent())

  • @doni1460
    @doni1460 Před 4 měsíci +1

    Nice one thanks.

  • @WyzrdCat
    @WyzrdCat Před 9 měsíci +1

    I personally definitely prefer to see the process of the build. Ideally, the first time you ever build it, so I can see the mistakes you make on the way. That said, I realize there's a lot of that format so definitely understand if there is an audience for this

  • @0x6po
    @0x6po Před 9 měsíci +1

    great video. btw, i hope you can do step by step as to see your thinking process when you actually implementing those things

    • @bmdavis419
      @bmdavis419  Před 9 měsíci

      Thanks! Definitely considering doing a live uncut version of me actually building out these examples for you guys to watch, then making a full deep dive like this

    • @0x6po
      @0x6po Před 9 měsíci

      @@bmdavis419 lovely, hope you feeling well and do the live soon xD

  • @abdirahmann
    @abdirahmann Před 9 měsíci +5

    at 22:00, "locking things with RLS so that everyone is just blocked 💥🔨", supabase exposes all tables in the public schema to the api, if you dont want that, create a new schema and it wont be exposed.

  • @riigel
    @riigel Před 9 měsíci +1

    THANKS MAAAAAN!!!

  • @SRG-Learn-Code
    @SRG-Learn-Code Před 9 měsíci

    I'm confused about how supabase auth works... I know it just works, but I would like to learn how/why does those things. Can the client create a fake session? Do you have to recreate the supabase client in every request or can/should you store it? Would be better to have a server only auth?

  • @Woeden
    @Woeden Před 6 měsíci

    I'm trying to list a bunch of image files from the bucket but it wont work. Do you know if its possible?

  • @ayushdedhia25
    @ayushdedhia25 Před 7 měsíci +2

    Hey just noticed your font looks really cool. Would you mind saying what font is it? 😅

    • @bmdavis419
      @bmdavis419  Před 7 měsíci +1

      Jetbrains mono nerd font!

    • @ayushdedhia25
      @ayushdedhia25 Před 7 měsíci +1

      @@bmdavis419 thank you so much ❤️

  • @jimjones26
    @jimjones26 Před 8 měsíci

    Question: Where did the migration file in the migrations folder come from? The name suggests it was automatically created, but I wanted to check.

    • @jimjones26
      @jimjones26 Před 8 měsíci +1

      Nevermind! I figured it out. I'm new to supabase so still learning. Awesome video so far, thanks!

  • @abdirahmann
    @abdirahmann Před 9 měsíci +3

    hi ben, what do you use to implement search on a system, whether be it in ecommerce, docs or internal support. Am currently evaluating using an approach that utilizes embeddings and all the ai hype, do you have any advice for this or give me your opinion. Thanks for the content, you are looking fabulous! 😃

    • @bmdavis419
      @bmdavis419  Před 9 měsíci +2

      I actually don’t have any real experience with this, I’ve always used a service for my search (algolia or mongodb search)

    • @abdirahmann
      @abdirahmann Před 9 měsíci

      @@bmdavis419 thanks 🤝

    • @khalilbessaad5553
      @khalilbessaad5553 Před 9 měsíci +1

      Not Ben but I've shipped algolia to prod. Create dev experience and the algolia recommended system is very very good. It's what makes algolia stay at the top. An opensource self hostable equivalent to algolia is meilisearch. Xata is also worth mentioning as it comes with postgres and elasticsearch out of the box

    • @abdirahmann
      @abdirahmann Před 9 měsíci

      @@khalilbessaad5553 algolia becomes expensive once you become a serious app though it does understand the semantics behind the meaning of a word/sentence, meilisearch doesn't understand semantics but they are working on it. Though i've already found a solution that uses the CLIP AI model from openAi which is able to understand text but also most importantly images where you can have a flow like image -> vectorize -> use the vector to search through a vector database using cosine similarity, i found a good solution literally today but i still have to understand the system somewhat indepth so that I'm confident when it goes to prod, anyways Thanks alot for your feedback 😊

  • @FredT34
    @FredT34 Před 7 měsíci +1

    @bmdavis419 Thanks A LOT for your videos, you save me hours of very painful learning (now it's just painful 😅)
    EdgeDB 4 arrives November 1st, I dream you'll play with it and Svelte/Kit !
    Thanks

    • @bmdavis419
      @bmdavis419  Před 7 měsíci

      I keep getting comments about EdgeDB, never used it, but if I get a slow time I'll take a look

  • @HonkletonDonkleton
    @HonkletonDonkleton Před 9 měsíci

    This is great thanks. Why not just remove drizzle?

  • @kevinmitchell6141
    @kevinmitchell6141 Před 9 měsíci

    Hey! Is there a specific reason you are not using explicit foreign keys and instead opting for relations?

  • @SimonHampton
    @SimonHampton Před 4 měsíci +2

    this was very good and useful but you did tend to assert that that's how sveltekit works in places, rather than explaining the underlying client server distinctions. that matters because Supabase have since changed to SSR Auth and those server and client differences are (for me) now even harder to follow and I fear your video hasn't fully equipped me for that

    • @bmdavis419
      @bmdavis419  Před 4 měsíci +1

      Yep I just saw that that change happened, will make a note of it!

    • @bmdavis419
      @bmdavis419  Před 4 měsíci

      supabase.com/docs/guides/auth/server-side/migrating-to-ssr-from-auth-helpers?framework=sveltekit

    • @mr_clean575
      @mr_clean575 Před 4 měsíci

      I've also been wondering about this as well

  • @nobodyshomeuk
    @nobodyshomeuk Před 9 měsíci +4

    Great video! When you've decided on your migrations approach, could you pin/post somewhere. Would be interested to see what you settled on!

    • @bmdavis419
      @bmdavis419  Před 9 měsíci +1

      Working on it with the drizzle team now, sounds like there may be something far better in the future! :)

    • @SRG-Learn-Code
      @SRG-Learn-Code Před 9 měsíci

      @@bmdavis419 I would like it vanilla. I'm still on the fence with orms.

  • @mmzzzmeemee
    @mmzzzmeemee Před 9 měsíci

    26:16 I thought you were going to say that you didn't use drizzle for migrations because drizzle doesn't support RLS, triggers, functions.
    (or do they?)

  • @albertoginelsalvador2172
    @albertoginelsalvador2172 Před 9 měsíci +1

    So good! but in the repo there isnt any drizzle, just prisma.

  • @khalilbessaad5553
    @khalilbessaad5553 Před 9 měsíci +2

    I need more of this. Prod concepts are hard to understand and it's hard to find the ressources for it.

    • @bmdavis419
      @bmdavis419  Před 9 měsíci +1

      Yea I rarely see stuff at this level, it’s usually todo apps and hello worlds

    • @khalilbessaad5553
      @khalilbessaad5553 Před 9 měsíci +1

      @@bmdavis419 Exactly. And then you find us struggling for months to implement supabase auth in Astro with no guidance lol

    • @khalilbessaad5553
      @khalilbessaad5553 Před 9 měsíci

      At least now this video could be a reference we could use

  • @lifeofdandotme
    @lifeofdandotme Před 9 měsíci +1

    The thing I really dislike about file based routing is you end up with dozens upon dozens of “page.svelte” or “index.ts” files. You have to know/see the whole file path in order to get the correct file. In a large project it makes fuzzy finding the right file kind of annoying.

    • @bmdavis419
      @bmdavis419  Před 9 měsíci

      Yea u have to get used to looking for folders not files and looking at paths not files, it definitely can get weird but it seems like what most frameworks are doing these days

  • @willl0014
    @willl0014 Před 8 měsíci

    I think for complex saas and enterprise apps you should decouple sveltekit and the server API because it will be really chaotic to manage a really business logic heavy API inside sveltekit. Intermingling all those files Will be a nightmare

  • @nuttbaked
    @nuttbaked Před 9 měsíci +2

    lessgo!!!

  • @4livetv934
    @4livetv934 Před 2 měsíci +1

    you censored your email but it's still visible during some transitions :P

  • @DanteMishima
    @DanteMishima Před 9 měsíci

    Good video, but you were blocking part of the screen

  • @vladimirjaksic5883
    @vladimirjaksic5883 Před 9 měsíci +1

    5173 .......... 'VITE' 👍

  • @elmagnificent8550
    @elmagnificent8550 Před 5 měsíci

    Didnt watch it all. Looks very similar in flutter development. We use go_router, auto_route libraries and it looks sort of similar here.

  • @codefork94
    @codefork94 Před 9 měsíci +1

    50 min. Paused video. Make coffee. Play video. Like video. Life is sweet

  • @eliott5891
    @eliott5891 Před 9 měsíci +1

    All and all, it's just postgres

  • @parkerrex
    @parkerrex Před 8 měsíci

    it's just postgres

  • @Canneverdoit
    @Canneverdoit Před 9 měsíci

    I don't see any benefit of using Drizzle instead of Supabase SDK. You loose all of the great benefits like RLS and etc. And you do also have to manually rewrite the types to Drizzle format. Seems like extra unnecessary layer to me.

    • @bmdavis419
      @bmdavis419  Před 9 měsíci

      its personal preference, I prefer doing it like this as I'm used to a separate backend, but you can absolutely just leverage the SDK

    • @Canneverdoit
      @Canneverdoit Před 9 měsíci

      @@bmdavis419 Thanks, just wanted to know if there was certain reason for it. But regarding to the format of the video, I think it's a great way to understand the flow and process. And I think a step by step after this would nail it! So first - What and Why (like this video), second - how (step by step).
      Keep it going!

  • @honwicong3760
    @honwicong3760 Před 9 měsíci

    I keep getting type error getSession is not a function from +layout.server.ts. Totally have no idea why it happens.