This is a T3 Stack project bootstrapped with create-t3-app and migrated to use Better Auth for authentication.
- Better Auth for modern authentication with email/password
- Todo Management - Full CRUD operations for todos
- Next.js 15 App Router
- tRPC for type-safe API routes
- Drizzle ORM with PostgreSQL
- Tailwind CSS for styling
- TypeScript for type safety
- Node.js 18+ and pnpm
- PostgreSQL database
-
Clone the repository
-
Copy
.env.exampleto.envand configure:cp .env.example .env
-
Update the
.envfile with your configuration:- Generate a secret:
openssl rand -base64 32 - Set
BETTER_AUTH_SECRETto the generated value - Configure your database URL in
DATABASE_URL
- Generate a secret:
-
Install dependencies:
pnpm install
-
Setup the database:
pnpm db:push # or run migrations: pnpm db:migrate -
Start the development server:
pnpm dev
-
Visit http://localhost:3000
This template uses Better Auth with the following features:
- Email/Password Authentication: Users can sign up and log in with email and password
- Session Management: Secure session handling with database storage
- Protected Routes: Easy to protect pages and API routes
- Visit
/authto access the login/signup page - Create an account with email and password
- Once logged in, you'll be redirected to the home page
- Click "Go to Todos" to access your todo list
- Create, complete, and delete todos as needed
import { useSession } from "~/lib/auth-client";
export function MyComponent() {
const { data: session } = useSession();
if (session) {
return <div>Welcome {session.user?.email}!</div>;
}
return <div>Not logged in</div>;
}import { getSession } from "~/server/auth";
export default async function Page() {
const session = await getSession();
if (!session) {
redirect("/auth");
}
return <div>Protected content</div>;
}To learn more about the T3 Stack, take a look at the following resources:
- Documentation
- Learn the T3 Stack — Check out these awesome tutorials
You can check out the create-t3-app GitHub repository — your feedback and contributions are welcome!
Follow our deployment guides for Vercel, Netlify and Docker for more information.