Module '"better-auth"' has no exported member 'createAuthMiddelware'.ts(2305) #60

Closed
opened 2026-03-13 07:30:32 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @zhaopengme on GitHub (Oct 10, 2024).

Module '"better-auth"' has no exported member 'createAuthMiddelware'.ts(2305)
image
thks

Originally created by @zhaopengme on GitHub (Oct 10, 2024). Module '"better-auth"' has no exported member 'createAuthMiddelware'.ts(2305) ![image](https://github.com/user-attachments/assets/50dc4abe-c670-40ea-b547-0f5157fc93ef) thks
Author
Owner

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

you need to import it from "better-auth/plugins"

@Bekacru commented on GitHub (Oct 10, 2024): you need to import it from "better-auth/plugins"
Author
Owner

@zhaopengme commented on GitHub (Oct 10, 2024):

this my code.

import myPlugin from '@/better/plugin';
import { betterAuth } from "better-auth";


export const auth = betterAuth({
 
  emailAndPassword: {
    enabled: true
  },
  plugins: [myPlugin]
});

plugin code

import { createAuthMiddelware } from "better-auth/plugins";

const myPlugin = {
  id: "my-plugin",
  middleware: [
    createAuthMiddelware(async (ctx) => {
      //do something
    })
  ]
};

export default myPlugin;

image

from 0.3.3 to 0.3.5-beta.3

still error.

@zhaopengme commented on GitHub (Oct 10, 2024): this my code. ``` import myPlugin from '@/better/plugin'; import { betterAuth } from "better-auth"; export const auth = betterAuth({ emailAndPassword: { enabled: true }, plugins: [myPlugin] }); ``` plugin code ``` import { createAuthMiddelware } from "better-auth/plugins"; const myPlugin = { id: "my-plugin", middleware: [ createAuthMiddelware(async (ctx) => { //do something }) ] }; export default myPlugin; ``` ![image](https://github.com/user-attachments/assets/5bf8da60-580f-4188-8a75-75a2c3d3343e) from 0.3.3 to 0.3.5-beta.3 still error.
Author
Owner

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

The API had slight changes, and the doc was not updated. I've just updated the doc.

https://www.better-auth.com/docs/concepts/plugins#middleware

@Bekacru commented on GitHub (Oct 10, 2024): The API had slight changes, and the doc was not updated. I've just updated the doc. https://www.better-auth.com/docs/concepts/plugins#middleware
Author
Owner

@zhaopengme commented on GitHub (Oct 10, 2024):

ok, I'll try it later

@zhaopengme commented on GitHub (Oct 10, 2024): ok, I'll try it later
Author
Owner

@MattheousDT commented on GitHub (Oct 11, 2024):

Typo. createAuthMiddelware should be createAuthMiddleware

@MattheousDT commented on GitHub (Oct 11, 2024): Typo. `createAuthMiddelware` should be `createAuthMiddleware`
Author
Owner

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

this should be fixed. feel free to re-open if not.

@Bekacru commented on GitHub (Oct 15, 2024): this should be fixed. feel free to re-open if not.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#60