Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Add session management example for SvelteKit (#6184)
* chore(docs): Session management sample for Svelte Added a code sample for managing the session through the $page store. The sample demonstrates how to retrieve the session data in the root +page.server.ts file and make it globally accessible through the $page store, simplifying state management in the application. The previous examples already used the data available in this store but did not show how to set it. * docs: Add authorization section to SvelteKit docs This authorization section was added to make sure a few caveats with SvelteKit were well documented to anyone using the library. The problem is documented here: sveltejs/kit#6315 Essentially, propagation of data between leafs is not guaranteed when using the +layout.server.ts file as its load function is not guaranteed to rerun every page change. The current approach to solve this is to do authorization in each +page.server.ts file and additionally make sure to grab the session data by awaiting the parent instead of directly accessing the $page store, to make sure the information there is current. * docs: Fix small typesafety mistake in SvelteKit PageLoad type should actually be PageServerLoad. Not setting this does not actually generate any problems other than TypeScript complaining that this type is not actually exported. * docs: Add handle hook authorization management Another way to handle authorization is through a path-based method. This added part of the documentation uses the handle hook to protect certain routes based on their path. The previous method which is per-component is still present. * docs: Simplify component approach for Svelte auth Using event.locals.getSession() exposed by SvelteKitAuth instead of relying in the root layout file making that available in the $page store. * docs: Complete SvelteKit authorization docs Finalize the explanation for the URI-based approach and also clarify interactions with the component-based approach. * docs: Add formatting to vars in the SvelteKit docs Format the variables like this: `var` so that it appears clearly as code when reading the documentation. Co-authored-by: Thang Vu <[email protected]>
- Loading branch information
7c96351
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
auth-docs – ./docs
authjs.dev
auth-docs-authjs.vercel.app
next-auth-docs-m1mt.vercel.app
auth-docs-git-main-authjs.vercel.app
www.authjs.dev
adapters.authjs.dev
errors.authjs.dev
warnings.authjs.dev
providers.authjs.dev
sveltekit.authjs.dev