[PR #3412] [MERGED] feat(username): add custom username normalization option #4805

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/3412
Author: @bortoz
Created: 7/16/2025
Status: Merged
Merged: 7/18/2025
Merged by: @Bekacru

Base: v1.3Head: feat/username-normalization


📝 Commits (3)

  • 5620ec0 feat(username): add custom username normalization option
  • 5602ee6 add transformer
  • ce926b9 handle nullish values

📊 Changes

4 files changed (+110 additions, -26 deletions)

View changed files

📝 docs/content/docs/plugins/username.mdx (+25 -1)
📝 packages/better-auth/src/plugins/username/index.ts (+24 -7)
📝 packages/better-auth/src/plugins/username/schema.ts (+22 -18)
📝 packages/better-auth/src/plugins/username/username.test.ts (+39 -0)

📄 Description

This PR add a new option to the username plugin that allow customizing the username normalization.

Example:

const auth = betterAuth({
    plugins: [
        username({
            usernameNormalization: (username) => {
                return username.toLowerCase()
                    .replaceAll("0", "o")
                    .replaceAll("3", "e")
                    .replaceAll("4", "a");
            }
        })
    ]
})

Summary by cubic

Added a new option to the username plugin that lets you define a custom function for username normalization or disable normalization entirely.

  • New Features
    • Supports custom username normalization logic through a new option.
    • Updated docs and tests to show how to use custom normalization.

🔄 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/3412 **Author:** [@bortoz](https://github.com/bortoz) **Created:** 7/16/2025 **Status:** ✅ Merged **Merged:** 7/18/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `v1.3` ← **Head:** `feat/username-normalization` --- ### 📝 Commits (3) - [`5620ec0`](https://github.com/better-auth/better-auth/commit/5620ec043edc97f87098897caf6d4e9015fdd8c3) feat(username): add custom username normalization option - [`5602ee6`](https://github.com/better-auth/better-auth/commit/5602ee690849314790594a075a9917a6d466c0e9) add transformer - [`ce926b9`](https://github.com/better-auth/better-auth/commit/ce926b986bdeb441e3e3d95ca056951e67e6c1d5) handle nullish values ### 📊 Changes **4 files changed** (+110 additions, -26 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/username.mdx` (+25 -1) 📝 `packages/better-auth/src/plugins/username/index.ts` (+24 -7) 📝 `packages/better-auth/src/plugins/username/schema.ts` (+22 -18) 📝 `packages/better-auth/src/plugins/username/username.test.ts` (+39 -0) </details> ### 📄 Description This PR add a new option to the username plugin that allow customizing the username normalization. Example: ```ts const auth = betterAuth({ plugins: [ username({ usernameNormalization: (username) => { return username.toLowerCase() .replaceAll("0", "o") .replaceAll("3", "e") .replaceAll("4", "a"); } }) ] }) ``` <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Added a new option to the username plugin that lets you define a custom function for username normalization or disable normalization entirely. - **New Features** - Supports custom username normalization logic through a new option. - Updated docs and tests to show how to use custom normalization. <!-- 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:00: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#4805