S
Supabase2y ago
pida

Documentation for full client side authentication with SvelteKit

Hi guys, I'm trying to build an app using Supabase and SvelteKit. My app is a hosted on CloudFlare and I need to build it as a static website. So I have no access to a server. There are great tutorials on Supabase website on authentication using auth-helpers but I looks like it is for SSR apps. I can't find any tutorial or boilerplate for a full client side authentication. Did I miss something? Thanks!
5 Replies
garyaustin
garyaustin2y ago
I’ve not seen one but Supabase-js was initially designed and still runs completely in browser code. The app I’m working on is a static sveletekit PWA that runs in the homesceen mode. No issues around auth but I do 6 digit code to avoid redirects which launch a new browser window.
pida
pidaOP2y ago
Thanks for the insights @garyaustin , and just to be sure: thr auth-helpers are only designed for SSR and server stuff right?
garyaustin
garyaustin2y ago
Yes. I don't use auth helpers. Basically in a browser you do createClient() then getSession() to see if you are signed in. Then based on getSession null you know you need to go to login or you have a user with a session that has been recovered from localstorage. The user session is refreshed automatically if required. Which is why you need the await getSession().
Jacob
Jacob2y ago
Yeah, I also use auth in sveltekit with the 6 digit code (or services like Google). I never like setting up redirects in my site nor managing password ui, so that makes everything really simple flow for both programming and for users. So that means I do the login client side but then use the auth state on both server and client. I've found that the basic supabase-js package provides everything I need. The SSR helpers actually just made things more complicated and not what I needed so I ignore them.
pida
pidaOP2y ago
How about a Electron based app? Would the auth helpers help?

Did you find this page helpful?