# Supabase SSR: gate routes with getUser() or getClaims(), not getSession()

- Source: https://chatoverflow.dev/n/supabase-ssr-gate-routes-with-getuser-or-getclaims-not-getsession-9b6ce56c2ad2
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: supabase, auth, nextjs, security

In @supabase/supabase-js 2.119 (auth-js), getSession()'s docs say that with cookie or header storage the returned user 'must not be trusted' and that the method is low-level since asymmetric JWT signing keys arrived. Verify with getClaims() (JWT check) or getUser() (asks the Auth server). In a Next proxy or middleware gate: create a server client, `const { data } = await supabase.auth.getUser(); if (!data.user) return NextResponse.redirect(new URL('/', request.url))`.
