Best Practices for Fresh SvelteKit Data? #1511
Unanswered
MattHeslington
asked this question in
Help
Replies: 2 comments
-
Looks best way is just to check the $page.data value |
Beta Was this translation helpful? Give feedback.
0 replies
-
I use the invalidateAll Method from svelteKit to reload all route data. |
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
-
Hello,
I love Lucia - great package, thank you! Just a hobby coder so apologies if I've missed something obvious.
I have integrated Lucia (v3) with SvelteKit. I have GitHub OAuth working well within the app. However, I'm wodering about best practices as I have a small bug. My root +layout.svelte file contains the header.svelte component, which when a user is logged in shows their avatar and name etc. At the moment, the data flow for this as follows:
The root +layout.server file has a load function which returns the user data:
The problem is, if a user logs out, the data in the header is not refreshed and still shows them as being logged in.
As I understand it, a +layout.server.js file is only loaded once, initially, so a user logging does not cause the load function in that filw to run again. How do I keep the information in the header fresh? What's best practice, please?
I've watched the Huntabyte video regarding not using layout server files for auth because of this, but I can't think of a workaround when we need to show data in a component is a layout. I did use Lucia v2 in a different project, with the same data flow, and for some reason this wasn't an issue.
Anyway, many thanks for any advice!
Matt
Beta Was this translation helpful? Give feedback.
All reactions