A simple todo list application built with Next.js, Better-Auth, and Prisma Postgres.
- Frontend: Next.js
- Database: Prisma Postgres
- Authentication: Better-Auth
- Styling: Tailwind CSS
- Drag & Drop: dnd-kit
- 📝 Create, edit, and delete todos
- ✅ Mark tasks as complete/incomplete
- 🎯 Drag and drop to reorder tasks
- 👤 Secure user authentication
- 🔄 Real-time synchronization
- 📱 Responsive design
- 🎨 Beautiful notebook-inspired UI
- Node.js 18+
- npm, yarn, pnpm, or bun
git clone <your-repo-url>
cd nextjs_with_prisma_and_better_auth
npm install
Create a .env
file in the root directory with the following variables:
# Database
DATABASE_URL="your_postgres_connection_string"
# Authentication
BETTER_AUTH_SECRET="your_secret_key"
Create a new Prisma Postgres database:
npx create-db
Follow the prompts and copy the Prisma Postgres connection string to your .env
file as DATABASE_URL
.
📖 More info: Prisma Postgres Documentation
Generate a secure secret for Better Auth:
npx @better-auth/cli@latest secret
Copy the generated secret to your .env
file as BETTER_AUTH_SECRET
.
Run Prisma migrations to set up your database:
npx prisma migrate dev
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
Open http://localhost:3000 to see your TodoApp!
src/
├── app/ # Next.js app router
│ ├── api/ # API routes
│ ├── dashboard/ # Dashboard page
│ ├── sign-in/ # Authentication pages
│ └── sign-up/
├── components/ # React components
│ └── TodoList.tsx # Main todo component
└── lib/ # Utilities
├── auth.ts # Auth configuration
├── auth-client.ts # Client-side auth
└── prisma.ts # Database client
prisma/
├── schema.prisma # Database schema
└── migrations/ # Database migrations
The easiest way to deploy is using the Vercel Platform:
- Push your code to GitHub
- Connect your repository to Vercel
- Add your environment variables in Vercel dashboard
- Deploy!
Make sure to set these in your deployment platform:
DATABASE_URL
: Your production Postgres connection stringBETTER_AUTH_SECRET
: Your Better Auth secret key
# Generate Prisma client
npx prisma generate
# Run migrations
npx prisma migrate dev
# View database in Prisma Studio
npx prisma studio
# Development
npm run dev
# Build for production
npm run build
# Start production server
npm run start