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 production-ready todo app built with React, Hono, and SQLite on Val Town.
- β Add, edit (double-click), complete, and delete todos
- π Filter by all / active / completed
- π§Ή Clear all completed todos at once
- β‘ Optimistic UI updates with automatic rollback on failure
- πΎ Persistent storage in val-scoped SQLite
- π‘οΈ Server-side input validation (1β500 chars, type checks)
- π¨ User-visible error messages + client errors surfaced to val logs
Rendering mermaid diagram...
index.ts β HTTP entrypoint: Hono server (static files + API)
backend/
db.ts β SQLite schema + query functions
shared/
types.ts β Todo/Filter types shared by client & server
frontend/
index.html β HTML shell (Twind + React)
index.tsx β React entrypoint
components/
App.tsx β Root component: state, API calls, filters
TodoInput.tsx β New-todo form
TodoItem.tsx β Single todo row (toggle/edit/delete)
| Method | Path | Description |
|---|---|---|
GET | /api/todos | List all todos |
POST | /api/todos | Create β body: { text } |
PATCH | /api/todos/:id | Update β body: { text?, completed? } |
DELETE | /api/todos/:id | Delete a todo |
POST | /api/todos/clear-completed | Delete all completed todos |
All endpoints return JSON; errors are { error: string } with 400/404 status codes.
- Data is stored in this val's scoped SQLite database (
todos_v1table). - Schema setup is idempotent (
CREATE TABLE IF NOT EXISTS), safe across restarts. - All queries are parameterized β no SQL injection.