A practice project: a small React todo list built with Vite, used to practice React state and tests. It is one of my small practice apps, not a product.
- Adds a todo from a text input. Blank or whitespace-only input is rejected. The text is stored as typed, including surrounding spaces.
- Toggles a todo between done and not done. A done todo gets the
completedclass, and its text is struck through. - Deletes a todo.
- Keeps todos in React state only. Reloading the page clears them.
Each todo gets its ID from a counter stored in a useRef, so two todos added in the same millisecond keep separate IDs.
- React 19 (
react,react-dom), built and served with Vite 8 and@vitejs/plugin-react. - TypeScript 6 type-checks
src/App.jsxandsrc/index.jsxthrough JSDoc annotations (checkJs). - Jest 30 with ts-jest and Testing Library runs the tests in
src/App.test.jsx. - ESLint 10 lints the project, with the React hooks rules enabled for
src/. - Bun is the package manager.
package.jsonpins[email protected].
- Node 22.23.2 (
engines.nodeis>=22.23.2 <23). - Bun 1.4.2 or newer, below 2.
bun install --frozen-lockfile
bun run startVite serves the app at http://localhost:5173 by default.
| Command | What it does |
|---|---|
bun run start |
Starts the Vite development server. |
bun run build |
Runs tsc, then vite build, which writes the output to build/. |
bun run start:prod |
Serves build/ with serve on 0.0.0.0, using PORT (default 3000). |
bun run lint |
Runs ESLint on the repository. |
bun run test |
Runs the Jest suite. |
bun run test:production |
Runs tests/production-smoke.mjs against build/. Run bun run build first. |
The app code reads no environment variables. The start:prod script reads PORT to choose its port and falls back to 3000.
nixpacks.toml configures a Nixpacks build with Node 22 and Bun. It runs bun install --frozen-lockfile, then bun run build, and starts the app with bun run start:prod.
src/
App.jsx Todo list component and its state
App.css Component styles, with one media query at 768px
App.test.jsx Jest tests for the component
index.jsx Entry point that mounts App into #root
index.css Global styles
public/ Favicon, web app manifest and robots.txt
tests/ Jest setup, CSS mock and the production smoke test
src/App.test.jsx has 12 tests. They cover the initial empty list, adding text, rejecting blank input, keeping the exact text, submitting the form without a page reload, completing and undoing a todo, deleting a todo, two todos added in the same millisecond, and rendering HTML-like text as plain text.
- https://todoapp.thomasscheiber.com/ serves this app.
- https://t-scheiber.github.io/todo-app/ loads the app, but its page title is "React App", not the title this source sets.