Claude Code Society, home

Learn, lesson 4 of 6

Data that sticks

Right now your timer forgets everything when you reload the page. In this lesson it starts remembering: your last ten study sessions, kept in the browser, still there tomorrow.

What you're doing

Every browser gives each website a small private store called localStorage. A page can write text into it and read it back later. It has no expiry date, so it's still there after you close the browser. It only holds text, so a list of sessions gets turned into text (JSON) on the way in and back into a list on the way out.

Three limits to know before you rely on it:

  • It lives in one browser on one device. Your phone's history and your laptop's are separate.
  • A private or incognito window clears it when the last private tab closes.
  • It isn't for passwords or anything secret, and it can't share data between people. That needs a server and a database, which comes later in the track.

Steps

  1. Start from a clean save

    Terminal
    cd study-timer
    git status

    Git should say there's nothing to commit. If not, commit what you have first (lesson 3), so you can always get back here.

  2. Plan the change

    Start claude --permission-mode plan and ask:

    Type into Claude Code
    When a focus round finishes, save it: the date, the time it ended and how many minutes it lasted. Keep only the last ten in the browser's localStorage, newest first, and show them in a list under the timer. Add a "Clear history" button. Also add a test mode, turned on by adding ?test to the address, where a focus round lasts 10 seconds and a break lasts 5. Make a plan first.
  3. Check the plan, then build

    Look for three things in the plan: where the list is saved, how it's turned into text and back, and what happens when there are already ten entries. Change anything that's unclear, then approve it.

  4. Commit and push

    localStorage works most reliably on a real web address, and opening a file straight from your disk can behave differently from browser to browser. So test on your live link:

    Type into Claude Code
    commit these changes with a descriptive message and push them

    Give GitHub Pages a minute to update.

  5. Prove it survives a refresh

    Open your GitHub Pages link with ?test on the end, like https://jordanlee.github.io/study-timer/?test. Let two focus rounds finish. Reload the page. Close the tab, open the link again. The two sessions should still be listed.

  6. Look at the stored data yourself

    In Chrome, open DevTools (F12 on Windows and Linux, Cmd + Option + I on a Mac), go to Application, expand Local Storage under Storage, and click your site. You'll see the key your timer uses and its value: your sessions, as text. Other browsers have the same thing under a different name.

  7. Check the limit of ten

    Still in test mode, let eleven rounds finish. The list should show ten, and the oldest one should be gone. If it shows eleven, tell Claude Code what you saw and have it fix the trimming.

Exercise

Proof of done

Make the study timer remember your last ten sessions, and prove it on your live link.

You're done when

  • After a reload, and after closing and reopening the tab, your finished sessions are still listed.
  • An eleventh session pushes the oldest one off the list.
  • You found your saved sessions in DevTools under Local Storage.
  • The change is committed and pushed, and the live link has it.

Sources

Read on October 4, 2026.

  1. MDN, Window: localStorage: saved across browser sessions with no expiry, cleared at the end of a private session, text only, one store per site, may fail for pages opened from a file.
  2. MDN, Web Storage API.
  3. MDN, JSON.stringify: turning a list into text.
  4. Chrome DevTools, View and edit local storage: Application, Storage, Local Storage; and Open Chrome DevTools for the keyboard shortcuts.
  5. Choose a permission mode: plan mode.