-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Prerequisites
- I have searched the repository’s issues and Kinde community to ensure my issue isn’t a duplicate
- I have checked the latest version of the library to replicate my issue
- I have read the contributing guidelines
- I agree to the terms within the code of conduct
Describe the issue
Expected behavior (per Kinde docs): When isLoading is false, the isAuthenticated value should be reliable.
Actual behavior: There's a transient state where isLoading: false, isAuthenticated: false, user: null appears briefly before the correct state isLoading: false, isAuthenticated: true, user: {...}.
Root cause (from SDK source analysis):
- KindeProvider wraps the React SDK's KindeProvider with forceChildrenRender: true
- useKindeBrowserClient → useProvidedKindeAuth calls transformReactAuthStateToNextState(reactState) which is async (decodes JWT tokens)
- The transform reads isLoading directly from the React SDK state
- But user depends on the async token decoding completing
- Result: React SDK's isLoading: false propagates immediately, but user (and thus isAuthenticated) remains null until the async transform completes
Location in SDK:
- dist/src/frontend/hooks/public/use-provided-kinde-auth.cjs.js
- dist/src/frontend/factories/index.cjs.js - transformReactAuthStateToNextState always sets isAuthenticated: false, then constructKindeClientState derives it from !!user
Here are some logs that illustrate the order we get
useAuthProvider.ts:25 [Kinde SDK State] {isLoading: true, isAuthenticated: false, hasUser: false}
useAuthProvider.ts:25 [Kinde SDK State] {isLoading: true, isAuthenticated: false, hasUser: false}
useAuthProvider.ts:25 [Kinde SDK State] {isLoading: false, isAuthenticated: false, hasUser: false}
useAuthProvider.ts:25 [Kinde SDK State] {isLoading: false, isAuthenticated: false, hasUser: false}
useAuthProvider.ts:25 [Kinde SDK State] {isLoading: false, isAuthenticated: true, hasUser: true}
Library URL
https://github.com/kinde-oss/kinde-auth-nextjs/
Library version
2.11.0
Operating system(s)
macOS
Operating system version(s)
Sonoma 14.5
Further environment details
No response
Reproducible test case URL
No response
Additional information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working