The plugins that returns the functions was broken #131

Closed
opened 2026-03-13 07:34:35 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @rachhen on GitHub (Oct 23, 2024).

Describe the bug
The functions of plugin that returns from createAuthClient can't use as a hook on the client. The typeof that hooks is an object not function. When I call hook and log it return Promise instead of data.

To Reproduce
Steps to reproduce the behavior:

  1. Add plugin to the createAuthClient
  2. Go to component
  3. Use the hooks
  4. Got error

Expected behavior
It should be use as hook and returns data instead of Promise and no Typescript error.

Screenshots
If applicable, add screenshots to help explain your problem.
image

Desktop (please complete the following information):

  • OS: MacOS
  • Browser Chrome
  • Version 0.5.3-beta.17

Additional context

The client:

export const authClient = createAuthClient({
  fetchOptions: {
    onError(e) {
      if (e.error.status === 429) {
        toast.error("Too many requests. Please try again later.");
      }
    },
  },

  plugins: [
    adminClient(),
    organizationClient(),
    passkeyClient(),
    twoFactorClient({
      redirect: true,
      twoFactorPage: "/two-factor",
    }),
  ],
});

Component

export function OrganizationDropdown() {
  const organizations = authClient.useListOrganizations();

  console.log(organizations)

return <div></div>
}

Typescript error:

This expression is not callable.
  Type 'PreinitializedWritableAtom<{ data: { id: string; name: string; slug: string; createdAt: Date; logo?: string | undefined; metadata?: any; }[] | null; error: BetterFetchError | null; isPending: boolean; isRefetching: boolean; }>' has no call signatures.

The log result:

Promise { <pending> }
Originally created by @rachhen on GitHub (Oct 23, 2024). **Describe the bug** The functions of plugin that returns from `createAuthClient` can't use as a hook on the client. The typeof that hooks is an object not function. When I call hook and log it return `Promise` instead of data. **To Reproduce** Steps to reproduce the behavior: 1. Add plugin to the `createAuthClient` 2. Go to component 3. Use the hooks 4. Got error **Expected behavior** It should be use as hook and returns data instead of Promise and no Typescript error. **Screenshots** If applicable, add screenshots to help explain your problem. <img width="824" alt="image" src="https://github.com/user-attachments/assets/d978974d-8631-4ab6-b43e-077cb70210e7"> **Desktop (please complete the following information):** - OS: MacOS - Browser Chrome - Version 0.5.3-beta.17 **Additional context** The client: ```ts export const authClient = createAuthClient({ fetchOptions: { onError(e) { if (e.error.status === 429) { toast.error("Too many requests. Please try again later."); } }, }, plugins: [ adminClient(), organizationClient(), passkeyClient(), twoFactorClient({ redirect: true, twoFactorPage: "/two-factor", }), ], }); ``` Component ```tsx export function OrganizationDropdown() { const organizations = authClient.useListOrganizations(); console.log(organizations) return <div></div> } ``` Typescript error: ```ts This expression is not callable. Type 'PreinitializedWritableAtom<{ data: { id: string; name: string; slug: string; createdAt: Date; logo?: string | undefined; metadata?: any; }[] | null; error: BetterFetchError | null; isPending: boolean; isRefetching: boolean; }>' has no call signatures. ``` The log result: ```ts Promise { <pending> } ```
Author
Owner

@Bekacru commented on GitHub (Oct 23, 2024):

make sure you import the client from "better-auth/react"

@Bekacru commented on GitHub (Oct 23, 2024): make sure you import the client from "better-auth/react"
Author
Owner

@rachhen commented on GitHub (Oct 23, 2024):

It work thank you

@rachhen commented on GitHub (Oct 23, 2024): It work thank you
Author
Owner

@productdevbook commented on GitHub (Dec 3, 2024):

vue problem

CleanShot 2024-12-04 at 00 24 49@2x

@productdevbook commented on GitHub (Dec 3, 2024): vue problem ![CleanShot 2024-12-04 at 00 24 49@2x](https://github.com/user-attachments/assets/b123dbe2-4cdd-4f34-8b78-14085915308f)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#131