Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Docs: Update SvelteKit SSR example to match the SvelteKit v2 cookies API (#20516)

Hugo Korte0df94bc6ed96
diff --git a/apps/docs/pages/guides/auth/server-side/creating-a-client.mdx b/apps/docs/pages/guides/auth/server-side/creating-a-client.mdx
index c08a9722a25..f0e4ef72106 100644
--- a/apps/docs/pages/guides/auth/server-side/creating-a-client.mdx
+++ b/apps/docs/pages/guides/auth/server-side/creating-a-client.mdx
@@ -455,11 +455,17 @@ export const handle: Handle = async ({ event, resolve }) => {
event.locals.supabase = createServerClient(PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY, {
cookies: {
get: (key) => event.cookies.get(key),
+ /**
+ * Note: You have to add the `path` variable to the
+ * set and remove method due to sveltekit's cookie API
+ * requiring this to be set, setting the path to an empty string
+ * will replicate previous/standard behaviour (https://kit.svelte.dev/docs/types#public-types-cookies)
+ */
set: (key, value, options) => {
- event.cookies.set(key, value, options)
+ event.cookies.set(key, value, { ...options, path: '' })
},
remove: (key, options) => {
- event.cookies.delete(key, options)
+ event.cookies.delete(key, { ...options, path: '' })
},
},
})