Custom Auth Paths
Here's a complete guide on how to customize view paths using the AuthUIProvider
component. This example will show you how to change the auth routes from /auth/sign-in
and /auth/sign-out
to use custom paths such as /auth/login
and /auth/logout
, respectively.
Step 1: Customize Auth View Paths
First, customize the default built-in paths by providing your custom routes through the viewPaths
prop on the <AuthUIProvider>
component.
Now your newly configured viewPaths
object is as follows:
Default Path | Custom Path |
---|---|
/auth/sign-in | /auth/login |
/auth/sign-out | /auth/logout |
/auth/sign-up | /auth/register |
/auth/forgot-password | /auth/forgot |
/auth/reset-password | /auth/reset |
/auth/magic-link | /auth/magic |
/auth/settings | /auth/config |
Adjusting Dynamic Auth Route
Next, your authentication page route can dynamically handle these paths. Set up your dynamic authentication page based on these custom routes.
Using Next.js App Router (app
router):
Example usage across your app:
Linking to new auth views:
Summary of Steps (Recap):
- Defined custom view paths within
AuthUIProvider
. - Updated dynamic auth page to handle correct paths within
generateStaticParams
. - Revised links/apps accordingly to use your newly specified paths.
You have now successfully customized all your authentication URLs using the shipped customization options while preserving all the other features and integrations seamlessly.