Skip to content

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

update useAutoAuthRedirect to use react-query

Alaister Younga4c334a59f57
diff --git a/studio/hooks/misc/useAutoAuthRedirect.tsx b/studio/hooks/misc/useAutoAuthRedirect.tsx
index eed587eaca7..056db53ef22 100644
--- a/studio/hooks/misc/useAutoAuthRedirect.tsx
+++ b/studio/hooks/misc/useAutoAuthRedirect.tsx
@@ -1,7 +1,7 @@
+import { useQueryClient } from '@tanstack/react-query'
import { auth, getReturnToPath } from 'lib/gotrue'
import { useRouter } from 'next/router'
import { useCallback, useEffect } from 'react'
-import { useSWRConfig } from 'swr'
export function usePushNext() {
const router = useRouter()
@@ -49,7 +49,7 @@ export function usePushNext() {
function useAutoAuthRedirect() {
const pushNext = usePushNext()
- const { cache } = useSWRConfig()
+ const queryClient = useQueryClient()
useEffect(() => {
const searchParams = new URLSearchParams(location.search)
@@ -75,9 +75,7 @@ function useAutoAuthRedirect() {
} = await auth.getSession()
if (session) {
- // .clear() does actually exist on the cache object, but it's not in the types 🤦🏻
- // @ts-ignore
- cache.clear()
+ await queryClient.resetQueries()
await pushNext()
}