Hello ! I'm currently coding a post creation syste...
# javascript
h
Hello ! I'm currently coding a post creation system. The posts are stored in a table, using the author id as a foreign key. How can I retrieve the id of the currently logged in user ? I'm using JavaScript with Svelte I'm also using the default users table provided by supabase I can retrieve an user object that only has three methods (set, update, and subscribe), but i can't find any documentation about this object, and I can't find the id within it.
s
The methods you are talking about here are svelte store methods, can you give a bit more context please? are you using the supabase-ui-svelte library or have you created your own integration?
h
I did not even know there was a supabase-ui-svelte library, So I'm making my own
I followed the "quickstart with svelte" tutorial
So I have two stores for a supabase and user objects
s
Ok I've looked at the guide now, you can get the user id from the store, are you trying to retrieve it inside of the script part of your code or inside the html part?
If its inside of the html then you can do
Copy code
html
{$user.id}
If its inside of the script tags then you will have to do this inside of a reactive statement
Copy code
js
let userId
$: userId = $user.id