[GH-ISSUE #3544] isUsernameAvailable is not working #18268

Closed
opened 2026-04-15 16:41:22 -05:00 by GiteaMirror · 12 comments
Owner

Originally created by @pranavmappoli on GitHub (Jul 22, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/3544

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Check if username is available
To check if a username is available, you can use the isUsernameAvailable function provided by the client.

auth-client.ts

const response = await authClient.isUsernameAvailable({
username: "new-username"
});

if(response.data?.available) {
console.log("Username is available");
} else {
console.log("Username is not available");
}

Current vs. Expected behavior

it should work

What version of Better Auth are you using?

latest

Provide environment information

apple

Which area(s) are affected? (Select all that apply)

Client

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
});

Additional context

No response

Originally created by @pranavmappoli on GitHub (Jul 22, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/3544 ### Is this suited for github? - [ ] Yes, this is suited for github ### To Reproduce [Check if username is available](https://www.better-auth.com/docs/plugins/username#check-if-username-is-available) To check if a username is available, you can use the isUsernameAvailable function provided by the client. auth-client.ts const response = await authClient.isUsernameAvailable({ username: "new-username" }); if(response.data?.available) { console.log("Username is available"); } else { console.log("Username is not available"); } ### Current vs. Expected behavior it should work ### What version of Better Auth are you using? latest ### Provide environment information ```bash apple ``` ### Which area(s) are affected? (Select all that apply) Client ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, }); ``` ### Additional context _No response_
GiteaMirror added the lockedbug labels 2026-04-15 16:41:22 -05:00
Author
Owner

@pranavmappoli commented on GitHub (Jul 22, 2025):

seems the method is not available (getting typescript error)
as well as when called it return 404

<!-- gh-comment-id:3102343140 --> @pranavmappoli commented on GitHub (Jul 22, 2025): seems the method is not available (getting typescript error) as well as when called it return 404
Author
Owner

@dosubot[bot] commented on GitHub (Jul 22, 2025):

The isUsernameAvailable method is only available if the Username plugin is enabled on both your server and client configs. In your provided config, only emailAndPassword is enabled—so the method is missing from the client (causing the TypeScript error) and the endpoint isn’t registered on the server (causing the 404) source.

To fix this, add the Username plugin to both your server and client configs. For example:

Server:

import { betterAuth } from "better-auth";
import { username } from "better-auth/plugins/username";

export const auth = betterAuth({
  emailAndPassword: { enabled: true },
  plugins: [username()],
});

Client:

import { createAuthClient } from "better-auth/client";
import { usernameClient } from "better-auth/plugins/username/client";

export const authClient = createAuthClient({
  plugins: [usernameClient()],
});

Make sure you’ve also run the required database migration for the Username plugin. After updating your configs, the method and endpoint should work as expected source.

If you still see errors after this, double-check your plugin setup and let me know what you see!

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

<!-- gh-comment-id:3102349304 --> @dosubot[bot] commented on GitHub (Jul 22, 2025): <!-- Answer --> The isUsernameAvailable method is only available if the Username plugin is enabled on both your server and client configs. In your provided config, only emailAndPassword is enabled—so the method is missing from the client (causing the TypeScript error) and the endpoint isn’t registered on the server (causing the 404) [source](https://github.com/better-auth/better-auth/blob/8fbe8f03a552f7af4e69178d0f84844969050601/packages/better-auth/src/plugins/username/index.ts). To fix this, add the Username plugin to both your server and client configs. For example: **Server:** ```ts import { betterAuth } from "better-auth"; import { username } from "better-auth/plugins/username"; export const auth = betterAuth({ emailAndPassword: { enabled: true }, plugins: [username()], }); ``` **Client:** ```ts import { createAuthClient } from "better-auth/client"; import { usernameClient } from "better-auth/plugins/username/client"; export const authClient = createAuthClient({ plugins: [usernameClient()], }); ``` Make sure you’ve also run the required database migration for the Username plugin. After updating your configs, the method and endpoint should work as expected [source](https://github.com/better-auth/better-auth/blob/8fbe8f03a552f7af4e69178d0f84844969050601/packages/better-auth/src/plugins/username/username.test.ts). If you still see errors after this, double-check your plugin setup and let me know what you see! <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/c243b6fe-351d-4c7d-b831-7f5e0c136ff2?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/c243b6fe-351d-4c7d-b831-7f5e0c136ff2?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/c243b6fe-351d-4c7d-b831-7f5e0c136ff2?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/c243b6fe-351d-4c7d-b831-7f5e0c136ff2?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/c243b6fe-351d-4c7d-b831-7f5e0c136ff2?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/c243b6fe-351d-4c7d-b831-7f5e0c136ff2?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/c243b6fe-351d-4c7d-b831-7f5e0c136ff2?feedback_type=other)</sup>&nbsp;&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/3544)
Author
Owner

@pranavmappoli commented on GitHub (Jul 22, 2025):

I have followed everything as per doc

<!-- gh-comment-id:3102362494 --> @pranavmappoli commented on GitHub (Jul 22, 2025): I have followed everything as per doc
Author
Owner

@frectonz commented on GitHub (Jul 24, 2025):

@pranavmappoli are you still facing this issue, even after enabling the username plugin.

<!-- gh-comment-id:3113913989 --> @frectonz commented on GitHub (Jul 24, 2025): @pranavmappoli are you still facing this issue, even after enabling the username plugin.
Author
Owner

@pranavmappoli commented on GitHub (Jul 24, 2025):

@frectonz yes, its not working , i have added all the plugins and, everything other to username works fine

<!-- gh-comment-id:3114066136 --> @pranavmappoli commented on GitHub (Jul 24, 2025): @frectonz yes, its not working , i have added all the plugins and, everything other to username works fine
Author
Owner

@frectonz commented on GitHub (Jul 24, 2025):

@pranavmappoli can you share your latest auth config with me, to help me reproduce the issue. I am trying to reproduce the issue in 1.3.3 but i am not seeing the problems you described.

For reference this the repo i am using to reproduce the issue: https://github.com/frectonz/better-auth-username

<!-- gh-comment-id:3114253156 --> @frectonz commented on GitHub (Jul 24, 2025): @pranavmappoli can you share your latest auth config with me, to help me reproduce the issue. I am trying to reproduce the issue in `1.3.3` but i am not seeing the problems you described. For reference this the repo i am using to reproduce the issue: https://github.com/frectonz/better-auth-username
Author
Owner

@pranavmappoli commented on GitHub (Jul 26, 2025):

@frectonz It working fine now, Not sure what changed in codebase, previously it return 404 everytime and typescript error as well like the method not exitsts,
Thanks a lot for your time

<!-- gh-comment-id:3121806360 --> @pranavmappoli commented on GitHub (Jul 26, 2025): @frectonz It working fine now, Not sure what changed in codebase, previously it return 404 everytime and typescript error as well like the method not exitsts, Thanks a lot for your time
Author
Owner

@johanan-23 commented on GitHub (Jul 27, 2025):

I'm facing the same issue! How did you resolve this error?

<!-- gh-comment-id:3124583358 --> @johanan-23 commented on GitHub (Jul 27, 2025): I'm facing the same issue! How did you resolve this error?
Author
Owner

@max-lancaster commented on GitHub (Jul 27, 2025):

@johanan-23 I was experiencing this same issue in my project and I was able to fix it by upgrading from better-auth 1.2.12 to 1.3.4 I verified via the open api plugin that the is-username-available endpoint was not showing up until I performed this upgrade:

Image
<!-- gh-comment-id:3124668084 --> @max-lancaster commented on GitHub (Jul 27, 2025): @johanan-23 I was experiencing this same issue in my project and I was able to fix it by upgrading from `better-auth` `1.2.12` to `1.3.4` I verified via the open api plugin that the `is-username-available` endpoint was not showing up until I performed this upgrade: <img width="263" height="112" alt="Image" src="https://github.com/user-attachments/assets/4e56d0e5-37a2-4397-8a0b-01532d461a60" />
Author
Owner

@johanan-23 commented on GitHub (Jul 28, 2025):

@johanan-23 I was experiencing this same issue in my project and I was able to fix it by upgrading from better-auth 1.2.12 to 1.3.4 I verified via the open api plugin that the is-username-available endpoint was not showing up until I performed this upgrade:

Image

Thanks G! The problem is now resolved!!

<!-- gh-comment-id:3125754250 --> @johanan-23 commented on GitHub (Jul 28, 2025): > [@johanan-23](https://github.com/johanan-23) I was experiencing this same issue in my project and I was able to fix it by upgrading from `better-auth` `1.2.12` to `1.3.4` I verified via the open api plugin that the `is-username-available` endpoint was not showing up until I performed this upgrade: > > <img alt="Image" width="263" height="112" src="https://private-user-images.githubusercontent.com/11873323/471241022-4e56d0e5-37a2-4397-8a0b-01532d461a60.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NTM2ODQ4MDEsIm5iZiI6MTc1MzY4NDUwMSwicGF0aCI6Ii8xMTg3MzMyMy80NzEyNDEwMjItNGU1NmQwZTUtMzdhMi00Mzk3LThhMGItMDE1MzJkNDYxYTYwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTA3MjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwNzI4VDA2MzUwMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWNhNjJiOTNhMGY5YmU4NjIxMDg4NmUzYzdmNGRhMTVkNjk0Mjg1MjM3Mzc4NjYwYzU5ZDEwY2Y3NzkwNzJhZDkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.uaO5QI2nELBz7xibC2WANQh0l1D_BEgdLvoXL4m97Jk"> Thanks G! The problem is now resolved!!
Author
Owner

@azaek commented on GitHub (Jul 28, 2025):

This doesn't trigger the username validator function, I think it should validate the username as well

<!-- gh-comment-id:3126042406 --> @azaek commented on GitHub (Jul 28, 2025): This doesn't trigger the username validator function, I think it should validate the username as well
Author
Owner

@emersonlaurentino commented on GitHub (Jul 31, 2025):

This doesn't trigger the username validator function, I think it should validate the username as well

https://github.com/better-auth/better-auth/pull/3719

<!-- gh-comment-id:3140530546 --> @emersonlaurentino commented on GitHub (Jul 31, 2025): > This doesn't trigger the username validator function, I think it should validate the username as well https://github.com/better-auth/better-auth/pull/3719
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#18268