[PR #4680] [MERGED] fix(plugins): asynchronous init #22426

Closed
opened 2026-04-15 21:02:20 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4680
Author: @LightTab2
Created: 9/15/2025
Status: Merged
Merged: 9/15/2025
Merged by: @himself65

Base: canaryHead: async-init


📝 Commits (3)

  • bc05bf8 Makes plugin's init possibly asynchronous
  • 4767108 feat: update
  • 3032589 Merge branch 'canary' into async-init

📊 Changes

4 files changed (+53 additions, -7 deletions)

View changed files

📝 packages/better-auth/src/init.test.ts (+22 -0)
📝 packages/better-auth/src/init.ts (+16 -3)
📝 packages/better-auth/src/types/plugins.ts (+8 -4)
packages/better-auth/src/utils/is-promise.ts (+7 -0)

📄 Description

I've run into issue when implementing a custom plugin: init cannot be async.

I believe there's no harm in allowing that.


Summary by cubic

Allow plugin init to be asynchronous, enabling async setup without breaking existing synchronous plugins. runPluginInit is now async and awaited in init; BetterAuthPlugin.init types accept Promise-based returns for context/options (or void).


🔄 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/4680 **Author:** [@LightTab2](https://github.com/LightTab2) **Created:** 9/15/2025 **Status:** ✅ Merged **Merged:** 9/15/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `async-init` --- ### 📝 Commits (3) - [`bc05bf8`](https://github.com/better-auth/better-auth/commit/bc05bf859e2bcd1e8ecc297c1f86878467fce10b) Makes plugin's `init` possibly asynchronous - [`4767108`](https://github.com/better-auth/better-auth/commit/476710878757a47906a3d68e40ec869886e313e3) feat: update - [`3032589`](https://github.com/better-auth/better-auth/commit/30325898b46882eb8ce0ceb9b2bf16b28c03b48c) Merge branch 'canary' into async-init ### 📊 Changes **4 files changed** (+53 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/init.test.ts` (+22 -0) 📝 `packages/better-auth/src/init.ts` (+16 -3) 📝 `packages/better-auth/src/types/plugins.ts` (+8 -4) ➕ `packages/better-auth/src/utils/is-promise.ts` (+7 -0) </details> ### 📄 Description I've run into issue when implementing a custom plugin: `init` cannot be `async`. I believe there's no harm in allowing that. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Allow plugin init to be asynchronous, enabling async setup without breaking existing synchronous plugins. runPluginInit is now async and awaited in init; BetterAuthPlugin.init types accept Promise-based returns for context/options (or void). <!-- 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 21:02:20 -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#22426