Skip to content

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

docs: add missing import and type decl to sveltekit tutorial (#21634)

Turiiya74a1d5fec103
diff --git a/apps/docs/content/guides/getting-started/tutorials/with-sveltekit.mdx b/apps/docs/content/guides/getting-started/tutorials/with-sveltekit.mdx
index 7610c78ef0e..edd59df53e3 100644
--- a/apps/docs/content/guides/getting-started/tutorials/with-sveltekit.mdx
+++ b/apps/docs/content/guides/getting-started/tutorials/with-sveltekit.mdx
@@ -120,7 +120,9 @@ Create a new `src/routes/+layout.server.ts` file to handle the session on the se
```ts src/routes/+layout.server.ts
// src/routes/+layout.server.ts
-export const load = async ({ locals: { getSession } }) => {
+import type { LayoutServerLoad } from './$types'
+
+export const load: LayoutServerLoad = async ({ locals: { getSession } }) => {
return {
session: await getSession(),
}
@@ -135,8 +137,9 @@ Create a new `src/routes/+layout.ts` file to handle the session and the supabase
// src/routes/+layout.ts
import { PUBLIC_SUPABASE_ANON_KEY, PUBLIC_SUPABASE_URL } from '$env/static/public'
import { createSupabaseLoadClient } from '@supabase/auth-helpers-sveltekit'
+import type { LayoutLoad } from './$types'
-export const load = async ({ fetch, data, depends }) => {
+export const load: LayoutLoad = async ({ fetch, data, depends }) => {
depends('supabase:auth')
const supabase = createSupabaseLoadClient({
@@ -393,8 +396,9 @@ and handle all our form actions through the `actions` object.
```ts
import { fail, redirect } from '@sveltejs/kit'
+import type { Actions, PageServerLoad } from './$types'
-export const load = async ({ locals: { supabase, getSession } }) => {
+export const load: PageServerLoad = async ({ locals: { supabase, getSession } }) => {
const session = await getSession()
if (!session) {
@@ -410,7 +414,7 @@ export const load = async ({ locals: { supabase, getSession } }) => {
return { session, profile }
}
-export const actions = {
+export const actions: Actions = {
update: async ({ request, locals: { supabase, getSession } }) => {
const formData = await request.formData()
const fullName = formData.get('fullName') as string
diff --git a/examples/user-management/sveltekit-user-management/src/routes/+layout.server.ts b/examples/user-management/sveltekit-user-management/src/routes/+layout.server.ts
index 6f3e61381dd..3cee2fb2163 100644
--- a/examples/user-management/sveltekit-user-management/src/routes/+layout.server.ts
+++ b/examples/user-management/sveltekit-user-management/src/routes/+layout.server.ts
@@ -1,5 +1,7 @@
// src/routes/+layout.server.ts
-export const load = async ({ locals: { getSession } }) => {
+import type { LayoutServerLoad } from './$types'
+
+export const load: LayoutServerLoad = async ({ locals: { getSession } }) => {
return {
session: await getSession()
}
diff --git a/examples/user-management/sveltekit-user-management/src/routes/+page.server.ts b/examples/user-management/sveltekit-user-management/src/routes/+page.server.ts
index 2ee87b4e01c..44e9d6b9bc8 100644
--- a/examples/user-management/sveltekit-user-management/src/routes/+page.server.ts
+++ b/examples/user-management/sveltekit-user-management/src/routes/+page.server.ts
@@ -1,7 +1,8 @@
// src/routes/+page.server.ts
import { redirect } from '@sveltejs/kit'
+import type { PageServerLoad } from './$types'
-export const load = async ({ url, locals: { getSession } }) => {
+export const load: PageServerLoad = async ({ url, locals: { getSession } }) => {
const session = await getSession()
// if the user is already logged in return them to the account page
diff --git a/examples/user-management/sveltekit-user-management/src/routes/account/+page.server.ts b/examples/user-management/sveltekit-user-management/src/routes/account/+page.server.ts
index f1a1be59536..9c26931969b 100644
--- a/examples/user-management/sveltekit-user-management/src/routes/account/+page.server.ts
+++ b/examples/user-management/sveltekit-user-management/src/routes/account/+page.server.ts
@@ -1,6 +1,7 @@
import { fail, redirect } from '@sveltejs/kit'
+import type { Actions, PageServerLoad } from './$types'
-export const load = async ({ locals: { supabase, getSession } }) => {
+export const load: PageServerLoad = async ({ locals: { supabase, getSession } }) => {
const session = await getSession()
if (!session) {
@@ -16,7 +17,7 @@ export const load = async ({ locals: { supabase, getSession } }) => {
return { profile }
}
-export const actions = {
+export const actions: Actions = {
update: async ({ request, locals: { supabase, getSession } }) => {
const formData = await request.formData()
const fullName = formData.get('fullName') as string