[GH-ISSUE #7043] Admin client plugin only exposes checkRolePermission method - other methods missing from types #10713

Closed
opened 2026-04-13 07:01:15 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @yusoofsh on GitHub (Dec 28, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/7043

Description

The admin client plugin (adminClient) only exposes the checkRolePermission method in its TypeScript type definitions. All other admin methods such as listUsers, createUser, setRole, banUser, unbanUser, revokeUserSessions, impersonateUser, and stopImpersonating are not available on the auth.admin object according to TypeScript, even though they should be available based on the plugin's functionality.

Current Status

Impact: Blocking - TypeScript compilation fails when trying to use any admin methods other than checkRolePermission.

Expected Status

All admin plugin methods should be properly typed and accessible on the auth.admin object when using the adminClient plugin, including:

  • listUsers
  • createUser
  • setRole
  • banUser
  • unbanUser
  • revokeUserSessions
  • impersonateUser
  • stopImpersonating

Environment

  • better-auth version: 1.4.9
  • Plugin configuration:
    • Server: admin() plugin enabled in betterAuth config
    • Client: adminClient() plugin enabled in createAuthClient config

Code Example

Client setup (src/lib/auth/client.ts):

import { adminClient } from "better-auth/client/plugins"
import { createAuthClient } from "better-auth/react"

export const auth = createAuthClient({
  plugins: [adminClient()],
})

Usage attempt (src/routes/dashboard/admin/users.tsx:27):

const data = await auth.admin.listUsers({
  query: {
    limit: 10,
    sortBy: "createdAt",
    sortDirection: "desc",
  },
})

TypeScript error: Property 'listUsers' does not exist on type '{ checkRolePermission: ...

Possible Solutions

Verified Option:

  • The admin plugin server endpoints exist and are properly defined in packages/better-auth/src/plugins/admin/routes.ts
  • The client plugin type inference may not be correctly mapping the server plugin's endpoints to the client API

Speculative Option:

  • The $InferServerPlugin mechanism in adminClient may not be properly inferring all endpoint methods from the server admin plugin
  • Type generation or path-to-object mapping for admin routes may need adjustment
Originally created by @yusoofsh on GitHub (Dec 28, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/7043 ### Description The admin client plugin (`adminClient`) only exposes the `checkRolePermission` method in its TypeScript type definitions. All other admin methods such as `listUsers`, `createUser`, `setRole`, `banUser`, `unbanUser`, `revokeUserSessions`, `impersonateUser`, and `stopImpersonating` are not available on the `auth.admin` object according to TypeScript, even though they should be available based on the plugin's functionality. ### Current Status **Impact:** Blocking - TypeScript compilation fails when trying to use any admin methods other than `checkRolePermission`. ### Expected Status All admin plugin methods should be properly typed and accessible on the `auth.admin` object when using the `adminClient` plugin, including: - `listUsers` - `createUser` - `setRole` - `banUser` - `unbanUser` - `revokeUserSessions` - `impersonateUser` - `stopImpersonating` ### Environment - **better-auth version:** 1.4.9 - **Plugin configuration:** - Server: `admin()` plugin enabled in `betterAuth` config - Client: `adminClient()` plugin enabled in `createAuthClient` config ### Code Example **Client setup (src/lib/auth/client.ts):** ```typescript import { adminClient } from "better-auth/client/plugins" import { createAuthClient } from "better-auth/react" export const auth = createAuthClient({ plugins: [adminClient()], }) ``` **Usage attempt (src/routes/dashboard/admin/users.tsx:27):** ```typescript const data = await auth.admin.listUsers({ query: { limit: 10, sortBy: "createdAt", sortDirection: "desc", }, }) ``` TypeScript error: `Property 'listUsers' does not exist on type '{ checkRolePermission: ...` ### Possible Solutions **Verified Option:** - The admin plugin server endpoints exist and are properly defined in `packages/better-auth/src/plugins/admin/routes.ts` - The client plugin type inference may not be correctly mapping the server plugin's endpoints to the client API **Speculative Option:** - The `$InferServerPlugin` mechanism in `adminClient` may not be properly inferring all endpoint methods from the server `admin` plugin - Type generation or path-to-object mapping for admin routes may need adjustment
GiteaMirror added the locked label 2026-04-13 07:01:15 -05:00
Author
Owner

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

It seems that you're experiencing issues with TypeScript type definitions for the adminClient plugin in Better Auth, particularly with methods like listUsers, createUser, etc., not being available as you expected. This is a known issue where the TypeScript inference may not correctly map the server plugin's endpoints to the client API, causing a compilation failure [1].

To resolve this, consider the following steps:

  1. Check the Plugin Configuration: Ensure that the plugin configuration for adminClient() is set up correctly in your createAuthClient call. According to the documentation, you can verify how the roles and permissions are configured.

  2. Verify TypeScript Types: A workaround observed in the community includes explicitly providing type parameters to the adminClient() call, using a type assertion like as Parameters<typeof adminClient>[0] [1]. This forces the TypeScript compiler to recognize the definitions explicitly.

  3. Monitor Updates: Keep an eye on future releases after Better Auth 1.4.9, as issues regarding type definitions are often resolved in subsequent updates. Checking the release notes or recent issues on GitHub can provide insights on any fixes.

If these approaches don’t resolve your issue, I recommend tagging members of the Better Auth team, Beka and Max, with @bekacru and @ping__ respectively, as they can offer more targeted assistance.

What specific admin methods are you looking to utilize, and have you encountered any other issues with the plugin configurations?

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

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3694882737 --> @better-auth-agent[bot] commented on GitHub (Dec 28, 2025): It seems that you're experiencing issues with TypeScript type definitions for the `adminClient` plugin in Better Auth, particularly with methods like `listUsers`, `createUser`, etc., not being available as you expected. This is a known issue where the TypeScript inference may not correctly map the server plugin's endpoints to the client API, causing a compilation failure [[1]](https://github.com/better-auth/better-auth/issues/6642). To resolve this, consider the following steps: 1. **Check the Plugin Configuration**: Ensure that the plugin configuration for `adminClient()` is set up correctly in your `createAuthClient` call. According to the documentation, you can verify how the roles and permissions are configured. 2. **Verify TypeScript Types**: A workaround observed in the community includes explicitly providing type parameters to the `adminClient()` call, using a type assertion like `as Parameters<typeof adminClient>[0]` [[1]](https://github.com/better-auth/better-auth/issues/6642). This forces the TypeScript compiler to recognize the definitions explicitly. 3. **Monitor Updates**: Keep an eye on future releases after Better Auth 1.4.9, as issues regarding type definitions are often resolved in subsequent updates. Checking the release notes or recent issues on GitHub can provide insights on any fixes. If these approaches don’t resolve your issue, I recommend tagging members of the Better Auth team, Beka and Max, with @bekacru and @ping__ respectively, as they can offer more targeted assistance. What specific admin methods are you looking to utilize, and have you encountered any other issues with the plugin configurations? _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

@himself65 commented on GitHub (Dec 30, 2025):

I believe the issue is not a valid concern; we do have a test case that includes all the admin APIs on the client side. And that place you mentioned is not for exposing the type.

5099056444/packages/better-auth/src/plugins/admin/admin.test.ts (L177-L187)

<!-- gh-comment-id:3699170188 --> @himself65 commented on GitHub (Dec 30, 2025): I believe the issue is not a valid concern; we do have a test case that includes all the admin APIs on the client side. And that place you mentioned is not for exposing the type. https://github.com/better-auth/better-auth/blob/50990564441f870f1c91c910952f36f60d54ba1e/packages/better-auth/src/plugins/admin/admin.test.ts#L177-L187
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#10713