Skip to content

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

SvelteKit docs and examples - remove `throw` (#21637)

Kirill Soaeb74c8947bd
diff --git a/apps/docs/content/guides/auth/auth-helpers/sveltekit.mdx b/apps/docs/content/guides/auth/auth-helpers/sveltekit.mdx
index 97f9641eb10..37bf88cee01 100644
--- a/apps/docs/content/guides/auth/auth-helpers/sveltekit.mdx
+++ b/apps/docs/content/guides/auth/auth-helpers/sveltekit.mdx
@@ -155,7 +155,7 @@ export const GET = async ({ url, locals: { supabase } }) => {
await supabase.auth.exchangeCodeForSession(code)
}
- throw redirect(303, '/')
+ redirect(303, '/')
}
```
@@ -175,7 +175,7 @@ export const GET = async ({ url, locals: { supabase } }) => {
await supabase.auth.exchangeCodeForSession(code)
}
- throw redirect(303, '/')
+ redirect(303, '/')
}
```
@@ -639,7 +639,7 @@ async function authorization({ event, resolve }) {
const session = await event.locals.getSession()
if (!session) {
// the user is not signed in
- throw redirect(303, '/')
+ redirect(303, '/')
}
}
@@ -701,7 +701,7 @@ async function authorization({ event, resolve }) {
const session = await event.locals.getSession()
if (!session) {
// the user is not signed in
- throw redirect(303, '/')
+ redirect(303, '/')
}
}
@@ -773,7 +773,7 @@ import { redirect } from '@sveltejs/kit'
export const load = async ({ parent }) => {
const { supabase, session } = await parent()
if (!session) {
- throw redirect(303, '/')
+ redirect(303, '/')
}
const { data: tableData } = await supabase.from('test').select('*')
@@ -819,12 +819,12 @@ export const actions = {
})
}
- throw redirect(303, '/dashboard')
+ redirect(303, '/dashboard')
},
signout: async ({ locals: { supabase } }) => {
await supabase.auth.signOut()
- throw redirect(303, '/')
+ redirect(303, '/')
},
}
```
@@ -1109,7 +1109,7 @@ import { redirect } from '@sveltejs/kit'
export const load: PageLoad = async (event) => {
const { session, supabaseClient } = await getSupabase(event)
if (!session) {
- throw redirect(303, '/')
+ redirect(303, '/')
}
const { data: tableData } = await supabaseClient.from('test').select('*')
@@ -1145,7 +1145,7 @@ import { redirect } from '@sveltejs/kit'
export const load: PageLoad = async ({ parent }) => {
const { supabase, session } = await parent()
if (!session) {
- throw redirect(303, '/')
+ redirect(303, '/')
}
const { data: tableData } = await supabase.from('test').select('*')
@@ -1179,7 +1179,7 @@ import { json, redirect } from '@sveltejs/kit'
export const GET: RequestHandler = async (event) => {
const { session, supabaseClient } = await getSupabase(event)
if (!session) {
- throw redirect(303, '/')
+ redirect(303, '/')
}
const { data } = await supabaseClient.from('test').select('*')
@@ -1457,7 +1457,7 @@ import type { PageLoad } from './$types'
export const load: PageLoad = withAuth(async ({ session, getSupabaseClient }) => {
if (!session.user) {
- throw redirect(303, '/')
+ redirect(303, '/')
}
const { data: tableData } = await getSupabaseClient().from('test').select('*')
@@ -1489,7 +1489,7 @@ import { redirect } from '@sveltejs/kit'
export const load: PageLoad = async (event) => {
const { session, supabaseClient } = await getSupabase(event)
if (!session) {
- throw redirect(303, '/')
+ redirect(303, '/')
}
const { data: tableData } = await supabaseClient.from('test').select('*')
@@ -1526,7 +1526,7 @@ interface TestTable {
export const GET: RequestHandler = withAuth(async ({ session, getSupabaseClient }) => {
if (!session.user) {
- throw redirect(303, '/')
+ redirect(303, '/')
}
const { data } = await getSupabaseClient().from<TestTable>('test').select('*')
@@ -1546,7 +1546,7 @@ import { json, redirect } from '@sveltejs/kit'
export const GET: RequestHandler = async (event) => {
const { session, supabaseClient } = await getSupabase(event)
if (!session) {
- throw redirect(303, '/')
+ redirect(303, '/')
}
const { data } = await supabaseClient.from('test').select('*')
@@ -1886,7 +1886,7 @@ import type { PageLoad } from './$types'
export const load: PageLoad = withAuth(async ({ session, getSupabaseClient }) => {
if (!session.user) {
- throw redirect(303, '/')
+ redirect(303, '/')
}
const { data: tableData } = await getSupabaseClient().from('test').select('*')
@@ -1948,7 +1948,7 @@ interface TestTable {
export const GET: RequestHandler = withAuth(async ({ session, getSupabaseClient }) => {
if (!session.user) {
- throw redirect(303, '/');
+ redirect(303, '/');
}
const { data } = await getSupabaseClient()
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 9c23fc8e93e..2ee87b4e01c 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
@@ -6,7 +6,7 @@ export const load = async ({ url, locals: { getSession } }) => {
// if the user is already logged in return them to the account page
if (session) {
- throw redirect(303, '/account')
+ redirect(303, '/account')
}
return { url: url.origin }
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 e75ab83cb73..f1a1be59536 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
@@ -4,7 +4,7 @@ export const load = async ({ locals: { supabase, getSession } }) => {
const session = await getSession()
if (!session) {
- throw redirect(303, '/')
+ redirect(303, '/')
}
const { data: profile } = await supabase
@@ -55,7 +55,7 @@ export const actions = {
const session = await getSession()
if (session) {
await supabase.auth.signOut()
- throw redirect(303, '/')
+ redirect(303, '/')
}
}
}