From 6d5e2e5d85c60f53e5b973e8712fa2201618cd2f Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Sun, 30 Apr 2023 21:26:32 +0000 Subject: [PATCH] Update SvelteKit guide to remove undefined inputs --- .../tutorials/with-sveltekit.mdx | 73 +++++++++---------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/apps/docs/pages/guides/getting-started/tutorials/with-sveltekit.mdx b/apps/docs/pages/guides/getting-started/tutorials/with-sveltekit.mdx index 3d52b20f8d1..8eba8465d47 100644 --- a/apps/docs/pages/guides/getting-started/tutorials/with-sveltekit.mdx +++ b/apps/docs/pages/guides/getting-started/tutorials/with-sveltekit.mdx @@ -126,9 +126,7 @@ Create a new `src/routes/+layout.server.ts` file to handle the session on the se ```ts title=src/routes/+layout.server.ts // src/routes/+layout.server.ts -import type { LayoutServerLoad } from './$types'; - -export const load: LayoutServerLoad = async ({ locals: { getSession } }) => { +export const load = async ({ locals: { getSession } }) => { return { session: await getSession() }; @@ -147,9 +145,8 @@ import { PUBLIC_SUPABASE_URL } from '$env/static/public'; import { createSupabaseLoadClient } from '@supabase/auth-helpers-sveltekit'; -import type { LayoutLoad } from './$types'; -export const load: LayoutLoad = async ({ fetch, data, depends }) => { +export const load = async ({ fetch, data, depends }) => { depends('supabase:auth'); const supabase = createSupabaseLoadClient({ @@ -173,23 +170,22 @@ Update your `src/routes/+layout.svelte`: @@ -220,9 +216,8 @@ Add the `Auth` component to your home page @@ -251,9 +246,8 @@ and send it over to the server. This all happens behind the scenes and isn't som ```ts // src/routes/+page.server.ts import { redirect } from '@sveltejs/kit'; -import type { PageServerLoad } from './$types'; -export const load: PageServerLoad = async ({ url, locals: { getSession } }) => { +export const load = async ({ url, locals: { getSession } }) => { const session = await getSession(); // if the user is already logged in return them to the account page @@ -277,9 +271,8 @@ This page is used for waiting while your client-side code inside of `src/routes/ import { browser } from '$app/environment'; import { goto } from '$app/navigation'; import { page } from '$app/stores'; - import type { PageData } from './$types'; - export let data: PageData; + export let data; $: { const redirectTo = $page.url.searchParams.get('redirect'); @@ -305,26 +298,33 @@ Create a new `src/routes/account/+page.svelte` file with the content below. ```svelte title=src/routes/account/+page.svelte @@ -366,7 +366,7 @@ Create a new `src/routes/account/+page.svelte` file with the content below. -
+
@@ -379,9 +379,8 @@ 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 = async ({ locals: { supabase, getSession } }) => { const session = await getSession(); if (!session) { @@ -395,7 +394,7 @@ export const load = (async ({ locals: { supabase, getSession } }) => { .single(); return { session, profile }; -}) satisfies PageServerLoad; +}; export const actions = { update: async ({ request, locals: { supabase, getSession } }) => { @@ -439,7 +438,7 @@ export const actions = { throw redirect(303, '/'); } } -} satisfies Actions; +}; ``` ### Launch!