convex-js PR 161: Fix Clerk session refresh auth (#54114)
## Summary Fix `ConvexProviderWithClerk` so Clerk session replacement triggers Convex auth setup again. The Clerk adapter already rebuilds its token fetcher when org context changes, but it does not currently react to Clerk `sessionId` changes. In Expo apps using `@clerk/expo`, signing out and signing back in can replace the Clerk session while Convex keeps using the previous token fetch closure. This can leave `useConvexAuth()` loaded but unauthenticated until the app reloads or the provider is manually remounted. Fixes #156. ## Changes - Include Clerk `sessionId` in the auth context values that rebuild `fetchAccessToken`. - Preserve the existing behavior of not depending on `getToken`, since Clerk Expo’s `useAuth` hook is not memoized and previously caused an auth loop. ## Follow-up note I noticed `fetchAccessToken` also reads `sessionClaims?.aud` without including a primitive derived value in the callback dependencies. I left that unchanged here to keep this PR scoped to Clerk session replacement, but it may be worth considering separately if the Convex integration/JWT-template mode can change during a mounted provider lifetime. ## Verification - `npm run typecheck -- --pretty false` - `npm run build` Co-authored-by: Eliot Gevers <eliot.gevers@gmail.com> GitOrigin-RevId: 07caac669cd8f15a50748fec68ef7d76a051f94c
S
Shawn Erquhart committed
7938958c376cc17ab5b8ed308097f8ea98d4f9fd
Parent: 79300d6
Committed by Convex, Inc. <no-reply@convex.dev>
on 7/8/2026, 3:17:39 AM