[GH-ISSUE #3718] With not react client useSession refetch not exist #9697

Closed
opened 2026-04-13 05:20:58 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @vincehi on GitHub (Jul 31, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/3718

Originally assigned to: @Paola3stefania on GitHub.

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

with a client other than React, refetch doesn't exist on the session hook authClient.useSession().

Current vs. Expected behavior

...

What version of Better Auth are you using?

1.3.4

Provide environment information

...

Which area(s) are affected? (Select all that apply)

Client

Auth config (if applicable)

const authClient = createAuthClient({
	plugins: [
		// stripeClient({
		// 	subscription: true, //if you want to enable subscription management
		// }),
		inferAdditionalFields<typeof auth>(),
	],
});

Additional context

No response

Originally created by @vincehi on GitHub (Jul 31, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/3718 Originally assigned to: @Paola3stefania on GitHub. ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce with a client other than React, refetch doesn't exist on the session hook authClient.useSession(). ### Current vs. Expected behavior ... ### What version of Better Auth are you using? 1.3.4 ### Provide environment information ```bash ... ``` ### Which area(s) are affected? (Select all that apply) Client ### Auth config (if applicable) ```typescript const authClient = createAuthClient({ plugins: [ // stripeClient({ // subscription: true, //if you want to enable subscription management // }), inferAdditionalFields<typeof auth>(), ], }); ``` ### Additional context _No response_
GiteaMirror added the locked label 2026-04-13 05:20:58 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jul 31, 2025):

Hi @vincehi! I'm Dosu and I’m helping the better-auth team.

The refetch method on useSession is only available in the React client. In non-React clients (like Svelte, Solid, or Vue), useSession returns a reactive store or accessor with session data and status flags (such as isPending, isRefetching, error), but does not expose a refetch function. This is by design—these frameworks expect session updates to propagate through their own reactive/store mechanisms, not through an explicit refetch API. If you need to manually refresh session data in a non-React client, you may need to re-invoke useSession or use a framework-specific pattern, such as calling useSession with a fetch function in Nuxt/Vue contexts (docs, code).

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

<!-- gh-comment-id:3140197852 --> @dosubot[bot] commented on GitHub (Jul 31, 2025): <!-- Greeting --> Hi @vincehi! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> The refetch method on useSession is only available in the React client. In non-React clients (like Svelte, Solid, or Vue), useSession returns a reactive store or accessor with session data and status flags (such as isPending, isRefetching, error), but does not expose a refetch function. This is by design—these frameworks expect session updates to propagate through their own reactive/store mechanisms, not through an explicit refetch API. If you need to manually refresh session data in a non-React client, you may need to re-invoke useSession or use a framework-specific pattern, such as calling useSession with a fetch function in Nuxt/Vue contexts ([docs](https://better-auth.com/docs/integrations/nuxt), [code](https://github.com/better-auth/better-auth/blob/33b0635c4dc1a28ce217b4eadecc4ed24092f12e/packages/better-auth/src/client/vue/index.ts)). <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/c6e7bc66-31d3-4fb3-a374-5a320ac57c2e?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/c6e7bc66-31d3-4fb3-a374-5a320ac57c2e?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/c6e7bc66-31d3-4fb3-a374-5a320ac57c2e?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/c6e7bc66-31d3-4fb3-a374-5a320ac57c2e?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/c6e7bc66-31d3-4fb3-a374-5a320ac57c2e?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/c6e7bc66-31d3-4fb3-a374-5a320ac57c2e?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/c6e7bc66-31d3-4fb3-a374-5a320ac57c2e?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/3718)
Author
Owner

@dagmawibabi commented on GitHub (Aug 2, 2025):

@vincehi is the response from Dosu enough?

<!-- gh-comment-id:3146108413 --> @dagmawibabi commented on GitHub (Aug 2, 2025): @vincehi is the response from Dosu enough?
Author
Owner

@vincehi commented on GitHub (Aug 2, 2025):

@vincehi is the response from Dosu enough?

No, the answer is not satisfactory. A refetch method is missing in all other non-react clients

<!-- gh-comment-id:3146353716 --> @vincehi commented on GitHub (Aug 2, 2025): > [@vincehi](https://github.com/vincehi) is the response from Dosu enough? No, the answer is not satisfactory. A refetch method is missing in all other non-react clients
Author
Owner

@kculmback commented on GitHub (Oct 19, 2025):

I ran into this too and found the refetch does actually exist for the useSession hook; it just hasn't been correctly added to the types.

For the time being I'm adding a @ts-expect-error comment:

// +page.svelte
const session = authClient.useSession();

function someFunction() {
  // @ts-expect-error
  await $session.refetch?.();
}

The optional chaining is just to be on the safe side. You could also probably manually cast the returned type of useSession.

This PR should do the trick once it is merged: https://github.com/better-auth/better-auth/pull/4367

<!-- gh-comment-id:3419092378 --> @kculmback commented on GitHub (Oct 19, 2025): I ran into this too and found the `refetch` does actually exist for the `useSession` hook; it just hasn't been correctly added to the types. For the time being I'm adding a `@ts-expect-error` comment: ``` // +page.svelte const session = authClient.useSession(); function someFunction() { // @ts-expect-error await $session.refetch?.(); } ``` The optional chaining is just to be on the safe side. You could also probably manually cast the returned type of `useSession`. This PR should do the trick once it is merged: https://github.com/better-auth/better-auth/pull/4367
Author
Owner

@brennerm commented on GitHub (Nov 18, 2025):

@kculmback Great find 👍

<!-- gh-comment-id:3547495988 --> @brennerm commented on GitHub (Nov 18, 2025): @kculmback Great find 👍
Author
Owner

@Paola3stefania commented on GitHub (Jan 11, 2026):

Looking at this :)

<!-- gh-comment-id:3733758615 --> @Paola3stefania commented on GitHub (Jan 11, 2026): Looking at this :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#9697