mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-10 12:27:44 +00:00
feat(username): Check username availability (#3025)
* feat(username): Check username availability closes https://github.com/better-auth/better-auth/issues/1553 * add: docs
This commit is contained in:
@@ -96,6 +96,23 @@ const data = await authClient.updateUser({
|
||||
})
|
||||
```
|
||||
|
||||
### Check if username is available
|
||||
|
||||
To check if a username is available, you can use the `isUsernameAvailable` function provided by the client.
|
||||
|
||||
```ts title="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");
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Schema
|
||||
|
||||
The plugin requires 1 field to be added to the user table:
|
||||
|
||||
Reference in New Issue
Block a user