TanStack Start
This guide covers integrating @daveyplate/better-auth-ui
with TanStack Start. We also install @daveyplate/better-auth-tanstack to handle the authentication state and queries.
Starter Project
Want to skip the installation? Check out the starter here:
Installation
Set up the Auth Provider
TanStack Start requires setting up providers slightly differently than a standard React application. Create a root-level provider component:
Note how we use TanStack Router's useRouter
hook and Link
component to handle navigation.
Setting Up Auth Routes
TanStack Start uses a file-based routing system. Here's how to set up your authentication routes:
Create Auth Route
Create the following route files for authentication:
This dynamic route will handle all the authentication paths (sign-in, sign-up, etc.).
This setup provides a solid foundation for integrating Better Auth UI with TanStack Start. You'll get all the benefits of TanStack's powerful routing system along with Better Auth UI's authentication capabilities.