diff --git a/.changeset/orange-eggs-start.md b/.changeset/orange-eggs-start.md new file mode 100644 index 00000000000..ca2d35137ad --- /dev/null +++ b/.changeset/orange-eggs-start.md @@ -0,0 +1,6 @@ +--- +'@clerk/shared': patch +'@clerk/types': patch +--- + +Remove `treatPendingAsSignedOut` from `useSession` and always return pending session diff --git a/packages/shared/src/react/hooks/useSession.ts b/packages/shared/src/react/hooks/useSession.ts index 71ed9669c1c..3a68dbf9d90 100644 --- a/packages/shared/src/react/hooks/useSession.ts +++ b/packages/shared/src/react/hooks/useSession.ts @@ -1,9 +1,9 @@ -import type { PendingSessionOptions, UseSessionReturn } from '@clerk/types'; +import type { UseSessionReturn } from '@clerk/types'; import { eventMethodCalled } from '../../telemetry/events/method-called'; import { useAssertWrappedByClerkProvider, useClerkInstanceContext, useSessionContext } from '../contexts'; -type UseSession = (options?: PendingSessionOptions) => UseSessionReturn; +type UseSession = () => UseSessionReturn; const hookName = `useSession`; /** @@ -55,7 +55,7 @@ const hookName = `useSession`; * * */ -export const useSession: UseSession = (options = {}) => { +export const useSession: UseSession = () => { useAssertWrappedByClerkProvider(hookName); const session = useSessionContext(); @@ -67,13 +67,9 @@ export const useSession: UseSession = (options = {}) => { return { isLoaded: false, isSignedIn: undefined, session: undefined }; } - const pendingAsSignedOut = - session?.status === 'pending' && - (options.treatPendingAsSignedOut ?? clerk.__internal_getOption('treatPendingAsSignedOut')); - const isSignedOut = session === null || pendingAsSignedOut; - if (isSignedOut) { + if (session === null) { return { isLoaded: true, isSignedIn: false, session: null }; } - return { isLoaded: true, isSignedIn: true, session }; + return { isLoaded: true, isSignedIn: clerk.isSignedIn, session }; }; diff --git a/packages/types/src/hooks.ts b/packages/types/src/hooks.ts index 7baac435ea4..7df8d93193d 100644 --- a/packages/types/src/hooks.ts +++ b/packages/types/src/hooks.ts @@ -191,7 +191,7 @@ export type UseSessionReturn = } | { isLoaded: true; - isSignedIn: true; + isSignedIn: boolean; session: SignedInSessionResource; };