Custom Settings
The default authentication components provided by @daveyplate/better-auth-ui
include a built-in settings page accessible at /auth/settings
.
However, for advanced use cases or customization needs, you may want to provide a user settings interface at your own custom path or selectively use only certain settings components within your own application structure.
Overview
You have two primary ways to create a custom settings page experience:
- Use the built-in plug-and-play
<SettingsCards />
component on your custom route. - Selectively import and use individual components to build your own specific settings page layout.
Step 1: Setting settingsUrl
To override the default built-in settings page URL (/auth/settings
) with your custom URL (example: /dashboard/settings
):
With AuthUIProvider:
Set the settingsUrl
prop within your main application provider:
Important: Once
settingsUrl
is set, the built-in/auth/settings
route will automatically redirect users visiting/auth/settings
to your custom path, providing a seamless replacement of the default option.
Step 2: Implementing Custom Settings UI
Option A: Using <SettingsCards />
The easiest way is to use the <SettingsCards />
component, which automatically handles displaying all enabled settings. This includes avatar, email, username, password, linked social providers, session management, delete account, and custom additional fields you've provided.
You can customize the appearance using TailwindCSS classes through classNames
props as documented in SettingsCards documentation:
Option B: Individually Using Settings Components
For finer-grained control, selectively import the components you want:
Component | Description |
---|---|
<UpdateAvatarCard /> | User avatar management |
<UpdateNameCard /> | Update user's name |
<UpdateUsernameCard /> | Manage username (if applicable/username set via plugin) |
<ChangeEmailCard /> | Changing the user's email address |
<ChangePasswordCard /> | Allow user to securely update password |
<ProvidersCard /> | Linking/Unlinking social provider accounts |
<SessionsCard /> | Active session management |
<DeleteAccountCard /> | Deleting the user account securely |
<UpdateFieldCard /> | Add or update additional custom user fields |
Here's a complete example demonstrating an individually composed user settings page:
This example assumes additionalFields
are configured via your <AuthUIProvider>
:
Handling Authentication for Settings Page
It's essential that your custom settings page is protected and accessible only by authenticated users. There's a built-in helper useAuthenticate
to ensure your settings pages are secured: