mirror of
https://github.com/better-auth/better-auth.git
synced 2026-10-25 10:13:54 -05:00
docs: fix Update "Getting Session on a loader" example (#224)
In SvelteKit, you can only access the request object (like headers, cookies, etc.) in server-side contexts like +page.server.ts
This commit is contained in:
@@ -69,10 +69,11 @@ Some of the actions are reactive. The client use [nano-store](https://github.com
|
||||
|
||||
### Example: Getting Session on a loader
|
||||
|
||||
```ts title="+page.ts"
|
||||
```ts title="+page.server.ts"
|
||||
import { auth } from "$lib/auth";
|
||||
import type { PageServerLoad } from "./$types";
|
||||
|
||||
export async function load(request: Request) {
|
||||
export const load: PageServerLoad = async ({request}) => {
|
||||
const session = await auth.api.getSession({
|
||||
headers: request.headers,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user