TanStack Start starter kit
Install the TanStack Start starter kit, configure authentication and PostgreSQL, and manage users and account settings.
Getting started
Download the starter kit zip file, extract it, and open the project folder in your terminal. You will need Bun and a running PostgreSQL database.
Install the dependencies:
Copy the example environment file:
Better Auth
This project uses Better Auth for authentication. Generate a private secret:
Add the generated value to .env, along with the application URLs:
Use the same application URL for BETTER_AUTH_URL and VITE_APP_URL. Update both when deploying to a different domain. Keep the secret private; only public configuration belongs in variables prefixed with VITE_.
If you use .env.local, check its values too. It takes precedence over .env.
Database setup
This starter kit uses PostgreSQL with Drizzle ORM. Create a database, then set your connection URL:
Replace USER, PASSWORD, HOST, PORT, and DATABASE with your PostgreSQL credentials. With PostgreSQL running, apply the included migrations:
The migrations create the authentication tables used for accounts, sessions, email verification, admin roles, and two-factor authentication. The included cleanup migration also removes the legacy demo todos table, so use a database dedicated to this application.
When you change the schema in src/db/schema.ts, generate and apply a new migration:
Password-reset emails and optional email verification use Resend. Configure a sending address on a verified domain in your Resend account, then update .env:
When email verification is enabled, new users must verify their email before signing in. Users can also request a verified email change from their profile settings.
If you do not need email verification, set:
Password-reset emails still require RESEND_API_KEY and EMAIL_FROM, even when email verification is disabled.
GitHub login
GitHub login is optional. Create a GitHub OAuth application and set its authorization callback URL to:
Add its credentials and enable the GitHub sign-in button:
Use your deployed application domain in the callback URL when deploying. Leave VITE_GITHUB_ENABLED=false if you only want email and password authentication.
Running the application
Start the development server:
Open http://localhost:3000 in your browser. The homepage redirects to the login page, or to the dashboard if you are already signed in.
Restart the development server after changing environment variables.
Admin account
Register an account at /register, then promote that existing account from your terminal:
Replace you@example.com with the email address you registered. This command assigns the admin role to an existing account; it does not create a new account. Public registration always creates a regular user.
Sign out and sign in again after changing the role. The Users menu will appear in the sidebar. Admins can search and paginate users, create accounts, view and edit profiles, change roles, ban or restore users, delete accounts, and impersonate users.
During impersonation, use the impersonation control to return to the original admin account. Admin pages and user-management operations check permissions on the server.
Account settings
Open the profile menu to access settings. Users can update their profile, change their password, choose a light, dark, or system theme, and enable two-factor authentication.
To enable two-factor authentication, open /settings/two-factor-auth, confirm your password, scan the QR code with an authenticator app, and enter the generated code. Store the recovery codes securely.
Checking your changes
Run the TypeScript check, authentication regression test, and production build:
The authentication test uses an isolated in-memory database. Also verify your application against PostgreSQL after applying migrations.