[PR #8792] docs(hooks): add example for handling multiple endpoints in a single hook #25116

Open
opened 2026-04-15 22:43:48 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/8792
Author: @Andrew1326
Created: 3/26/2026
Status: 🔄 Open

Base: mainHead: docs/improve-hooks-multiple-endpoints


📝 Commits (1)

  • c51e8a3 docs(hooks): add example for handling multiple endpoints in a single hook

📊 Changes

1 file changed (+29 additions, -0 deletions)

View changed files

📝 docs/content/docs/concepts/hooks.mdx (+29 -0)

📄 Description

Summary

  • Adds a new example showing how to handle multiple endpoints within a single before or after hook using ctx.path conditionals
  • Adds a callout clarifying that hooks take a single middleware function, not an array

Context

Users frequently ask how to set multiple handlers in hooks (e.g., Discussion #8723). The current docs only show single-endpoint examples, which leads to confusion about whether hooks accept an array of handlers.

This small addition makes it clear that you branch on ctx.path inside one middleware function.


Summary by cubic

Add a docs example showing how to handle multiple endpoints in a single hook by branching on ctx.path inside one createAuthMiddleware for before/after. Add a callout clarifying that hooks accept a single middleware function, not an array.

Written for commit c51e8a3d89. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/8792 **Author:** [@Andrew1326](https://github.com/Andrew1326) **Created:** 3/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `docs/improve-hooks-multiple-endpoints` --- ### 📝 Commits (1) - [`c51e8a3`](https://github.com/better-auth/better-auth/commit/c51e8a3d89b1b74ff0ffacaf2489b64f7eb37b1a) docs(hooks): add example for handling multiple endpoints in a single hook ### 📊 Changes **1 file changed** (+29 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/concepts/hooks.mdx` (+29 -0) </details> ### 📄 Description ## Summary - Adds a new example showing how to handle multiple endpoints within a single `before` or `after` hook using `ctx.path` conditionals - Adds a callout clarifying that hooks take a single middleware function, not an array ## Context Users frequently ask how to set multiple handlers in hooks (e.g., [Discussion #8723](https://github.com/better-auth/better-auth/discussions/8723#discussioncomment-16331341)). The current docs only show single-endpoint examples, which leads to confusion about whether hooks accept an array of handlers. This small addition makes it clear that you branch on `ctx.path` inside one middleware function. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Add a docs example showing how to handle multiple endpoints in a single hook by branching on `ctx.path` inside one `createAuthMiddleware` for `before`/`after`. Add a callout clarifying that hooks accept a single middleware function, not an array. <sup>Written for commit c51e8a3d89b1b74ff0ffacaf2489b64f7eb37b1a. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-15 22:43:48 -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#25116