From defe17c57a0fab81c9c37207d90ad4bf3700eea2 Mon Sep 17 00:00:00 2001 From: Laura Beatris <48022589+LauraBeatris@users.noreply.github.com> Date: Fri, 1 Aug 2025 14:07:11 -0300 Subject: [PATCH] Remove `treatPendingAsSignedOut` from `useSession` --- .changeset/sixty-dogs-film.md | 5 +++++ packages/vue/src/composables/useSession.ts | 15 ++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 .changeset/sixty-dogs-film.md diff --git a/.changeset/sixty-dogs-film.md b/.changeset/sixty-dogs-film.md new file mode 100644 index 00000000000..0d627aa392a --- /dev/null +++ b/.changeset/sixty-dogs-film.md @@ -0,0 +1,5 @@ +--- +'@clerk/vue': patch +--- + +Remove `treatPendingAsSignedOut` from `useSession` and always return pending session diff --git a/packages/vue/src/composables/useSession.ts b/packages/vue/src/composables/useSession.ts index 9dd4a463bc7..e251a267183 100644 --- a/packages/vue/src/composables/useSession.ts +++ b/packages/vue/src/composables/useSession.ts @@ -1,11 +1,11 @@ -import type { PendingSessionOptions, UseSessionReturn } from '@clerk/types'; +import type { UseSessionReturn } from '@clerk/types'; import { computed } from 'vue'; import type { ToComputedRefs } from '../utils'; import { toComputedRefs } from '../utils'; import { useClerkContext } from './useClerkContext'; -type UseSession = (options?: PendingSessionOptions) => ToComputedRefs; +type UseSession = () => ToComputedRefs; /** * Returns the current [`Session`](https://clerk.com/docs/references/javascript/session) object which provides @@ -32,23 +32,20 @@ type UseSession = (options?: PendingSessionOptions) => ToComputedRefs * */ -export const useSession: UseSession = (options = {}) => { - const { sessionCtx, ...clerkContext } = useClerkContext(); +export const useSession: UseSession = () => { + const { sessionCtx, clerk } = useClerkContext(); const result = computed(() => { if (sessionCtx.value === undefined) { return { isLoaded: false, isSignedIn: undefined, session: undefined }; } - const pendingAsSignedOut = - sessionCtx.value?.status === 'pending' && - (options.treatPendingAsSignedOut ?? clerkContext.treatPendingAsSignedOut); - const isSignedOut = sessionCtx.value === null || pendingAsSignedOut; + const isSignedOut = sessionCtx.value === null; if (isSignedOut) { return { isLoaded: true, isSignedIn: false, session: null }; } - return { isLoaded: true, isSignedIn: true, session: sessionCtx.value }; + return { isLoaded: true, isSignedIn: !!clerk.value?.isSignedIn, session: sessionCtx.value }; }); return toComputedRefs(result);