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:
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!1 Reply
I'm curious about the same. Failing to successfully implement server-side authentication so far. Did you manage to find a solution @Stephen G ?
Actually I found a solution here https://discord.com/channels/1288403910284935179/1379223049332592802. Look for the SvelteCookie plugin.