Skip to content

Commit aa9f185

Browse files
authored
chore(clerk-js): Remove treatPendingAsSignedOut from useSession (#6432)
1 parent c69de58 commit aa9f185

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

.changeset/orange-eggs-start.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@clerk/shared': patch
3+
'@clerk/types': patch
4+
---
5+
6+
Remove `treatPendingAsSignedOut` from `useSession` and always return pending session

packages/shared/src/react/hooks/useSession.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import type { PendingSessionOptions, UseSessionReturn } from '@clerk/types';
1+
import type { UseSessionReturn } from '@clerk/types';
22

33
import { eventMethodCalled } from '../../telemetry/events/method-called';
44
import { useAssertWrappedByClerkProvider, useClerkInstanceContext, useSessionContext } from '../contexts';
55

6-
type UseSession = (options?: PendingSessionOptions) => UseSessionReturn;
6+
type UseSession = () => UseSessionReturn;
77

88
const hookName = `useSession`;
99
/**
@@ -55,7 +55,7 @@ const hookName = `useSession`;
5555
* </Tab>
5656
* </Tabs>
5757
*/
58-
export const useSession: UseSession = (options = {}) => {
58+
export const useSession: UseSession = () => {
5959
useAssertWrappedByClerkProvider(hookName);
6060

6161
const session = useSessionContext();
@@ -67,13 +67,9 @@ export const useSession: UseSession = (options = {}) => {
6767
return { isLoaded: false, isSignedIn: undefined, session: undefined };
6868
}
6969

70-
const pendingAsSignedOut =
71-
session?.status === 'pending' &&
72-
(options.treatPendingAsSignedOut ?? clerk.__internal_getOption('treatPendingAsSignedOut'));
73-
const isSignedOut = session === null || pendingAsSignedOut;
74-
if (isSignedOut) {
70+
if (session === null) {
7571
return { isLoaded: true, isSignedIn: false, session: null };
7672
}
7773

78-
return { isLoaded: true, isSignedIn: true, session };
74+
return { isLoaded: true, isSignedIn: clerk.isSignedIn, session };
7975
};

packages/types/src/hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export type UseSessionReturn =
191191
}
192192
| {
193193
isLoaded: true;
194-
isSignedIn: true;
194+
isSignedIn: boolean;
195195
session: SignedInSessionResource;
196196
};
197197

0 commit comments

Comments
 (0)