[PR #7207] feat: implement user-defined hook positions #32746

Open
opened 2026-04-17 23:29:33 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7207
Author: @Bekacru
Created: 1/8/2026
Status: 🔄 Open

Base: nextHead: feat/hooks-pos


📝 Commits (1)

  • 80f4b8e feat: implement user-defined hook positions

📊 Changes

5 files changed (+590 additions, -39 deletions)

View changed files

📝 docs/content/docs/concepts/hooks.mdx (+76 -0)
📝 packages/better-auth/src/api/to-auth-endpoints.test.ts (+275 -0)
📝 packages/better-auth/src/api/to-auth-endpoints.ts (+55 -17)
📝 packages/better-auth/src/plugins/multi-session/index.ts (+134 -18)
📝 packages/core/src/types/init-options.ts (+50 -4)

📄 Description

Summary by cubic

Adds hook position control so user-defined hooks can run before or after plugin hooks. Also improves multi-session cookie handling for more reliable session switching and cleanup.

  • New Features

    • Support "pre" (default) and "post" positions for before and after hooks.
    • Hooks can be defined as a function or { handler, position }.
    • Updated execution order to respect positions; added tests and docs.
  • Bug Fixes

    • Include the active session token when listing sessions.
    • Correctly set/retain multi-session cookies when switching sessions.
    • Clean up expired/invalid multi-session cookies and avoid duplicates for the same user.
    • Enforce maximum sessions using accurate multi-session counting.

Written for commit 80f4b8e88f. 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/7207 **Author:** [@Bekacru](https://github.com/Bekacru) **Created:** 1/8/2026 **Status:** 🔄 Open **Base:** `next` ← **Head:** `feat/hooks-pos` --- ### 📝 Commits (1) - [`80f4b8e`](https://github.com/better-auth/better-auth/commit/80f4b8e88f0095d2851b2b6c856e16729af4bc75) feat: implement user-defined hook positions ### 📊 Changes **5 files changed** (+590 additions, -39 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/concepts/hooks.mdx` (+76 -0) 📝 `packages/better-auth/src/api/to-auth-endpoints.test.ts` (+275 -0) 📝 `packages/better-auth/src/api/to-auth-endpoints.ts` (+55 -17) 📝 `packages/better-auth/src/plugins/multi-session/index.ts` (+134 -18) 📝 `packages/core/src/types/init-options.ts` (+50 -4) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Adds hook position control so user-defined hooks can run before or after plugin hooks. Also improves multi-session cookie handling for more reliable session switching and cleanup. - **New Features** - Support "pre" (default) and "post" positions for `before` and `after` hooks. - Hooks can be defined as a function or `{ handler, position }`. - Updated execution order to respect positions; added tests and docs. - **Bug Fixes** - Include the active session token when listing sessions. - Correctly set/retain multi-session cookies when switching sessions. - Clean up expired/invalid multi-session cookies and avoid duplicates for the same user. - Enforce maximum sessions using accurate multi-session counting. <sup>Written for commit 80f4b8e88f0095d2851b2b6c856e16729af4bc75. 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-17 23:29:33 -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#32746