[PR #5222] [CLOSED] feat: add alias plugin #5863

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

📋 Pull Request Information

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

Base: canaryHead: feat/alias-plugin


📝 Commits (10+)

  • 335ac91 feat: add alias plugin
  • 3a1ad5f Merge branch 'canary' into feat/alias-plugin
  • fe6cb1c fix: client type inference & add prefix to server endpoint keys
  • ac44d65 chore: fix tests
  • 4657c1b Merge branch 'canary' into feat/alias-plugin
  • 5e1bb44 feat: optionally transform server endpoint methods
  • 570133f chore: fix tests
  • 412cad3 feat: wrap get actions to prefix path based actions
  • 8a29189 feat: handle prefix for getAtoms
  • 2bc32c0 chore: fix package.json

📊 Changes

28 files changed (+2945 additions, -13 deletions)

View changed files

📝 docs/components/sidebar-content.tsx (+7 -0)
docs/content/docs/plugins/alias.mdx (+301 -0)
📝 packages/better-auth/src/api/index.ts (+9 -1)
📝 packages/better-auth/src/api/to-auth-endpoints.ts (+2 -1)
📝 packages/better-auth/src/client/config.ts (+8 -2)
📝 packages/better-auth/src/client/lynx/index.ts (+1 -1)
📝 packages/better-auth/src/client/plugins/index.ts (+1 -0)
📝 packages/better-auth/src/client/proxy.ts (+5 -1)
📝 packages/better-auth/src/client/react/index.ts (+1 -1)
📝 packages/better-auth/src/client/solid/index.ts (+1 -1)
📝 packages/better-auth/src/client/svelte/index.ts (+1 -1)
📝 packages/better-auth/src/client/vanilla.ts (+1 -1)
📝 packages/better-auth/src/client/vue/index.ts (+1 -1)
packages/better-auth/src/plugins/alias/client.ts (+262 -0)
packages/better-auth/src/plugins/alias/compat/client.ts (+170 -0)
packages/better-auth/src/plugins/alias/compat/index.ts (+104 -0)
packages/better-auth/src/plugins/alias/index.ts (+201 -0)
packages/better-auth/src/plugins/alias/test/alias.test.ts (+194 -0)
packages/better-auth/src/plugins/alias/test/client.test.ts (+489 -0)
packages/better-auth/src/plugins/alias/test/integration.test.ts (+460 -0)

...and 8 more files

📄 Description

Fixes: #3595
Closes: #4278

Resolves endpoint conflicts and adds a compat plugin to preservere interoperability for aliased plugins.
Optionally allows excluding endpoints and modifying type inference, signals, server plugin id and endpoint function names.

Refactored client to pass options to getAtoms to prefix endpoints, and allow passing atomListeners as function to allow lazy loading signals inside aliased client plugin to only prefix specific signals inside compat plugin.


Summary by cubic

Adds a new alias plugin to namespace plugin endpoints with a path prefix on both server and client, preventing conflicts. Adds a compat layer for mixed setups, updates client APIs, and ships docs, exports, and tests.

  • New Features

    • Server: alias(prefix, plugin) prefixes endpoints, middleware, hooks, and rate limits; supports exclude/include endpoints, prefixEndpointMethods, modifyId, and optional type-prefixing; handles special sign-in/up paths; works with nested/empty prefixes.
    • Client: aliasClient(prefix, plugin) prefixes pathMethods, wraps getActions/getAtoms to rewrite URLs, optionally prefixes atoms and type inference, supports function or array atomListeners, updates fetchPlugins, and adjusts inferred server endpoints.
    • Compat: aliasCompat/aliasCompatClient selectively prefix specific endpoints and atoms so non-aliased plugins interoperate with an aliased one.
    • Docs: added usage docs and sidebar link; exported alias/aliasClient and compat helpers; comprehensive server/client tests.
  • Migration

    • No breaking changes.
    • Wrap plugins with the same prefix on server and client; use compat when mixing:
      • Server: alias("/stripe", stripePlugin())
      • Client: aliasClient("/stripe", stripeClient())
      • Compat: aliased.compat(otherPlugin) / aliasCompatClient(aliased, otherClientPlugin)

Written for commit f1868f760e. Summary will update automatically 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/5222 **Author:** [@jslno](https://github.com/jslno) **Created:** 10/10/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `feat/alias-plugin` --- ### 📝 Commits (10+) - [`335ac91`](https://github.com/better-auth/better-auth/commit/335ac91eb74bdfc82700ada063e48b8e92c258a9) feat: add alias plugin - [`3a1ad5f`](https://github.com/better-auth/better-auth/commit/3a1ad5f9843c010638780b39362ab9d368a21f18) Merge branch 'canary' into feat/alias-plugin - [`fe6cb1c`](https://github.com/better-auth/better-auth/commit/fe6cb1cbed896ed00e5b37e0b588fe235075ea05) fix: client type inference & add prefix to server endpoint keys - [`ac44d65`](https://github.com/better-auth/better-auth/commit/ac44d651739149d5f1519e905efa12e9d68b1808) chore: fix tests - [`4657c1b`](https://github.com/better-auth/better-auth/commit/4657c1bec1e142a93c2862eb94c2cdc8a37e10bd) Merge branch 'canary' into feat/alias-plugin - [`5e1bb44`](https://github.com/better-auth/better-auth/commit/5e1bb4472b67b857e039b88ae0d5be97ab18e34e) feat: optionally transform server endpoint methods - [`570133f`](https://github.com/better-auth/better-auth/commit/570133f83f1bcd836542eeb0445a044c2cdb6ade) chore: fix tests - [`412cad3`](https://github.com/better-auth/better-auth/commit/412cad3cc134cda963bd3f66fc6162af6815f60e) feat: wrap get actions to prefix path based actions - [`8a29189`](https://github.com/better-auth/better-auth/commit/8a2918900e91507d9b3a7f6c28abe72022873b60) feat: handle prefix for getAtoms - [`2bc32c0`](https://github.com/better-auth/better-auth/commit/2bc32c0d5b5124218622345c7cd5a5ab50bab297) chore: fix package.json ### 📊 Changes **28 files changed** (+2945 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `docs/components/sidebar-content.tsx` (+7 -0) ➕ `docs/content/docs/plugins/alias.mdx` (+301 -0) 📝 `packages/better-auth/src/api/index.ts` (+9 -1) 📝 `packages/better-auth/src/api/to-auth-endpoints.ts` (+2 -1) 📝 `packages/better-auth/src/client/config.ts` (+8 -2) 📝 `packages/better-auth/src/client/lynx/index.ts` (+1 -1) 📝 `packages/better-auth/src/client/plugins/index.ts` (+1 -0) 📝 `packages/better-auth/src/client/proxy.ts` (+5 -1) 📝 `packages/better-auth/src/client/react/index.ts` (+1 -1) 📝 `packages/better-auth/src/client/solid/index.ts` (+1 -1) 📝 `packages/better-auth/src/client/svelte/index.ts` (+1 -1) 📝 `packages/better-auth/src/client/vanilla.ts` (+1 -1) 📝 `packages/better-auth/src/client/vue/index.ts` (+1 -1) ➕ `packages/better-auth/src/plugins/alias/client.ts` (+262 -0) ➕ `packages/better-auth/src/plugins/alias/compat/client.ts` (+170 -0) ➕ `packages/better-auth/src/plugins/alias/compat/index.ts` (+104 -0) ➕ `packages/better-auth/src/plugins/alias/index.ts` (+201 -0) ➕ `packages/better-auth/src/plugins/alias/test/alias.test.ts` (+194 -0) ➕ `packages/better-auth/src/plugins/alias/test/client.test.ts` (+489 -0) ➕ `packages/better-auth/src/plugins/alias/test/integration.test.ts` (+460 -0) _...and 8 more files_ </details> ### 📄 Description Fixes: #3595 Closes: #4278 Resolves endpoint conflicts and adds a compat plugin to preservere interoperability for aliased plugins. Optionally allows excluding endpoints and modifying type inference, signals, server plugin id and endpoint function names. Refactored client to pass options to `getAtoms` to prefix endpoints, and allow passing `atomListeners` as function to allow lazy loading signals inside aliased client plugin to only prefix specific signals inside compat plugin. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds a new alias plugin to namespace plugin endpoints with a path prefix on both server and client, preventing conflicts. Adds a compat layer for mixed setups, updates client APIs, and ships docs, exports, and tests. - **New Features** - Server: alias(prefix, plugin) prefixes endpoints, middleware, hooks, and rate limits; supports exclude/include endpoints, prefixEndpointMethods, modifyId, and optional type-prefixing; handles special sign-in/up paths; works with nested/empty prefixes. - Client: aliasClient(prefix, plugin) prefixes pathMethods, wraps getActions/getAtoms to rewrite URLs, optionally prefixes atoms and type inference, supports function or array atomListeners, updates fetchPlugins, and adjusts inferred server endpoints. - Compat: aliasCompat/aliasCompatClient selectively prefix specific endpoints and atoms so non-aliased plugins interoperate with an aliased one. - Docs: added usage docs and sidebar link; exported alias/aliasClient and compat helpers; comprehensive server/client tests. - **Migration** - No breaking changes. - Wrap plugins with the same prefix on server and client; use compat when mixing: - Server: alias("/stripe", stripePlugin()) - Client: aliasClient("/stripe", stripeClient()) - Compat: aliased.compat(otherPlugin) / aliasCompatClient(aliased, otherClientPlugin) <sup>Written for commit f1868f760e87e1e215bf7d7b6b6080dce10637c8. Summary will update automatically 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-03-13 12:39:26 -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#5863