Skip to content

Commit f92fdbc

Browse files
authored
Simplify authentication state management with eagerAuth (#12)
* Simplify authentication state management Remove dependency on accessToken presence for determining authentication state. With eagerAuth enabled, we can rely solely on user presence to determine if authenticated, eliminating race conditions between user and token availability. Changes: - Remove accessToken from useAccessToken destructuring - Determine isAuthenticated based only on !!user - Simplify the authentication flow by removing unnecessary token checks This addresses the issues raised in PR #10 about authentication reliability, particularly in production environments. * update to authkit-nextjs v2.7.1
1 parent 18494fa commit f92fdbc

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

components/ConvexClientProvider.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ export function ConvexClientProvider({ children }: { children: ReactNode }) {
2020

2121
function useAuthFromAuthKit() {
2222
const { user, loading: isLoading } = useAuth();
23-
const { accessToken, getAccessToken, refresh } = useAccessToken();
23+
const { getAccessToken, refresh } = useAccessToken();
2424

25-
const authenticated = !!user && !!accessToken;
25+
const isAuthenticated = !!user;
2626

2727
const fetchAccessToken = useCallback(
2828
async ({ forceRefreshToken }: { forceRefreshToken?: boolean } = {}): Promise<string | null> => {
@@ -46,7 +46,7 @@ function useAuthFromAuthKit() {
4646

4747
return {
4848
isLoading,
49-
isAuthenticated: authenticated,
49+
isAuthenticated,
5050
fetchAccessToken,
5151
};
5252
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"format": "prettier --write ."
2323
},
2424
"dependencies": {
25-
"@workos-inc/authkit-nextjs": "^2.7.0",
25+
"@workos-inc/authkit-nextjs": "^2.7.1",
2626
"convex": "^1.27.0",
2727
"next": "15.4.3",
2828
"react": "^19.0.0",

0 commit comments

Comments
 (0)