Saves that vanish

Play this lesson

Where does your progress go?

Garden Defense remembers your best wave, your seeds and the plants you've unlocked. Where does it keep them?

In local storage: a small storage area that the web browser keeps for each website, on that one device. The vibe-coded save is a single line:

localStorage.setItem('bestWave', 12);

When the game starts again, it reads the value back with localStorage.getItem('bestWave').

How local storage works

Local storage holds pairs of a key (a name, like bestWave) and a value (like 12), saved as text. Browsers give each website a few megabytes.

Prototypes use it because it's free, needs no server and no login, and works straight away. But it belongs to one website, in one browser, on one device. Nothing is sent anywhere else.

Quick check

Your friend plays Garden Defense in the browser on their phone, then switches to a tablet. Where is their progress?

  1. Only on the phone
  2. On both devices
  3. Saved online in their account
Show the answer

Only on the phone

Local storage stays on the device where you played. The tablet has its own empty storage, so your friend starts again from wave 1.

Ways a save disappears

Player message

Feedback form, @sproutboss
I reached wave 30 on the family laptop. Today I played on my phone and I'm back at wave 1! Did your update delete my save??

What most likely happened?

  1. The save is still in local storage on the laptop. The phone has its own, empty storage.
  2. The update deleted every player's save
  3. The phone is too slow to load wave 30
Show the answer

The save is still in local storage on the laptop. The phone has its own, empty storage.

Nothing was deleted. Local storage never leaves the device, so the phone started fresh. To the player it still feels like we lost their progress, and that's a real problem for the studio.

And cheaters love it

Local storage lives on the player's own device, so the player controls it. Desktop browsers have built-in developer tools (the F12 key opens them in most). One of their tabs lists the local storage of the site you're on, and any value can be changed by double-clicking it.

Type 99999999 over your score, reload the page, and the game believes it. No hacking skills needed.

Spot the cheat

Local storage: Garden Defense
Key            ValuebestWave       12seeds          340highScore      99999999playMinutes    41

Which value was almost certainly edited by hand?

  1. bestWave: 12
  2. seeds: 340
  3. highScore: 99999999
Show the answer

highScore: 99999999

A player who reached wave 12 in 41 minutes can't have 99,999,999 points. The numbers don't fit together. A server can run checks like this, but the game on the player's device can be edited too.

Why it matters for a business

For a hobby, a lost save is sad. For a studio, it costs money.

Game developers follow a rule: never trust the client. The client is the copy of the game running on the player's device. Anything important gets checked on a server, a computer the studio controls.

Quick check

If our game saves data on a player's device, the player can't change it.

Show the answer

False

It's their device, so they can change anything stored on it. That's why scores and purchases need to be checked on a server the player can't edit.

The fix: cloud saves

In Stage 4 we move saves to the cloud with Firebase. Players sign in, their progress lives in an online database, and it follows them to any device. Security rules on the server decide who can change what, so nobody can edit someone else's save, and the server can reject impossible scores.

Local storage still has a job: small things that don't matter if they're lost, like the sound volume.

Bolt says: That's the full disaster list: one computer, a giant file, copies instead of versions, and fragile saves. Time for the boss.

Fact-checked 9 October 2026