Installation
1
Add the server plugin
Enable
emailAndPassword and add the username plugin:auth.ts
2
Run the database migration
The plugin adds
username and displayUsername columns to the user table:- migrate
- generate
3
Add the client plugin
auth-client.ts
Usage
Sign up with a username
Pass ausername field to the existing signUp.email method:
sign-up.ts
If only
username is provided, displayUsername is automatically set to the pre-normalized value of username. Usernames are lowercased by default — "JaneDoe" and "janedoe" are treated as the same username.Sign in with a username
Use thesignIn.username method added by the plugin:
sign-in.ts
Update a username
update-username.ts
Check username availability
check-username.ts
Configuration options
All options are passed tousername() on the server:
auth.ts
Database schema
The plugin adds two optional columns to theuser table: