[PR #5522] [CLOSED] feat:Components #6058

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5522
Author: @R5dan
Created: 10/23/2025
Status: Closed

Base: canaryHead: components


📝 Commits (2)

📊 Changes

167 files changed (+8986 additions, -395 deletions)

View changed files

📝 demo/nextjs/app/layout.tsx (+4 -0)
📝 demo/nextjs/components/sign-in.tsx (+198 -195)
📝 demo/nextjs/lib/auth-client.ts (+4 -2)
📝 package.json (+1 -1)
📝 packages/better-auth/src/api/index.ts (+1 -1)
📝 packages/better-auth/src/api/routes/account.ts (+2 -2)
📝 packages/better-auth/src/api/routes/callback.ts (+2 -1)
📝 packages/better-auth/src/api/routes/email-verification.ts (+2 -1)
📝 packages/better-auth/src/api/routes/error.ts (+2 -2)
📝 packages/better-auth/src/api/routes/index.ts (+74 -9)
📝 packages/better-auth/src/api/routes/ok.ts (+2 -2)
📝 packages/better-auth/src/api/routes/reset-password.ts (+2 -1)
📝 packages/better-auth/src/api/routes/sign-in.ts (+2 -1)
📝 packages/better-auth/src/api/routes/sign-out.ts (+2 -1)
📝 packages/better-auth/src/api/routes/sign-up.ts (+2 -1)
📝 packages/better-auth/src/api/routes/update-user.ts (+2 -2)
📝 packages/better-auth/src/api/to-auth-endpoints.ts (+2 -2)
📝 packages/better-auth/src/auth.ts (+7 -2)
📝 packages/better-auth/src/client/config.ts (+18 -0)
📝 packages/better-auth/src/client/plugins/index.ts (+1 -0)

...and 80 more files

📄 Description

Add automatically generated components

Adds 2 packages:

  • @better-auth/react
  • @better-auth/components

@better-auth/components generates HAST template for the components, which is then turned into react jsx in @better-auth/react

I have also moved better-auth/client/react to @better-auth/react/client.
As the components generate HAST, it should be easy to add other frameworks, using there equivalent of createElement

Client plugins are able to add config for the components (for example allowing the username plugin to edit the signIn / signUp component)

@himself65 @Bekacru @ping-maxwell can I have some input about how you want this to work (if you even want it) and what components you want etc


Summary by cubic

Adds a HAST-driven components system with two new packages: @better-auth/components (generator) and @better-auth/react (React renderer) to auto-build configurable auth UIs. The demo now uses the new SignIn component via a BetterAuthContext provider.

  • New Features

    • New packages: @better-auth/components (HAST templates) and @better-auth/react (renderer + UI primitives).
    • Pluggable UI config via componentClient; plugins can add/modify Sign In/Sign Up methods (first: form).
    • New BetterAuthContext provider; demo wrapped and SignIn migrated to generated UI.
    • Client gains $components with collected config; type plumbing added to core/client for component configs.
  • Migration

    • Update imports: better-auth/client/react → @better-auth/react/client; plugins from @better-auth/client/plugins (add componentClient()).
    • Wrap your app with BetterAuthContext and render to use generated UI.
    • Access server context as $context.context (direct $context access is deprecated).

🔄 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/5522 **Author:** [@R5dan](https://github.com/R5dan) **Created:** 10/23/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `components` --- ### 📝 Commits (2) - [`132ef59`](https://github.com/better-auth/better-auth/commit/132ef59d6861dcd278a9503fa666a01449f7d9f3) init - [`30f22c9`](https://github.com/better-auth/better-auth/commit/30f22c97d3aa648e7a602e3f551a7e133396a1b9) components ### 📊 Changes **167 files changed** (+8986 additions, -395 deletions) <details> <summary>View changed files</summary> 📝 `demo/nextjs/app/layout.tsx` (+4 -0) 📝 `demo/nextjs/components/sign-in.tsx` (+198 -195) 📝 `demo/nextjs/lib/auth-client.ts` (+4 -2) 📝 `package.json` (+1 -1) 📝 `packages/better-auth/src/api/index.ts` (+1 -1) 📝 `packages/better-auth/src/api/routes/account.ts` (+2 -2) 📝 `packages/better-auth/src/api/routes/callback.ts` (+2 -1) 📝 `packages/better-auth/src/api/routes/email-verification.ts` (+2 -1) 📝 `packages/better-auth/src/api/routes/error.ts` (+2 -2) 📝 `packages/better-auth/src/api/routes/index.ts` (+74 -9) 📝 `packages/better-auth/src/api/routes/ok.ts` (+2 -2) 📝 `packages/better-auth/src/api/routes/reset-password.ts` (+2 -1) 📝 `packages/better-auth/src/api/routes/sign-in.ts` (+2 -1) 📝 `packages/better-auth/src/api/routes/sign-out.ts` (+2 -1) 📝 `packages/better-auth/src/api/routes/sign-up.ts` (+2 -1) 📝 `packages/better-auth/src/api/routes/update-user.ts` (+2 -2) 📝 `packages/better-auth/src/api/to-auth-endpoints.ts` (+2 -2) 📝 `packages/better-auth/src/auth.ts` (+7 -2) 📝 `packages/better-auth/src/client/config.ts` (+18 -0) 📝 `packages/better-auth/src/client/plugins/index.ts` (+1 -0) _...and 80 more files_ </details> ### 📄 Description Add automatically generated components Adds 2 packages: - `@better-auth/react` - `@better-auth/components` `@better-auth/components` generates HAST template for the components, which is then turned into react jsx in `@better-auth/react` I have also moved `better-auth/client/react` to `@better-auth/react/client`. As the components generate HAST, it should be easy to add other frameworks, using there equivalent of `createElement` Client plugins are able to add config for the components (for example allowing the `username` plugin to edit the `signIn` / `signUp` component) @himself65 @Bekacru @ping-maxwell can I have some input about how you want this to work (if you even want it) and what components you want etc <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds a HAST-driven components system with two new packages: @better-auth/components (generator) and @better-auth/react (React renderer) to auto-build configurable auth UIs. The demo now uses the new SignIn component via a BetterAuthContext provider. - New Features - New packages: @better-auth/components (HAST templates) and @better-auth/react (renderer + UI primitives). - Pluggable UI config via componentClient; plugins can add/modify Sign In/Sign Up methods (first: form). - New BetterAuthContext provider; demo wrapped and SignIn migrated to generated UI. - Client gains $components with collected config; type plumbing added to core/client for component configs. - Migration - Update imports: better-auth/client/react → @better-auth/react/client; plugins from @better-auth/client/plugins (add componentClient()). - Wrap your app with BetterAuthContext and render <SignIn /> to use generated UI. - Access server context as $context.context (direct $context access is deprecated). <!-- 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:46:02 -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#6058