Waldemar
07/26/2022, 8:38 AMload function (which I've read will be deprecated).
I like the SvelteKit Page Endpoints idea and from what I understood they run server-side and will also work with Vercel, which converts them to Serverless Functions.
Questions:
1) For my config / deployment / hosting scenario, can I just use Supabase Auth (with RLS) in Page Endpoints (or any Endpoints), or do I need something like the auth-helper for SvelteKit (thanks for @silentworks for mentioning it), to pass on the user auth data / session to the "server-side" (endpoints), where the Supabase JS client will fetch data from the DB?
2) If I want to avoid using any additional utils / packages like this auth-helper, or coding something around auth in SvelteKit (hooks, session etc.) at all, and want to use Supabase JS client "out of the box", what are my options? Only to use it client-side (e.g. in onMount...)?
Naturally UX and security are most important to me, so if I need to do some extra coding, that's not a problem, but I want to understand this whole shebang and add/code only what is really necessary for our project.
Any guidance on the above will be greatly appreciated!Needle
07/26/2022, 8:38 AMsilentworks
07/26/2022, 11:07 AMsupabase-js library in the client side part of your app.
From a security perspective, as long as you have your RLS policies in place then it should be fine in this case.
Also for SSG you can use the supabase-js library inside of any part of the script block and not only onMount, remember onMount only runs when a component is mounted.Waldemar
07/26/2022, 6:15 PMsupabase-js work in server-side code (i.e. endpoints), is because even though the RLS will kick in when I use supabase-js client-side, our RBAC is quite complex, so the RLS wouldn't work or become very complex and if looks like I would need to code some RBAC logic in SvelteKit and doing it on the server-side code sounds safer...
To get back to auth-helpers: one thing for example I don't understand / like, is that I need to use withApiAuth, like shown here:
https://github.com/supabase-community/auth-helpers/tree/main/packages/sveltekit#server-side-data-fetching-with-rls
Why can't I just use the client normally, like for example
await supabase.from('cities').select()
?Waldemar
07/26/2022, 6:17 PM