Can't getSession from server-side hooks (SvelteKit)

Hello,

I'm trying to implement better-auth with SvelteKit.

I'm trying to get the current session in the hooks.server.ts file.

const session = await auth.api.getSession({
    headers: event.request.headers,
});
console.log("Session data:");
console.log(session);


Unfortunately, the session is always null. Any ideas?
Was this page helpful?