A production-ready, offline-first todo application with authentication, multi-list organization, and rich task metadata. Built with Next.js 15, TypeScript, and MongoDB.
- Secure Authentication: Email/Password signup and login with JWT
- HTTP-only Cookies: Session management with secure, HTTP-only cookies
- Route Protection: Automatic redirect to login for protected routes
- Data Isolation: Complete user data privacy and separation
- Robust Logout: Clean session termination with client-side cleanup
- Unlimited Lists: Create and manage multiple todo lists
- List Management: Rename and delete lists with ease
- Cascading Delete: Deleting a list removes all associated todos
- Smart Defaults: Auto-select first list on load
- List Switching: Quick dropdown navigation between lists
Each todo includes:
- Title and Description
- Status: Pending | Todo | In Progress | Completed
- Category: Bug | Feature | Docs | Improvement | Refactor
- Priority: Minor | Normal | Important | Critical
- Visual Badges: Color-coded badges for quick identification
- Instant Updates: Optimistic UI for immediate feedback
- LocalStorage Caching: Persistent offline data storage
- Smart Sync: Automatic synchronization when online
- No Loading Flash: Skeleton loaders during hydration
- Conflict Resolution: Intelligent merge strategy for sync conflicts
- Dark Mode: System, light, and dark theme support
- Smooth Transitions: No jarring UI changes
- Modern Design: Clean interface with shadcn/ui components
- Responsive Layout: Works on all screen sizes
- Accessible: ARIA labels and keyboard navigation
- Frontend: Next.js 15 (App Router), React 19, TypeScript
- State Management: Zustand with localStorage persistence
- Styling: Tailwind CSS, shadcn/ui components
- Backend: Next.js API Routes
- Database: MongoDB with Mongoose ODM
- Authentication: JWT with jose, HTTP-only cookies
- Theme: next-themes for dark mode support
- Node.js 18+ and npm
- MongoDB instance (local or cloud like MongoDB Atlas)
- Git
git clone https://github.com/yourusername/fasttodo.git
cd fasttodonpm installCreate a .env.local file in the root directory:
# MongoDB Connection String
MONGODB_URI=mongodb://localhost:27017/fasttodo
# OR for MongoDB Atlas:
# MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/fasttodo
# JWT Secret (use a strong random string)
JWT_SECRET=your-super-secret-jwt-key-change-this-in-productionGenerate a secure JWT secret:
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"npm run devOpen http://localhost:3000 in your browser.
- Navigate to
http://localhost:3000 - You'll be redirected to
/login - Click "Sign Up" and create an account
- After signup, you'll be automatically logged in
- Click the "Create List" button
- Enter a list name (e.g., "Work Tasks")
- Click "Done"
- Make sure a list is selected (shown in the dropdown)
- Click "Create Todo"
- Fill in the details:
- Title (required)
- Description (optional)
- Status (default: Todo)
- Category (default: Feature)
- Priority (default: Normal)
- Click "Save changes"
- Switch Lists: Click the list dropdown, select a different list
- Rename List: Click the โฎ menu next to the list dropdown โ "Rename list"
- Delete List: Click the โฎ menu โ "Delete list" (deletes all todos in the list)
The app works perfectly offline:
- Go Offline: Disconnect from the internet
- Create/Edit: Make changes to todos and lists
- Local Storage: Changes are saved immediately to localStorage
- Reload: Page reloads show cached data with no flash
- Reconnect: Automatic sync to server when back online
Click the Sun/Moon icon in the header to toggle between:
- Light mode
- Dark mode
- System preference
User Action
โ
Zustand Store (Optimistic Update)
โ
LocalStorage (Offline Persistence)
โ
API Route (if online)
โ
MongoDB (Server Persistence)
โ
Sync & Merge (on reconnect)
fasttodo/
โโโ src/
โ โโโ app/
โ โ โโโ api/
โ โ โ โโโ auth/[...path]/ # Auth endpoints
โ โ โ โโโ lists/ # List CRUD
โ โ โ โโโ todos/ # Todo CRUD
โ โ โโโ login/ # Login page
โ โ โโโ signup/ # Signup page
โ โ โโโ layout.tsx # Root layout with ThemeProvider
โ โ โโโ page.tsx # Main dashboard
โ โโโ components/
โ โ โโโ ui/ # shadcn/ui components
โ โ โโโ header.tsx # App header with theme toggle
โ โ โโโ todo-list.tsx # Main todo list view
โ โ โโโ todo-card.tsx # Individual todo card
โ โ โโโ todo-dialog.tsx # Create/edit dialog
โ โ โโโ create-list-dialog.tsx # List creation
โ โ โโโ ...
โ โโโ lib/
โ โ โโโ db.ts # MongoDB connection
โ โ โโโ auth.ts # JWT utilities
โ โโโ models/
โ โ โโโ Todo.ts # Todo Mongoose schema
โ โ โโโ List.ts # List Mongoose schema
โ โ โโโ User.ts # User Mongoose schema
โ โโโ store/
โ โ โโโ use-todo-store.ts # Zustand store with sync logic
โ โโโ proxy.ts # Route protection middleware
โโโ package.json
The app uses a sophisticated sync engine in use-todo-store.ts:
- Push Deletions: Sync deleted items to server
- Push Updates: Sync created/modified items
- Pull & Merge: Fetch server data and merge with local changes
- Conflict Resolution: Unsynced local changes always take precedence
- Login โ JWT signed โ HTTP-only cookie set
- Every API request โ Cookie validated โ User identified
- Protected routes โ
proxy.tschecks auth โ Redirect if needed
- Signup and login
- Create multiple lists
- Switch between lists
- Create todos with different statuses/categories/priorities
- Edit todos
- Delete todos
- Rename list
- Delete list (verify cascading delete)
- Go offline, create todo, reconnect (verify sync)
- Reload page offline (verify no data loss)
- Toggle theme (light/dark/system)
- Logout and login again
If you get connection errors:
- Ensure MongoDB is running:
mongod --version - Check your
MONGODB_URIin.env.local - For MongoDB Atlas, ensure IP whitelist includes your IP
If you see JWT-related errors:
- Verify
JWT_SECRETis set in.env.local - Clear cookies and try logging in again
- Regenerate JWT_SECRET with a strong random string
If you see hydration warnings:
- Check that
suppressHydrationWarningis on<html>tag - Ensure ThemeProvider is wrapping the app
- Clear browser cache and reload
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License.
- Next.js - The React Framework
- shadcn/ui - Beautiful UI components
- Zustand - Lightweight state management
- MongoDB - Database platform
- Tailwind CSS - Utility-first CSS framework
Built with โค๏ธ using Next.js and TypeScript