Repository navigation
Revert "docs: Remove Auth Helpers" - #41383
Conversation
This reverts commit 9274b81.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
6 Skipped Deployments
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
WalkthroughThis PR adds comprehensive documentation for Supabase Auth Helpers across multiple frameworks (Next.js, Remix, SvelteKit) and introduces new Auth UI documentation for React and Flutter components. It includes deprecation notices directing users to the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25–30 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 8
🧹 Nitpick comments (3)
apps/docs/content/guides/auth/auth-helpers/auth-ui.mdx (1)
60-67: JSX comment syntax in code blocks may confuse readers.The code examples include JSX comment syntax
{/* Apply predefined theme */}inline within props. While syntactically valid, this pattern is unusual and might confuse readers. Consider moving comments above the prop or removing them.Also applies to: 162-169
apps/docs/content/guides/auth/auth-helpers/remix.mdx (1)
395-402: Unusual empty destructuring pattern.The empty destructuring
({}: LoaderFunctionArgs)is non-standard. If the parameter isn't used, consider using_or omitting the type annotation.-export const loader = ({}: LoaderFunctionArgs) => { +export const loader = (_args: LoaderFunctionArgs) => {apps/docs/content/guides/auth/auth-helpers/flutter-auth-ui.mdx (1)
27-35: Consider clarifying dotenv dependency or using placeholder values.The initialization example uses
dotenv.get('SUPABASE_URL')which requires theflutter_dotenvpackage, but this dependency isn't mentioned in the installation section. Users unfamiliar with this pattern might encounter errors.Consider either:
- Adding
flutter_dotenvto the installation instructions- Using placeholder strings like other Supabase docs typically do
void main() async { await Supabase.initialize( - url: dotenv.get('SUPABASE_URL'), - anonKey: dotenv.get('SUPABASE_PUBLISHABLE_KEY'), + url: 'YOUR_SUPABASE_URL', + anonKey: 'YOUR_SUPABASE_ANON_KEY', ); runApp(const MyApp()); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts(1 hunks)apps/docs/content/_partials/auth_helpers.mdx(1 hunks)apps/docs/content/guides/auth/auth-helpers.mdx(1 hunks)apps/docs/content/guides/auth/auth-helpers/auth-ui.mdx(1 hunks)apps/docs/content/guides/auth/auth-helpers/flutter-auth-ui.mdx(1 hunks)apps/docs/content/guides/auth/auth-helpers/nextjs-pages.mdx(1 hunks)apps/docs/content/guides/auth/auth-helpers/nextjs.mdx(1 hunks)apps/docs/content/guides/auth/auth-helpers/remix.mdx(1 hunks)apps/docs/content/guides/auth/auth-helpers/sveltekit.mdx(1 hunks)apps/www/lib/redirects.js(2 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-12-11T00:21:01.839Z
Learnt from: dnywh
Repo: supabase/supabase PR: 41215
File: apps/design-system/content/docs/accessibility.mdx:30-30
Timestamp: 2025-12-11T00:21:01.839Z
Learning: In apps/design-system/content/docs/, MDX files use different relative path formats based on their location: root-level docs use `components/button` format, while subdirectory docs (ui-patterns/, components/) use `../components/button` format for linking to components.
Applied to files:
apps/docs/content/guides/auth/auth-helpers/nextjs-pages.mdxapps/docs/content/guides/auth/auth-helpers/auth-ui.mdx
📚 Learning: 2025-12-11T17:04:40.002Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/studio-ui.mdc:0-0
Timestamp: 2025-12-11T17:04:40.002Z
Learning: Applies to apps/studio/pages/**/*.{ts,tsx} : Use related layout components (e.g., AuthLayout) for pages within existing sections
Applied to files:
apps/docs/content/guides/auth/auth-helpers/nextjs-pages.mdxapps/docs/content/guides/auth/auth-helpers/sveltekit.mdx
📚 Learning: 2025-12-11T02:39:45.932Z
Learnt from: CR
Repo: supabase/supabase PR: 0
File: .cursor/rules/docs-graphql.mdc:0-0
Timestamp: 2025-12-11T02:39:45.932Z
Learning: Applies to apps/docs/resources/**/[!Schema]*Resolver.ts : Use `supabase()` client for database operations with `convertPostgrestToApiError` for error handling in GraphQL resolvers
Applied to files:
apps/docs/content/guides/auth/auth-helpers/nextjs-pages.mdx
🪛 LanguageTool
apps/docs/content/guides/auth/auth-helpers/remix.mdx
[uncategorized] ~11-~11: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...Use the new @supabase/ssr package for Server Side Authentication. @supabase/ssr takes t...
(EN_COMPOUND_ADJECTIVE_INTERNAL)
[style] ~343-~343: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...ables are not available client-side, we need to plumb them through from the loader. <T...
(REP_NEED_TO_VB)
apps/docs/content/guides/auth/auth-helpers/nextjs-pages.mdx
[uncategorized] ~11-~11: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...Use the new @supabase/ssr package for Server Side Authentication. @supabase/ssr takes t...
(EN_COMPOUND_ADJECTIVE_INTERNAL)
[grammar] ~242-~242: Use a hyphen to join words.
Context: ...nt-side data fetching with RLS For [row level security](/docs/learn/auth-deep-di...
(QB_NEW_EN_HYPHEN)
[grammar] ~291-~291: Use a hyphen to join words.
Context: ...r Supabase client to retrieve the logged in user's session: ```jsx pages/profile...
(QB_NEW_EN_HYPHEN)
[grammar] ~326-~326: Use a hyphen to join words.
Context: ...e the server Supabase client to run [row level security](/docs/learn/auth-deep-di...
(QB_NEW_EN_HYPHEN)
[grammar] ~548-~548: Use a hyphen to join words.
Context: ...r Supabase client to retrieve the logged in user's session: <Tabs scrollable ...
(QB_NEW_EN_HYPHEN)
[grammar] ~688-~688: Use a hyphen to join words.
Context: ...geAuth, and withMiddlewareAuth` higher order functions as deprecated and they w...
(QB_NEW_EN_HYPHEN)
apps/docs/content/guides/auth/auth-helpers.mdx
[uncategorized] ~45-~45: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...Use the new @supabase/ssr package for Server Side Authentication. Use the [migration doc]...
(EN_COMPOUND_ADJECTIVE_INTERNAL)
apps/docs/content/guides/auth/auth-helpers/auth-ui.mdx
[style] ~10-~10: For conciseness, consider replacing this expression with an adverb.
Context: ...longer maintained by the Supabase Team. At the moment, the team does not have capacity to giv...
(AT_THE_MOMENT)
[grammar] ~12-~12: Use a hyphen to join words.
Context: ...Supabase UI Library](/ui) which has auth ready blocks to use in your projects. <...
(QB_NEW_EN_HYPHEN)
[style] ~135-~135: Try using a more formal synonym here to elevate your writing.
Context: ...pdate password - Forgotten password We are planning on adding more views in the future. Follow along ...
(PLAN_ON_INTEND)
[grammar] ~483-~483: Use a hyphen to join words.
Context: ... email - Forgot your password? ### Sign in and sign up views Add sign_in or `...
(QB_NEW_EN_HYPHEN)
[grammar] ~483-~483: Use a hyphen to join words.
Context: ...got your password? ### Sign in and sign up views Add sign_in or sign_up vie...
(QB_NEW_EN_HYPHEN)
apps/docs/content/guides/auth/auth-helpers/flutter-auth-ui.mdx
[grammar] ~39-~39: Ensure spelling is correct
Context: ... widget to create an email and password signin and signup form. It also contains a but...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
[grammar] ~66-~66: Ensure spelling is correct
Context: ...agicAuth` widget to create a magic link signIn form. ```dart SupaMagicAuth( redirec...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
apps/docs/content/guides/auth/auth-helpers/nextjs.mdx
[uncategorized] ~11-~11: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...Use the new @supabase/ssr package for Server Side Authentication. @supabase/ssr takes t...
(EN_COMPOUND_ADJECTIVE_INTERNAL)
[style] ~253-~253: Consider removing “of” to be more concise
Context: .../auth/auth-helpers/nextjs#server-side). All of the [supabase-js authentication strategies]...
(ALL_OF_THE)
[grammar] ~401-~401: Use a hyphen to join words.
Context: ...rocess from form submissions. #### Sign up route <Tabs scrollable size="sma...
(QB_NEW_EN_HYPHEN)
[style] ~803-~803: Consider a more concise word here.
Context: ...server-side. In order to use Supabase in Server Components, you ...
(IN_ORDER_TO_PREMIUM)
apps/docs/content/_partials/auth_helpers.mdx
[uncategorized] ~3-~3: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...Use the new @supabase/ssr package for Server Side Authentication. @supabase/ssr takes t...
(EN_COMPOUND_ADJECTIVE_INTERNAL)
apps/docs/content/guides/auth/auth-helpers/sveltekit.mdx
[uncategorized] ~11-~11: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...Use the new @supabase/ssr package for Server Side Authentication. @supabase/ssr takes t...
(EN_COMPOUND_ADJECTIVE_INTERNAL)
[style] ~215-~215: Consider a more concise word here.
Context: ... ### Generate types from your database In order to get the most out of TypeScript and its ...
(IN_ORDER_TO_PREMIUM)
[style] ~242-~242: Consider removing “of” to be more concise
Context: ...th/auth-helpers/sveltekit#server-side). All of the [supabase-js authentication strategies]...
(ALL_OF_THE)
[style] ~386-~386: Consider a more concise word here.
Context: ...tener in the root +layout.svelte file in order to catch Supabase events being triggered. ...
(IN_ORDER_TO_PREMIUM)
[grammar] ~788-~788: Use a hyphen to join words.
Context: ...nt-side data fetching with RLS For [row level security](/docs/guides/database/po...
(QB_NEW_EN_HYPHEN)
[style] ~918-~918: This phrase is redundant. Consider using “inside”.
Context: ...etup our Supabase client for the server inside of a hooks.server.ts file. <Tabs scro...
(OUTSIDE_OF)
[style] ~989-~989: Consider a more concise word here.
Context: ... client [#migration-initialize-client] In order to use the Supabase library in your client...
(IN_ORDER_TO_PREMIUM)
[grammar] ~1085-~1085: Use a hyphen to join words.
Context: ...s.client.ts` in our project for Supabase related code. #### Types [#migration-ty...
(QB_NEW_EN_HYPHEN)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build
- GitHub Check: typecheck
🔇 Additional comments (10)
apps/docs/content/guides/auth/auth-helpers/sveltekit.mdx (1)
9-13: Clear deprecation notice.The deprecation warning is prominently placed and provides a migration path to
@supabase/ssr. Good documentation practice for legacy content.apps/docs/content/guides/auth/auth-helpers/nextjs.mdx (1)
59-61: Non-standard environment variable naming.The documentation uses
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEYbut the standard Supabase convention isNEXT_PUBLIC_SUPABASE_ANON_KEY. This inconsistency could confuse users following other Supabase documentation.Please verify whether this naming convention is intentional for this documentation or should be aligned with the standard
NEXT_PUBLIC_SUPABASE_ANON_KEYused elsewhere in Supabase docs.apps/docs/content/guides/auth/auth-helpers.mdx (1)
1-50: LGTM!The overview page is well-structured with clear navigation to framework-specific guides and consistent deprecation messaging.
apps/docs/content/guides/auth/auth-helpers/remix.mdx (1)
1-855: LGTM overall!The Remix Auth Helpers documentation is comprehensive with good coverage of server-side and client-side patterns. The deprecation notice is clear and provides migration guidance.
apps/docs/content/guides/auth/auth-helpers/auth-ui.mdx (1)
129-135: Fix broken relative links in Auth UI documentation.The relative links at lines 129-135 contain two broken references:
../auth-emailshould be../auth-email-passwordless(the actual filename)../auth-magic-linkhas no corresponding file and should be removed or updatedThe
../social-loginlink is correct and resolves properly.⛔ Skipped due to learnings
Learnt from: dnywh Repo: supabase/supabase PR: 41215 File: apps/design-system/content/docs/accessibility.mdx:30-30 Timestamp: 2025-12-11T00:21:01.839Z Learning: In apps/design-system/content/docs/, MDX files use different relative path formats based on their location: root-level docs use `components/button` format, while subdirectory docs (ui-patterns/, components/) use `../components/button` format for linking to components.apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts (1)
916-927: LGTM - Auth UI navigation section follows existing patterns.The navigation structure correctly adds the Auth UI subsection with proper
enabledflag and follows the established conventions for section headers withurl: undefined.apps/www/lib/redirects.js (2)
1302-1305: Redirect change correctly supports restored documentation.The change from the wildcard pattern
/docs/guides/auth/auth-helpers/:path*to the specific path/docs/guides/auth/auth-helpers/auth-ui-overviewis appropriate. The wildcard would have redirected all auth-helpers subpaths (including the newly restored pages) to the migration guide, which would break the restored documentation.
2160-2164: New redirect for Next.js server components consolidation looks correct.This permanent redirect consolidates the nextjs-server-components path to the main nextjs auth-helpers page.
apps/docs/content/guides/auth/auth-helpers/nextjs-pages.mdx (1)
9-15: Deprecation notice is clear and helpful.The admonition properly warns users about the deprecated package and provides clear migration guidance with links to the new
@supabase/ssrpackage and the Next.js Server-Side Auth guide.apps/docs/content/guides/auth/auth-helpers/flutter-auth-ui.mdx (1)
99-118: Review the link target carefully—the#providersanchor depends on partial template rendering.The relative path
../../auth#providerscorrectly resolves toguides/auth.mdx. However, the auth.mdx file uses a conditional partial include for providers content. The#providersanchor exists in_partials/providers.mdx(as## Providers), not directly inauth.mdx. Verify that the documentation build system properly renders this conditional partial and generates the anchor at the expected location when the link is followed.
| @@ -0,0 +1,5 @@ | |||
| <Admonition type="caution"> | |||
|
|
|||
| The Auth helpers package is deprecated. Use the new `@supabase/ssr` package for Server Side Authentication. `@supabase/ssr` takes the core concepts of the Auth Helpers package and makes them available to any server framework. Read out the [migration doc](/docs/guides/auth/server-side/migrating-to-ssr-from-auth-helpers) to learn more. | |||
There was a problem hiding this comment.
Typo: "Read out the" should be "Read the".
-The Auth helpers package is deprecated. Use the new `@supabase/ssr` package for Server Side Authentication. `@supabase/ssr` takes the core concepts of the Auth Helpers package and makes them available to any server framework. Read out the [migration doc](/docs/guides/auth/server-side/migrating-to-ssr-from-auth-helpers) to learn more.
+The Auth helpers package is deprecated. Use the new `@supabase/ssr` package for Server-Side Authentication. `@supabase/ssr` takes the core concepts of the Auth Helpers package and makes them available to any server framework. Read the [migration doc](/docs/guides/auth/server-side/migrating-to-ssr-from-auth-helpers) to learn more.📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| The Auth helpers package is deprecated. Use the new `@supabase/ssr` package for Server Side Authentication. `@supabase/ssr` takes the core concepts of the Auth Helpers package and makes them available to any server framework. Read out the [migration doc](/docs/guides/auth/server-side/migrating-to-ssr-from-auth-helpers) to learn more. | |
| The Auth helpers package is deprecated. Use the new `@supabase/ssr` package for Server-Side Authentication. `@supabase/ssr` takes the core concepts of the Auth Helpers package and makes them available to any server framework. Read the [migration doc](/docs/guides/auth/server-side/migrating-to-ssr-from-auth-helpers) to learn more. |
🧰 Tools
🪛 LanguageTool
[uncategorized] ~3-~3: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...Use the new @supabase/ssr package for Server Side Authentication. @supabase/ssr takes t...
(EN_COMPOUND_ADJECTIVE_INTERNAL)
🤖 Prompt for AI Agents
In apps/docs/content/_partials/auth_helpers.mdx around line 3, the sentence
contains a typo: "Read out the [migration doc]..." should be corrected to "Read
the [migration doc]..."; update the text to remove "out" so it reads "Read the
[migration
doc](/docs/guides/auth/server-side/migrating-to-ssr-from-auth-helpers) to learn
more."
| const { | ||
| data: { user }, | ||
| } = await supabase.auth.getUser() | ||
|
|
||
| if (!session) | ||
| return { | ||
| redirect: { | ||
| destination: '/', | ||
| permanent: false, | ||
| }, | ||
| } | ||
|
|
There was a problem hiding this comment.
Bug: Undefined variable session in code example.
The code destructures user from supabase.auth.getUser() on lines 354-356, but line 358 checks if (!session) which is undefined. This should check if (!user) instead.
const {
data: { user },
} = await supabase.auth.getUser()
- if (!session)
+ if (!user)
return {
redirect: {
destination: '/',
permanent: false,
},
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const { | |
| data: { user }, | |
| } = await supabase.auth.getUser() | |
| if (!session) | |
| return { | |
| redirect: { | |
| destination: '/', | |
| permanent: false, | |
| }, | |
| } | |
| const { | |
| data: { user }, | |
| } = await supabase.auth.getUser() | |
| if (!user) | |
| return { | |
| redirect: { | |
| destination: '/', | |
| permanent: false, | |
| }, | |
| } |
🤖 Prompt for AI Agents
In apps/docs/content/guides/auth/auth-helpers/nextjs-pages.mdx around lines 354
to 365, the example checks an undefined variable `session`; replace that check
with `if (!user)` (or otherwise verify the correct variable from
supabase.auth.getUser()) so the guard uses the destructured `user` value
returned above and returns the redirect when the user is missing.
|
|
||
| return { | ||
| props: { | ||
| initialSession: session, | ||
| user: session.user, | ||
| }, | ||
| } | ||
| } |
There was a problem hiding this comment.
Bug: References undefined session variable in migration example.
The migration example retrieves user from supabase.auth.getUser() but the props reference session and session.user which are undefined.
return {
props: {
- initialSession: session,
- user: session.user,
+ initialSession: null,
+ user,
},
}Alternatively, if initialSession is needed, the code should call supabase.auth.getSession() instead of getUser().
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| return { | |
| props: { | |
| initialSession: session, | |
| user: session.user, | |
| }, | |
| } | |
| } | |
| return { | |
| props: { | |
| initialSession: null, | |
| user, | |
| }, | |
| } | |
| } |
🤖 Prompt for AI Agents
In apps/docs/content/guides/auth/auth-helpers/nextjs-pages.mdx around lines
796-803, the returned props reference a nonexistent session variable
(initialSession: session, user: session.user) even though the example called
supabase.auth.getUser(); fix by either (A) if you only fetched the user, return
props: { user } (rename the variable to user or destructure from getUser
response) and remove initialSession, or (B) if initialSession is required, call
supabase.auth.getSession() instead of getUser() and then return initialSession:
session and user: session.user; update variable names accordingly so props refer
to defined locals.
| export async function middleware(req) { | ||
| const res = NextResponse.next() | ||
|
|
||
| // Create a Supabase client configured to use cookies | ||
| const supabase = createMiddlewareClient({ req, res }) | ||
|
|
||
| // Refresh session if expired - required for Server Components | ||
| await supabase.auth.getUser() | ||
|
|
||
| return res | ||
| } |
There was a problem hiding this comment.
Inconsistency between JS and TS middleware examples.
The JavaScript example uses supabase.auth.getUser() (Line 93) while the TypeScript example uses supabase.auth.getSession() (Line 133). Both should use the same method for consistency. The getUser() approach is generally preferred as it validates the session with the server.
// In the TypeScript example (line 133)
- await supabase.auth.getSession()
+ await supabase.auth.getUser()Also applies to: 119-136
🤖 Prompt for AI Agents
In apps/docs/content/guides/auth/auth-helpers/nextjs.mdx around lines 86-96 and
119-136, the JS and TS middleware examples are inconsistent: the JS example
calls supabase.auth.getUser() while the TS example calls
supabase.auth.getSession(). Replace the getSession() call(s) in the TypeScript
example with supabase.auth.getUser() so both examples use the same
server-validated method, and ensure any TypeScript typings/await handling
reflect getUser()'s return shape.
| <Admonition type="note"> | ||
|
|
||
| Next.js Server Actions are currently in `alpha` so may change without notice. | ||
|
|
||
| </Admonition> |
There was a problem hiding this comment.
Outdated information: Server Actions are no longer in alpha.
Server Actions became stable in Next.js 14. This note about them being in "alpha" is outdated and may confuse readers.
-<Admonition type="note">
-
-Next.js Server Actions are currently in `alpha` so may change without notice.
-
-</Admonition>📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| <Admonition type="note"> | |
| Next.js Server Actions are currently in `alpha` so may change without notice. | |
| </Admonition> |
🤖 Prompt for AI Agents
In apps/docs/content/guides/auth/auth-helpers/nextjs.mdx around lines 875 to
879, the Admonition states Server Actions are in "alpha" which is outdated;
update the note to reflect that Server Actions are stable as of Next.js 14 (or
remove the alpha warning). Replace the admonition text with an accurate, concise
statement such as noting that Server Actions are stable in Next.js 14 (and
optionally link to Next.js docs/CHANGELOG), and ensure the phrasing does not
imply they are experimental.
| useEffect(() => { | ||
| const { | ||
| data: { subscription }, | ||
| } = supabase.auth.onAuthStateChange((event, session) => { | ||
| if (session?.access_token !== serverAccessToken) { | ||
| // server and client are out of sync. | ||
| revalidate() | ||
| } | ||
| }) | ||
|
|
||
| return () => { | ||
| subscription.unsubscribe() | ||
| } | ||
| }, [serverAccessToken, supabase, revalidate]) | ||
| ``` |
There was a problem hiding this comment.
Inconsistency between JS and TS examples in auth state change handling.
The TypeScript example (Line 586) includes a check for event !== 'INITIAL_SESSION' to avoid unnecessary revalidation, but the JavaScript example (Line 556) lacks this check. This could cause the JS implementation to revalidate on initial load unnecessarily.
// In the JavaScript example (around line 555-556)
- } = supabase.auth.onAuthStateChange((event, session) => {
- if (session?.access_token !== serverAccessToken) {
+ } = supabase.auth.onAuthStateChange((event, session) => {
+ if (event !== 'INITIAL_SESSION' && session?.access_token !== serverAccessToken) {Also applies to: 582-596
🤖 Prompt for AI Agents
In apps/docs/content/guides/auth/auth-helpers/remix.mdx around lines 552-566
(and similarly apply to lines 582-596), the JavaScript useEffect handling
supabase.auth.onAuthStateChange is missing the TypeScript check for event !==
'INITIAL_SESSION'; update the JS example to only call revalidate when the event
is not 'INITIAL_SESSION' and when the session access token differs from the
serverAccessToken, and ensure the cleanup still unsubscribes the subscription;
mirror the same conditional logic used in the TypeScript example to avoid
unnecessary revalidation on initial load.
| event.locals.safeGetSession = async () => { | ||
| const { | ||
| data: { user }, | ||
| error, | ||
| } = await supabase.auth.getUser() | ||
| if (error) { | ||
| return { session: null, user: null } | ||
| } | ||
|
|
||
| const { | ||
| data: { session }, | ||
| } = await event.locals.supabase.auth.getSession() | ||
| return { session, user } | ||
| } |
There was a problem hiding this comment.
Critical: Undefined variable supabase in safeGetSession function.
Line 87 references supabase.auth.getUser(), but the variable supabase is not defined in this scope. It should reference event.locals.supabase instead. Users copying this code will encounter a ReferenceError at runtime.
Apply this diff to fix the undefined variable:
event.locals.safeGetSession = async () => {
const {
data: { user },
error,
- } = await supabase.auth.getUser()
+ } = await event.locals.supabase.auth.getUser()
if (error) {
return { session: null, user: null }
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| event.locals.safeGetSession = async () => { | |
| const { | |
| data: { user }, | |
| error, | |
| } = await supabase.auth.getUser() | |
| if (error) { | |
| return { session: null, user: null } | |
| } | |
| const { | |
| data: { session }, | |
| } = await event.locals.supabase.auth.getSession() | |
| return { session, user } | |
| } | |
| event.locals.safeGetSession = async () => { | |
| const { | |
| data: { user }, | |
| error, | |
| } = await event.locals.supabase.auth.getUser() | |
| if (error) { | |
| return { session: null, user: null } | |
| } | |
| const { | |
| data: { session }, | |
| } = await event.locals.supabase.auth.getSession() | |
| return { session, user } | |
| } |
🤖 Prompt for AI Agents
In apps/docs/content/guides/auth/auth-helpers/sveltekit.mdx around lines 83 to
96, the safeGetSession function references an undefined variable supabase
(supabase.auth.getUser()); change that call to use
event.locals.supabase.auth.getUser() so it uses the local Supabase client in
this scope, ensuring both user and session calls consistently reference
event.locals.supabase and avoid the ReferenceError at runtime.
| event.locals.safeGetSession = async () => { | ||
| const { | ||
| data: { user }, | ||
| error, | ||
| } = await supabase.auth.getUser() | ||
| if (error) { | ||
| return { session: null, user: null } | ||
| } | ||
|
|
||
| const { | ||
| data: { session }, | ||
| } = await event.locals.supabase.auth.getSession() | ||
| return { session, user } | ||
| } |
There was a problem hiding this comment.
Critical: Undefined variable supabase in safeGetSession function.
Line 134 has the same issue as the JavaScript example above. The variable supabase is not defined in this scope and should reference event.locals.supabase.
Apply this diff to fix the undefined variable:
event.locals.safeGetSession = async () => {
const {
data: { user },
error,
- } = await supabase.auth.getUser()
+ } = await event.locals.supabase.auth.getUser()
if (error) {
return { session: null, user: null }
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| event.locals.safeGetSession = async () => { | |
| const { | |
| data: { user }, | |
| error, | |
| } = await supabase.auth.getUser() | |
| if (error) { | |
| return { session: null, user: null } | |
| } | |
| const { | |
| data: { session }, | |
| } = await event.locals.supabase.auth.getSession() | |
| return { session, user } | |
| } | |
| event.locals.safeGetSession = async () => { | |
| const { | |
| data: { user }, | |
| error, | |
| } = await event.locals.supabase.auth.getUser() | |
| if (error) { | |
| return { session: null, user: null } | |
| } | |
| const { | |
| data: { session }, | |
| } = await event.locals.supabase.auth.getSession() | |
| return { session, user } | |
| } |
🤖 Prompt for AI Agents
In apps/docs/content/guides/auth/auth-helpers/sveltekit.mdx around lines 130 to
143, the safeGetSession function references an undefined variable supabase;
replace those references with event.locals.supabase (i.e., call
event.locals.supabase.auth.getUser() instead of supabase.auth.getUser(), and
ensure any other supabase uses in that function use event.locals.supabase) so
the function uses the injected supabase client from event.locals.
This reverts commit 7415e9f.
Reverts #40986 as redirects don't work and can only check in production :(
Summary by CodeRabbit
Documentation
Chores
✏️ Tip: You can customize this high-level summary in your review settings.