© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•6mo ago•
11 replies
Tom

Sveltekit protected routes question

as per the docs https://supabase.com/docs/guides/auth/server-side/sveltekit

In the hooks.server.ts:
if (!event.locals.session && event.url.pathname.startsWith('/private')) {
    redirect(303, '/auth')
  }
if (!event.locals.session && event.url.pathname.startsWith('/private')) {
    redirect(303, '/auth')
  }


So any route I want to "protect" I need to add it to this if check? Or put protected routes into the /protected directory? Bit confused on what's the way its supposed to work.
Screenshot_2025-08-28_at_19.13.38.png
Setting up Server-Side Auth for SvelteKit | Supabase Docs
Setting up Server-Side Auth for SvelteKit | Supabase Docs
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Next JS Protected Routes
SupabaseSSupabase / help-and-questions
4y ago
Nextjs with google provider (protected routes)
SupabaseSSupabase / help-and-questions
4y ago
Use realtime across multiple routes in Sveltekit
SupabaseSSupabase / help-and-questions
3y ago
Protected columns?
SupabaseSSupabase / help-and-questions
4y ago