[GH-ISSUE #6977] Anonymous client throws typescript error when used with multi session #19321

Closed
opened 2026-04-15 18:15:01 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @OkBeiRohan on GitHub (Dec 24, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/6977

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

When both the multiSessionClient() and anonymousClient() are used together, typescript creates a lint error:

./src/components/auth/login/more-login/more-login.tsx:42:55
Type error: Property 'anonymous' does not exist on type '{ social: <FetchOptions extends ClientFetchOption<Partial<{ provider: (string & {}) | "github" | "apple" | "atlassian" | "cognito"
| "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | ... 21 more ... | "vercel"; ... 8 more ...; additionalData?: Record<...> | undefined; }> & Record<..
.'.

  40 |     setLoading(true);
  41 |     try {
> 42 |       const { data, error } = await authClient.signIn.anonymous();
     |                                                       ^
  43 |
  44 |       if (error) {
  45 |         setError(error.message || "Failed to login anonymously");
Next.js build worker exited with code: 1 and signal: null
 ELIFECYCLE  Command failed with exit code 1.

Current vs. Expected behavior

Currently throws a lint error that fails the Next.js build.

What version of Better Auth are you using?

1.4.9

System info

{
  "system": {
    "platform": "win32",
    "arch": "x64",
    "version": "Windows 11 Enterprise",
    "release": "10.0.26100",
    "cpuCount": 16,
    "cpuModel": "11th Gen Intel(R) Core(TM) i7-11850H @ 2.50GHz",
    "totalMemory": "31.72 GB",
    "freeMemory": "8.55 GB"
  },
  "node": {
    "version": "v25.2.1",
    "env": "development"
  },
  "packageManager": {
    "name": "npm",
    "version": "11.7.0"
  },
  "frameworks": [
    {
      "name": "next",
      "version": "16.1.1"
    },
    {
      "name": "react",
      "version": "^19.2.3"
    }
  ],
  "databases": null,
  "betterAuth": {
    "version": "^1.4.9",
    "config": null
  }
}

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

Client

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
  plugins: [
    anonymous(),
    multiSession(),
  ]
});

Additional context

No response

Originally created by @OkBeiRohan on GitHub (Dec 24, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/6977 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce When both the `multiSessionClient()` and `anonymousClient()` are used together, typescript creates a lint error: ```bash ./src/components/auth/login/more-login/more-login.tsx:42:55 Type error: Property 'anonymous' does not exist on type '{ social: <FetchOptions extends ClientFetchOption<Partial<{ provider: (string & {}) | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | ... 21 more ... | "vercel"; ... 8 more ...; additionalData?: Record<...> | undefined; }> & Record<.. .'. 40 | setLoading(true); 41 | try { > 42 | const { data, error } = await authClient.signIn.anonymous(); | ^ 43 | 44 | if (error) { 45 | setError(error.message || "Failed to login anonymously"); Next.js build worker exited with code: 1 and signal: null  ELIFECYCLE  Command failed with exit code 1. ``` ### Current vs. Expected behavior Currently throws a lint error that fails the Next.js build. ### What version of Better Auth are you using? 1.4.9 ### System info ```bash { "system": { "platform": "win32", "arch": "x64", "version": "Windows 11 Enterprise", "release": "10.0.26100", "cpuCount": 16, "cpuModel": "11th Gen Intel(R) Core(TM) i7-11850H @ 2.50GHz", "totalMemory": "31.72 GB", "freeMemory": "8.55 GB" }, "node": { "version": "v25.2.1", "env": "development" }, "packageManager": { "name": "npm", "version": "11.7.0" }, "frameworks": [ { "name": "next", "version": "16.1.1" }, { "name": "react", "version": "^19.2.3" } ], "databases": null, "betterAuth": { "version": "^1.4.9", "config": null } } ``` ### Which area(s) are affected? (Select all that apply) Client ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, plugins: [ anonymous(), multiSession(), ] }); ``` ### Additional context _No response_
GiteaMirror added the lockedbug labels 2026-04-15 18:15:01 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Dec 24, 2025):

It seems you are encountering a TypeScript error when trying to use both multiSessionClient() and anonymousClient() together in your application. The error indicates that the property anonymous does not exist on the type being used.

Based on what I found, this may be related to how certain properties and methods are defined in the Better Auth library, specifically concerning the anonymous plugin. There have been instances where users reported problems integrating anonymous sessions alongside other session types, and the TypeScript definitions can sometimes lead to inconsistencies, particularly with the plugin configurations [2], [6].

To troubleshoot this issue, I recommend the following steps:

  1. Ensure Plugin Versions Are Compatible: Make sure that the versions of the plugins (anonymous and multiSession) you are using are compatible with your version of Better Auth. Sometimes, mismatched plugin versions can cause TypeScript issues.

  2. Review TypeScript Configuration: Make sure that your TypeScript configuration handles optional properties correctly. Setting exactOptionalPropertyTypes: true in your tsconfig.json could potentially reveal or exacerbate type errors.

  3. Look for Open Issues: Since this issue may not be fully resolved, keep an eye on any open issues regarding this specific case in the Better Auth repository to see if there are updates or workarounds provided by the community or the development team [1], [8].

If these steps do not resolve your issue, you may want to tag @bekacru or @ping__ for a more detailed response from the Better Auth team.

Have you tried any of these troubleshooting steps already? Let me know if you need further assistance!

If you need more help, tag @better-auth-agent in a comment so I can respond.

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3689374345 --> @better-auth-agent[bot] commented on GitHub (Dec 24, 2025): It seems you are encountering a TypeScript error when trying to use both `multiSessionClient()` and `anonymousClient()` together in your application. The error indicates that the property `anonymous` does not exist on the type being used. Based on what I found, this may be related to how certain properties and methods are defined in the Better Auth library, specifically concerning the anonymous plugin. There have been instances where users reported problems integrating anonymous sessions alongside other session types, and the TypeScript definitions can sometimes lead to inconsistencies, particularly with the plugin configurations [[2]](https://github.com/better-auth/better-auth/issues/3658), [[6]](https://github.com/better-auth/better-auth/issues/5266). To troubleshoot this issue, I recommend the following steps: 1. **Ensure Plugin Versions Are Compatible**: Make sure that the versions of the plugins (`anonymous` and `multiSession`) you are using are compatible with your version of Better Auth. Sometimes, mismatched plugin versions can cause TypeScript issues. 2. **Review TypeScript Configuration**: Make sure that your TypeScript configuration handles optional properties correctly. Setting `exactOptionalPropertyTypes: true` in your `tsconfig.json` could potentially reveal or exacerbate type errors. 3. **Look for Open Issues**: Since this issue may not be fully resolved, keep an eye on any open issues regarding this specific case in the Better Auth repository to see if there are updates or workarounds provided by the community or the development team [[1]](https://github.com/better-auth/better-auth/pull/5825), [[8]](https://github.com/better-auth/better-auth/issues/6127). If these steps do not resolve your issue, you may want to tag @bekacru or @ping__ for a more detailed response from the Better Auth team. Have you tried any of these troubleshooting steps already? Let me know if you need further assistance! _If you need more help, tag @better-auth-agent in a comment so I can respond._ <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) • [Discord](https://discord.gg/fG2XXEuQX3) • [GitHub](https://github.com/Skyvern-AI/Skyvern) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/fG2XXEuQX3) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/Skyvern-AI/Skyvern)
Author
Owner

@dosubot[bot] commented on GitHub (Dec 24, 2025):

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

This TypeScript error is a known breaking change in Better Auth v1.4.9. Plugin methods like signIn.anonymous are no longer automatically inferred unless you explicitly type your auth client with the correct plugin types. To fix this, you need to use the new AuthClient type helper and import the plugin types, then specify all plugins in the generic parameter. For example:

import { createAuthClient, type AuthClient } from "better-auth/client";
import { anonymousClient, type AnonymousClientPlugin, multiSessionClient, type MultiSessionClientPlugin } from "better-auth/client/plugins";

export const authClient: AuthClient<{
  plugins: [AnonymousClientPlugin, MultiSessionClientPlugin];
}> = createAuthClient({
  plugins: [anonymousClient(), multiSessionClient()],
});

This will restore type safety and make signIn.anonymous available. As a temporary workaround, you can cast the client to any, but you'll lose type safety. You can also try downgrading to v1.4.8 or using the 1.4.10-beta.1 release, which may have improved inference for some setups. More details and examples are in this issue and this discussion.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

<!-- gh-comment-id:3689382422 --> @dosubot[bot] commented on GitHub (Dec 24, 2025): <!-- Greeting --> Hi @OkBeiRohan! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> This TypeScript error is a known breaking change in Better Auth v1.4.9. Plugin methods like signIn.anonymous are no longer automatically inferred unless you explicitly type your auth client with the correct plugin types. To fix this, you need to use the new AuthClient type helper and import the plugin types, then specify all plugins in the generic parameter. For example: ```ts import { createAuthClient, type AuthClient } from "better-auth/client"; import { anonymousClient, type AnonymousClientPlugin, multiSessionClient, type MultiSessionClientPlugin } from "better-auth/client/plugins"; export const authClient: AuthClient<{ plugins: [AnonymousClientPlugin, MultiSessionClientPlugin]; }> = createAuthClient({ plugins: [anonymousClient(), multiSessionClient()], }); ``` This will restore type safety and make signIn.anonymous available. As a temporary workaround, you can cast the client to any, but you'll lose type safety. You can also try downgrading to v1.4.8 or using the 1.4.10-beta.1 release, which may have improved inference for some setups. More details and examples are in [this issue](https://github.com/better-auth/better-auth/issues/6971) and [this discussion](https://github.com/better-auth/better-auth/issues/6965). <!-- 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/4795f191-995c-4b5b-b8e8-a2b78561760f?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/4795f191-995c-4b5b-b8e8-a2b78561760f?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/4795f191-995c-4b5b-b8e8-a2b78561760f?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/4795f191-995c-4b5b-b8e8-a2b78561760f?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/4795f191-995c-4b5b-b8e8-a2b78561760f?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/4795f191-995c-4b5b-b8e8-a2b78561760f?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/4795f191-995c-4b5b-b8e8-a2b78561760f?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20TypeScript%20error%20is%20a%20known%20breaking%20change%20in%20Better%20Auth%20v1.4.9.%20Plugin%20methods%20like%20signIn.anonymous%20are%20no%20longer%20automatically%20inferred%20unless%20you%20explicitly%20type%20your%20auth%20client%20with%20the%20correct%20plugin%20types.%20To%20fix%20this%2C%20you%20need%20to%20use%20the%20new%20AuthClient%20type%20helper%20and%20import%20the%20plugin%20types%2C%20then%20specify%20all%20plugins%20in%20the%20generic%20parameter.%20For%20example%3A%0A%0A%60%60%60ts%0Aimport%20%7B%20createAuthClient%2C%20type%20AuthClient%20%7D%20from%20%22better-auth/client%22%3B%0Aimport%20%7B%20anonymousClient%2C%20type%20AnonymousClientPlugin%2C%20multiSessionClient%2C%20type%20MultiSessionClientPlugin%20%7D%20from%20%22better-auth/client/plugins%22%3B%0A%0Aexport%20const%20authClient%3A%20AuthClient%3C%7B%0A%20%20plugins%3A%20%5BAnonymousClientPlugin%2C%20MultiSessionClientPlugin%5D%3B%0A%7D%3E%20%3D%20createAuthClient%28%7B%0A%20%20plugins%3A%20%5BanonymousClient%28%29%2C%20multiSessionClient%28%29%5D%2C%0A%7D%29%3B%0A%60%60%60%0A%0AThis%20will%20restore%20type%20safety%20and%20make%20signIn.anonymous%20available.%20As%20a%20temporary%20workaround%2C%20you%20can%20cast%20the%20client%20to%20any%2C%20but%20you%27ll%20lose%20type%20safety.%20You%20can%20also%20try%20downgrading%20to%20v1.4.8%20or%20using%20the%201.4.10-beta.1%20release%2C%20which%20may%20have%20improved%20inference%20for%20some%20setups.%20More%20details%20and%20examples%20are%20in%20%5Bthis%20issue%5D%28https%3A//github.com/better-auth/better-auth/issues/6971%29%20and%20%5Bthis%20discussion%5D%28https%3A//github.com/better-auth/better-auth/issues/6965%29.)&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/6977)
Author
Owner

@bytaesu commented on GitHub (Dec 24, 2025):

Hi @OkBeiRohan,

Due to type issues caused by recent changes in the multi-session plugin, we reverted it yesterday. The issue has been resolved in this beta version! Please let me know if you have any questions 🙂

 "better-auth": "1.4.10-beta.1"
<!-- gh-comment-id:3689822536 --> @bytaesu commented on GitHub (Dec 24, 2025): Hi @OkBeiRohan, Due to type issues caused by recent changes in the `multi-session` plugin, we reverted it yesterday. The issue has been resolved in this beta version! Please let me know if you have any questions 🙂 ``` "better-auth": "1.4.10-beta.1" ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#19321