[GH-ISSUE #3251] Wrong type for hooks context. Wrong documentation #26863

Closed
opened 2026-04-17 17:35:06 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @irg1008 on GitHub (Jul 2, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/3251

Typed value:

Image

Docs:

Image

Originally created by @irg1008 on GitHub (Jul 2, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/3251 Typed value: ![Image](https://github.com/user-attachments/assets/4602434b-2af7-4b8f-8ea7-8bfd01005cb3) Docs: ![Image](https://github.com/user-attachments/assets/94b20fa7-e842-425f-962e-574f687b41da)
GiteaMirror added the locked label 2026-04-17 17:35:06 -05:00
Author
Owner

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

The correct type for hooks context in Better Auth is HookEndpointContext, not MiddlewareInputContext. Both the codebase and the current documentation show that hooks like before and after should receive a single ctx parameter, which provides properties such as path, body, headers, request, query, and context. If you’re seeing MiddlewareInputContext, it’s likely coming from outdated code, a third-party type, or a legacy integration—this type isn’t present in the current Better Auth codebase or docs.

To resolve this, update your hook handlers to use the correct ctx type as shown in the docs, and check for any lingering or custom types in your setup that might be overriding or shadowing the correct types. You can see the accurate usage and type definitions in the hooks documentation and type definitions. If you need help tracking down where the old type is coming from, let me know more about your setup!

To reply, just mention @dosu.


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

<!-- gh-comment-id:3028533880 --> @dosubot[bot] commented on GitHub (Jul 2, 2025): <!-- Answer --> The correct type for hooks context in Better Auth is HookEndpointContext, not MiddlewareInputContext<MiddlewareOptions>. Both the codebase and the current documentation show that hooks like before and after should receive a single ctx parameter, which provides properties such as path, body, headers, request, query, and context. If you’re seeing MiddlewareInputContext<MiddlewareOptions>, it’s likely coming from outdated code, a third-party type, or a legacy integration—this type isn’t present in the current Better Auth codebase or docs. To resolve this, update your hook handlers to use the correct ctx type as shown in the docs, and check for any lingering or custom types in your setup that might be overriding or shadowing the correct types. You can see the accurate usage and type definitions in the [hooks documentation](https://github.com/better-auth/better-auth/blob/5ead4ab2f277a121a1da188c0e172ebb633fb7a0/docs/content/docs/concepts/hooks.mdx) and [type definitions](https://github.com/better-auth/better-auth/blob/5ead4ab2f277a121a1da188c0e172ebb633fb7a0/packages/better-auth/src/types/context.ts). If you need help tracking down where the old type is coming from, let me know more about your setup! <!-- 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/9e593198-e556-45c0-b0b5-07edba735e0e?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/9e593198-e556-45c0-b0b5-07edba735e0e?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/9e593198-e556-45c0-b0b5-07edba735e0e?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/9e593198-e556-45c0-b0b5-07edba735e0e?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/9e593198-e556-45c0-b0b5-07edba735e0e?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/9e593198-e556-45c0-b0b5-07edba735e0e?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/9e593198-e556-45c0-b0b5-07edba735e0e?feedback_type=other)</sup>&nbsp;&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/3251)
Author
Owner

@dagmawibabi commented on GitHub (Jul 12, 2025):

@irg1008 resolved?

<!-- gh-comment-id:3066233973 --> @dagmawibabi commented on GitHub (Jul 12, 2025): @irg1008 resolved?
Author
Owner

@irg1008 commented on GitHub (Jul 13, 2025):

@irg1008 resolved?

Yes I am using the createHook helper

<!-- gh-comment-id:3066632841 --> @irg1008 commented on GitHub (Jul 13, 2025): > @irg1008 resolved? Yes I am using the createHook helper
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#26863