Skip to content

Commit 55a67f8

Browse files
committed
small delay
1 parent 48b8ae6 commit 55a67f8

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

dashboard/src/routes/auth/callback.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createFileRoute } from '@tanstack/react-router'
1+
import { createFileRoute, useNavigate } from '@tanstack/react-router'
22
import { useAuth } from '@workos-inc/authkit-react'
33
import { useEffect, useState } from 'react'
44

@@ -9,6 +9,7 @@ export const Route = createFileRoute('/auth/callback')({
99
function AuthCallback() {
1010
const { user, isLoading } = useAuth()
1111
const [error, setError] = useState<string | null>(null)
12+
const navigate = useNavigate()
1213

1314
useEffect(() => {
1415
// Check for error in URL
@@ -21,9 +22,13 @@ function AuthCallback() {
2122
return
2223
}
2324

24-
// If we have a user, redirect to dashboard
25+
// If we have a user, redirect to dashboard using client-side navigation
26+
// This preserves the session state without a full page reload
2527
if (!isLoading && user) {
26-
window.location.href = '/dashboard'
28+
// Small delay to ensure session is fully saved
29+
setTimeout(() => {
30+
navigate({ to: '/dashboard' })
31+
}, 100)
2732
return
2833
}
2934

@@ -32,11 +37,11 @@ function AuthCallback() {
3237
const code = params.get('code')
3338
if (!code) {
3439
setTimeout(() => {
35-
window.location.href = '/'
40+
navigate({ to: '/' })
3641
}, 2000)
3742
}
3843
}
39-
}, [user, isLoading])
44+
}, [user, isLoading, navigate])
4045

4146
if (error) {
4247
return (

0 commit comments

Comments
 (0)