Anyone using supabase with sveltekit for auth and ...
# javascript
i
Anyone using supabase with sveltekit for auth and profiles? There's the built in private users table. The recommendation for user-managed profile fields is to create a separate
profiles
table. I have the postgres stuff working to automatically create a profile entry for new users. When someone logs in to the sveltekit app I need the User and Profile to be persistent but I'm not seeing any built-in way to do this. Is that true? Do I need to rely on setting localstorage or something to store the Profile data when a user first logs in?
s
Can you elaborate a bit more on what you mean by User and Profile to be persistent please?
j
You need to store the auth token in a cookie and then identify yourself with that. Take a look at svelte-kit hooks
i
I have cookie auth set up and everything. The sessions are working and I get data from the User table from that. Supabase recommends setting up a public table for other user information: https://supabase.com/docs/reference/javascript/auth-update > User metadata: It's generally better to store user data in a table inside your public schema (i.e. public.users). Use the update() method if you have data which rarely changes or is specific only to the logged in user.
so i'm trying to avoid querying that table too many times. i'd like the profile information to be grouped in with my session information if possible
I made some progress last night and I think I need to just keep that in my __layout.svelte file. When a user logs in, send another request to grab their profile and put it in a store. And since stores aren't persistent.. If a user refreshes the page, make sure it's there and if not, request it again.