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.
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, announcementsWhat 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.