Closed uncapped1599 closed 12 months ago
I don't think this needs to change as this is not a tutorial, its a guide on how you can do various things. This would be down to the developer to have a better understanding of SvelteKit in order to know they should use a sequence to have both.
@silentworks, disagree. Better examples are better.
@uncapped1599, you can make a PR for the docs by editing the following: https://github.com/supabase/supabase/blob/master/apps/docs/pages/guides/auth/auth-helpers/sveltekit.mdx
I'll do it if you want.
Hi @silentworks , thanks for getting back to me. You can't really protect routes without a session so I believe this fits better in the page. The rest of this link works well to cover everything you would need, step-by-step for Supabase and Sveltekit.
@j13n - sure happy to. Have made a pull request on the doc. I would just double check the typescript, I am never great without intellisense while editing in browser.
I don't disagree with your goal, but I do with the tactics.
Also a fair point, perhaps the last section should then suggest users can use this to protect multiple routes and direct them towards the sequence helper function docs at Sveltekit.
PR got merged so closing this one out.
Improve documentation
Supabase Auth with SvelteKit
Link
https://supabase.com/docs/guides/auth/auth-helpers/sveltekit?language=ts Add a link to the page which needs improvement (if relevant)
Describe the problem
To both create a supabase client in sveltekit and protect your routes, you need to update the hooks.server.ts/js file at the root of your project. However, the current documentation suggests updating the same file with two exported functions (See client and protect links)
You cannot export two functions in hooks.server.ts/js you must use a sequence helper function.
This is going to confuse people trying to implement the auth in sveltekit (it confused me at first).
Describe the improvement
Your final step in protecting multiple routes should suggest editing the client creation function and protecting routes function to be fed into a sequence helper function.
Here is a suggested edit to the example code in that final step:
Additional context
This will now work as you intend and allow users to follow through the whole tutorial and get a working authentication with supabase alongside also protecting routes.