Todo
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data β all from the browser, and deployed in milliseconds.
A modern todo application built with React and @sqlife/react for local-first data management.
- β Add, edit, and delete todos
- π Pin important todos to the top
- β Mark todos as completed
- π Filter todos by status (All, Active, Completed)
- π± Responsive design with Tailwind CSS
- πΎ Local-first data storage with SQLite
- Frontend: React 18.2.0 with TypeScript
- Database: SQLite via @sqlife/react
- Styling: Tailwind CSS
- Backend: Hono for serving static files
- Platform: Val Town
The app uses a SQLite table with the following structure:
CREATE TABLE todo (
id TEXT PRIMARY KEY NOT NULL,
title TEXT NOT NULL,
completed BOOLEAN NOT NULL DEFAULT 0,
created_at TEXT NOT NULL,
updated_at TEXT NOT NULL,
completed_at TEXT NOT NULL DEFAULT "",
pinned INTEGER NOT NULL DEFAULT 0
)
βββ index.ts # Main HTTP handler
βββ frontend/
β βββ index.html # HTML template
β βββ index.tsx # React app entry point
β βββ components/
β βββ App.tsx # Main app component
β βββ TodoItem.tsx # Individual todo item
β βββ AddTodoForm.tsx # Form for adding new todos
βββ README.md
- Add todos: Type in the input field and click "Add Todo" or press Enter
- Complete todos: Click the checkbox next to any todo
- Pin todos: Click the π icon to pin important todos to the top
- Edit todos: Click on the todo text to edit it inline
- Delete todos: Click the ποΈ icon to delete a todo
- Filter todos: Use the All/Active/Completed buttons to filter the view
This app uses @sqlife/react which provides:
- Client-side SQLite database
- Reactive queries that automatically update the UI
- Offline-first functionality
- No server-side database required
The database is created automatically when the first todo is added.