Use of $effect and JWT refresh #175
Unanswered
fullymiddleaged
asked this question in
Q&A
Replies: 1 comment
-
Svelte $effect will run when data changes. The token expiring is just time passing, not the data actually changing. Supabase SDK will kick off a refresh when you navigate/refresh, but probably doesn't automatically run in background (I'm guessing to avoid unnecessary traffic for idle tabs). That make sense? I don't see a bug here, just a question, so bumping over to discussions. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
Firstly thanks for the great work with this template! I'm a bit stuck/confused about how to manage expired JWT tokens though. I see you have a listener setup as per the Supabase docs and the following code making use of $effect in: src/routes/(admin)/account/+layout.svelte
But once logged into the account page, if I have a variable looking at the current JWT access token (see below), it doesn't get updated at all when it expires. If I manually refresh the main account page or navigate elsewhere it does, but I presumed the listener would kick in? From the docs $effect is supposed to update associated variables when they change (e.g. from the listener). Am I completely misunderstanding here?
Please let me know if there is a correct way to update my variable when the JWT token expires.
My variable inside: account/(menu)/+page.svelte
Beta Was this translation helpful? Give feedback.
All reactions