[PR #3688] [CLOSED] Feature/org customand subdomains #4955

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/3688
Author: @Nitish-Naik
Created: 7/29/2025
Status: Closed

Base: mainHead: feature/org-custom-domains


📝 Commits (7)

  • b6ee48c fix: name require signup
  • 5e9e066 feature: allow custom and subdomains
  • a02b915 Merge branch 'main' into feature/org-custom-domains
  • b858115 Merge branch 'main' into feature/org-custom-domains
  • 23ccf1c Update schema.ts
  • 2e6d1ca Update demo/nextjs/middleware.ts
  • a6d76c2 Update packages/better-auth/src/plugins/organization/adapter.ts

📊 Changes

10 files changed (+339 additions, -136 deletions)

View changed files

📝 demo/nextjs/middleware.ts (+15 -0)
docs/content/docs/organizations/custom-domains.mdx (+32 -0)
📝 packages/better-auth/package.json (+6 -2)
📝 packages/better-auth/src/api/routes/sign-up.ts (+13 -0)
📝 packages/better-auth/src/plugins/organization/access/statement.ts (+3 -0)
📝 packages/better-auth/src/plugins/organization/adapter.ts (+12 -0)
📝 packages/better-auth/src/plugins/organization/organization.ts (+8 -0)
packages/better-auth/src/plugins/organization/routes/domain.ts (+157 -0)
📝 packages/better-auth/src/plugins/organization/schema.ts (+3 -0)
📝 pnpm-lock.yaml (+90 -134)

📄 Description

feature : #3153

title: Custom Domains

Custom Domains

Better Auth allows you to use your own custom domains and subdomains for your organizations. This allows you to provide a more branded experience for your users.

Adding a Custom Domain

To add a custom domain, follow these steps:

  1. Go to your organization's settings page.
  2. Navigate to the "Domain" section.
  3. Enter your custom domain and click "Add".

Verifying Your Domain

Once you've added your domain, you'll need to verify it to prove that you own it. To do this, you'll need to add a TXT record to your domain's DNS settings.

  1. You will be provided with a verification token. This token is a unique string that you'll need to add to your DNS records.
  2. Create a new TXT record in your DNS provider's dashboard.
    • Host: _better-auth-verify
    • Value: The verification token you were given.
  3. Save the record and wait for it to propagate. This can take up to 48 hours, but it's usually much faster.
  4. Once the record has propagated, click the "Verify" button in your organization's settings.

If the verification is successful, your custom domain will be active and ready to use.

Removing a Custom Domain

To remove a custom domain, simply click the "Remove" button in your organization's settings.


Summary by cubic

Added support for custom domains and subdomains for organizations, allowing users to set, verify, and remove branded domains through the Better Auth platform.

  • New Features
    • API endpoints to add, verify, and remove custom domains for organizations.
    • DNS-based verification using a TXT record.
    • Middleware to route requests based on verified custom domains.
    • Documentation for setup and management of custom domains.

🔄 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/3688 **Author:** [@Nitish-Naik](https://github.com/Nitish-Naik) **Created:** 7/29/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feature/org-custom-domains` --- ### 📝 Commits (7) - [`b6ee48c`](https://github.com/better-auth/better-auth/commit/b6ee48c3aa86233955a3f53f796e545d1c2ae09d) fix: name require signup - [`5e9e066`](https://github.com/better-auth/better-auth/commit/5e9e066348114e5728efea703c50dcd7cc7d49a0) feature: allow custom and subdomains - [`a02b915`](https://github.com/better-auth/better-auth/commit/a02b915212bac457b20aa179d134353f0fbd93b2) Merge branch 'main' into feature/org-custom-domains - [`b858115`](https://github.com/better-auth/better-auth/commit/b85811547dfe15aee01b67239ef7a8a427469f02) Merge branch 'main' into feature/org-custom-domains - [`23ccf1c`](https://github.com/better-auth/better-auth/commit/23ccf1c0b3097be9a9aa54f88981f8ef0578e8c5) Update schema.ts - [`2e6d1ca`](https://github.com/better-auth/better-auth/commit/2e6d1cabd8cbbdb218edc9b5a469ca63d32c75b8) Update demo/nextjs/middleware.ts - [`a6d76c2`](https://github.com/better-auth/better-auth/commit/a6d76c262b873dd1545e3c7823702b113869ee13) Update packages/better-auth/src/plugins/organization/adapter.ts ### 📊 Changes **10 files changed** (+339 additions, -136 deletions) <details> <summary>View changed files</summary> 📝 `demo/nextjs/middleware.ts` (+15 -0) ➕ `docs/content/docs/organizations/custom-domains.mdx` (+32 -0) 📝 `packages/better-auth/package.json` (+6 -2) 📝 `packages/better-auth/src/api/routes/sign-up.ts` (+13 -0) 📝 `packages/better-auth/src/plugins/organization/access/statement.ts` (+3 -0) 📝 `packages/better-auth/src/plugins/organization/adapter.ts` (+12 -0) 📝 `packages/better-auth/src/plugins/organization/organization.ts` (+8 -0) ➕ `packages/better-auth/src/plugins/organization/routes/domain.ts` (+157 -0) 📝 `packages/better-auth/src/plugins/organization/schema.ts` (+3 -0) 📝 `pnpm-lock.yaml` (+90 -134) </details> ### 📄 Description feature : #3153 --- title: Custom Domains --- # Custom Domains Better Auth allows you to use your own custom domains and subdomains for your organizations. This allows you to provide a more branded experience for your users. ## Adding a Custom Domain To add a custom domain, follow these steps: 1. **Go to your organization's settings page.** 2. **Navigate to the "Domain" section.** 3. **Enter your custom domain and click "Add".** ## Verifying Your Domain Once you've added your domain, you'll need to verify it to prove that you own it. To do this, you'll need to add a `TXT` record to your domain's DNS settings. 1. **You will be provided with a verification token.** This token is a unique string that you'll need to add to your DNS records. 2. **Create a new `TXT` record in your DNS provider's dashboard.** * **Host:** `_better-auth-verify` * **Value:** The verification token you were given. 3. **Save the record and wait for it to propagate.** This can take up to 48 hours, but it's usually much faster. 4. **Once the record has propagated, click the "Verify" button in your organization's settings.** If the verification is successful, your custom domain will be active and ready to use. ## Removing a Custom Domain To remove a custom domain, simply click the "Remove" button in your organization's settings. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Added support for custom domains and subdomains for organizations, allowing users to set, verify, and remove branded domains through the Better Auth platform. - **New Features** - API endpoints to add, verify, and remove custom domains for organizations. - DNS-based verification using a TXT record. - Middleware to route requests based on verified custom domains. - Documentation for setup and management of custom domains. <!-- 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:05:28 -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#4955