[PR #7923] [MERGED] feat: support infer init context #15875

Closed
opened 2026-04-13 10:16:46 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7923
Author: @himself65
Created: 2/11/2026
Status: Merged
Merged: 2/11/2026
Merged by: @himself65

Base: canaryHead: himself65/2026/02/11/infer-context


📝 Commits (1)

  • aff9d84 feat: support infer init context

📊 Changes

4 files changed (+48 additions, -4 deletions)

View changed files

📝 packages/better-auth/src/types/auth.ts (+2 -2)
📝 packages/better-auth/src/types/plugins.ts (+22 -1)
📝 packages/better-auth/src/types/types.test.ts (+22 -0)
📝 packages/core/src/types/plugin.ts (+2 -1)

📄 Description

Related: https://github.com/better-auth/better-auth/pull/7746


Summary by cubic

Adds type inference for plugin init context so plugin-provided values are strongly typed on auth.$context.

  • New Features
    • Introduced InferPluginContext and merged it into auth.$context.
    • Plugins can return extra context keys from init; they’re included in $context typing.
    • Prevents conflicts by omitting core AuthContext keys when inferring.
    • Added a test that verifies custom values and helpers are correctly inferred.

Written for commit aff9d84b51. 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/7923 **Author:** [@himself65](https://github.com/himself65) **Created:** 2/11/2026 **Status:** ✅ Merged **Merged:** 2/11/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2026/02/11/infer-context` --- ### 📝 Commits (1) - [`aff9d84`](https://github.com/better-auth/better-auth/commit/aff9d84b511546a7a8f24c02927824657dd9db8c) feat: support infer init context ### 📊 Changes **4 files changed** (+48 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/types/auth.ts` (+2 -2) 📝 `packages/better-auth/src/types/plugins.ts` (+22 -1) 📝 `packages/better-auth/src/types/types.test.ts` (+22 -0) 📝 `packages/core/src/types/plugin.ts` (+2 -1) </details> ### 📄 Description Related: https://github.com/better-auth/better-auth/pull/7746 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds type inference for plugin init context so plugin-provided values are strongly typed on auth.$context. - **New Features** - Introduced InferPluginContext and merged it into auth.$context. - Plugins can return extra context keys from init; they’re included in $context typing. - Prevents conflicts by omitting core AuthContext keys when inferring. - Added a test that verifies custom values and helpers are correctly inferred. <sup>Written for commit aff9d84b511546a7a8f24c02927824657dd9db8c. 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-13 10:16:46 -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#15875