Back to projects
Projectbeginner 9 steps ~70 min

Pomodoro Timer

Build a focus timer that stays accurate in background tabs: an end-time-based reducer, interval cleanup, a live tab title, settings that survive reloads, sound and screen reader announcements, and a keyboard shortcut.

What you'll build

A Pomodoro timer that stays accurate in background tabs, with settings, announcements, and a keyboard shortcut.

  • React
  • useReducer
  • timers
  • localStorage
  • aria-live
Project briefrequirements and design decisions

Requirements

  • 25-minute work and 5-minute break phases that alternate
  • Start, pause, and reset
  • Time stays accurate even when the tab is in the background

Architecture decisions

  • Store the phase end time, not a decrementing counter, so drift and throttled timers don't matter
  • Clean up intervals in the effect's cleanup function
  • Phase transitions in one place (a reducer)

Stretch goals

  • Configurable durations saved to localStorage
  • Browser notification when a phase ends
  • Show the remaining time in the tab title

Production checklist

  • Respect reduced-motion preferences for animations
  • Accessible live announcements when a phase changes
  • Tests with fake timers

1What we're building

A Pomodoro timer alternates focus sessions (25 minutes) with short breaks (5 minutes). It sounds like a beginner exercise, and most tutorials build it with a counter that goes down by one every second.

That version is broken in real life. Browsers throttle timers in background tabs. Chrome runs a hidden tab's timers at most once per second, and after a few minutes hidden, as rarely as once a minute. A counter-based timer silently falls behind, and your "25-minute" session takes 35.

You'll build it the way production apps do: store when the phase ends, and compute what's left from the clock. Then you'll add the details that make it pleasant to use every day.

1timer.js pure logic: formatTime and a timer reducer (start, pause, tick, reset) 2settings.js load and save durations safely 3TimerFace.jsx the display: phase, time, progress, controls 4SettingsForm.jsx duration inputs 5sound.js a beep with the Web Audio API 6App.jsx wires it together: intervals, title, shortcuts, announcements

What you'll learn: why setInterval isn't a clock, modeling a state machine with useReducer, effect cleanup, defensive localStorage, accessible live announcements, and keyboard shortcuts that don't fight the browser.

Pomodoro Timer project | Bloom