Issue with setting session_token cookie in SvelteKit SSR

I'm experimenting with better-auth in SvelteKit SSR mode for registration and login functionality. I'm successfully getting the session_token cookie from the auth API:

const { headers, response } = await auth.api.signInEmail({
  returnHeaders: true,
  body: {
    email,
    password
  }
});


This returns the cookie as a string. However, SvelteKit's setHeader method doesn't allow setting cookies directly, and the cookies object requires individual cookie properties rather than accepting a cookie string.

Is there a better approach to handle this cookie setting without adding a cookie parsing dependency? I'm aware of the authClient but specifically want to experiment with SSR implementation. Thanks!
Was this page helpful?