[PR #5888] feat: support pass raw function as middleware #14545

Closed
opened 2026-04-13 09:31:31 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/better-auth/better-auth/pull/5888

State: closed
Merged: Yes


Summary by cubic

Support passing raw functions as middleware in plugin hooks, reducing boilerplate and making plugins easier to write. Raw functions are auto-wrapped with createAuthMiddleware and a default matcher.

  • New Features

    • Plugin hooks (before/after) accept either {matcher, handler} or a raw middleware function.
    • Raw functions are wrapped with createAuthMiddleware and use a matcher that always returns true.
  • Refactors

    • optionsMiddleware is no longer re-exported from better-auth.
    • Removed the unused shimEndpoint helper.

Written for commit f053400d86. Summary will update automatically on new commits.

**Original Pull Request:** https://github.com/better-auth/better-auth/pull/5888 **State:** closed **Merged:** Yes --- <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Support passing raw functions as middleware in plugin hooks, reducing boilerplate and making plugins easier to write. Raw functions are auto-wrapped with createAuthMiddleware and a default matcher. - **New Features** - Plugin hooks (before/after) accept either {matcher, handler} or a raw middleware function. - Raw functions are wrapped with createAuthMiddleware and use a matcher that always returns true. - **Refactors** - optionsMiddleware is no longer re-exported from better-auth. - Removed the unused shimEndpoint helper. <sup>Written for commit f053400d8637916be15383e91d90896d0c39f0d9. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. -->
GiteaMirror added the pull-request label 2026-04-13 09:31:31 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#14545