Can't get SvelteKit + Supabase Auth Working ๐
I've tried every tutorial I can find including the ones in the official docs. They're all either outdated, don't work, or both. The official docs use the auth-helpers scheme even though the recommended method is to use the newer SSR module. But I can't get that far because the tutorial ends up in a 500 error:
For some reason the
supabase
object isn't making into my layout file.
So after several hours of having no fun at all, my question is... Has anyone managed to successfully get SvelteKit working with Supabase Auth? Are there any current/working tutorials out there that I haven't found? Anyone got a recent GitHub showing it working?
I really really want to love Supabase. But so far it's just been a huge bummer. Literally step one of the tutorial fails with this error:
Seriously not inspiring much confidence so far.12 Replies
Not up on the latest Sveltekit stuff, but I believe 2 is about 2weeks old. I'm not sure how much testing has occurred with that version considering the time of year.
https://github.com/supabase/auth-helpers/issues/706
GitHub
Sveltekit 2.0 cookie API change ยท Issue #706 ยท supabase/auth-helpers
Bug report I confirm this is a bug with Supabase, not with my own application. I confirm I have searched the Docs, GitHub Discussions, and Discord. Describe the bug Recently Sveltekit 2.0 was relea...
Stack Overflow
Sveltekit run build = Warning: To load an ES module, set "type": "m...
I wrote a simple Sveltekit Application with the Skeleton UI. I created the build folder using npm run build.
If I locally run this via node using node index.js it works fine, and the site is access...
yeah, I have this working in production, but I'm using kit 1.x still.
@cp-sean you should be able to safely ignore the dependency mismatch warning, the sveltekit 1.x to 2.x differences shouldn't impact the auth bits
feel free to ping me direct if you need extra help. I have been meaning to put together a sveltekit + supabase started based on my knowledge anyway, maybe we could give it a go?
Hey that sounds great! I'm actually just now going through Joy Of Code's explanation of SvelteKit data flow to patch up a few knowledge gaps around hooks > +layout.server.js > +layout.js โ Once I'm 100% solid around that, I think it should be just a matter of reading the Supabase docs and using the
supabase
object. I'm in San Francisco; what timezone are you in? Let's collaborate! ๐EST
(also, highly recommend using typescript)
for anyone else who needs it: https://github.com/fnimick/sveltekit-supabase-auth-starter
GitHub
GitHub - fnimick/sveltekit-supabase-auth-starter: A starter templat...
A starter template for Sveltekit v2 with Supabase Auth used for authentication - GitHub - fnimick/sveltekit-supabase-auth-starter: A starter template for Sveltekit v2 with Supabase Auth used for au...
I've implemented this code in a fresh repo, it successfully sends the magic link, but clicking the link in the inbucket never seems to establish a user session .ie it's always "session": null. Difficult for me to figure out what's going wrong since there are no errors. *edit: figured it out, I had generated my supabase types to a different path, working great now, thanks for sharing!
HI @francis I was using your code like almost copying your entire auth, but i had facing some problem
i always get
any idea with this issues? i recheck everything i already make sure everything id copied.

here's your problem:
did you set up the hooks properly?
i think i was, i add your code to my code

hooks
not the server load
you have to explicit define
getSession
yourself