[PR #5101] [CLOSED] feat: add getPlugin helper #5775

Closed
opened 2026-03-13 12:35:25 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5101
Author: @jslno
Created: 10/5/2025
Status: Closed

Base: canaryHead: feat/get-plugin-helper


📝 Commits (1)

  • 1f4ce37 feat: add getPlugin helper

📊 Changes

2 files changed (+9 additions, -0 deletions)

View changed files

packages/better-auth/src/utils/get-plugin.ts (+8 -0)
📝 packages/better-auth/src/utils/index.ts (+1 -0)

📄 Description

Basic Usage

const adminPlugin = getPlugin<ReturnType<typeof admin<any>>>(
	"admin",
	ctx.context,
);

adminPlugin?.endpoints.listUsers({
	query: {},
	headers,
});

Summary by cubic

Adds a typed getPlugin helper to fetch a registered plugin by id from the AuthContext. Also exports it from utils for easy access.

  • New Features
    • getPlugin

      (id, context): returns the matching plugin or undefined from context.options.plugins.

    • Exported via utils index for public use.

🔄 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/5101 **Author:** [@jslno](https://github.com/jslno) **Created:** 10/5/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `feat/get-plugin-helper` --- ### 📝 Commits (1) - [`1f4ce37`](https://github.com/better-auth/better-auth/commit/1f4ce37443547b4e52679e75c1b2d53da4a0c021) feat: add getPlugin helper ### 📊 Changes **2 files changed** (+9 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `packages/better-auth/src/utils/get-plugin.ts` (+8 -0) 📝 `packages/better-auth/src/utils/index.ts` (+1 -0) </details> ### 📄 Description ### Basic Usage ```ts const adminPlugin = getPlugin<ReturnType<typeof admin<any>>>( "admin", ctx.context, ); adminPlugin?.endpoints.listUsers({ query: {}, headers, }); ``` <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds a typed getPlugin helper to fetch a registered plugin by id from the AuthContext. Also exports it from utils for easy access. - **New Features** - getPlugin<P extends BetterAuthPlugin>(id, context): returns the matching plugin or undefined from context.options.plugins. - Exported via utils index for public use. <!-- 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-03-13 12:35:25 -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#5775