🔎 What you'll see
(no error — everything resets after a refresh)
🤔 Why it happens
Data kept only in variables vanishes when the page reloads. To keep it in the browser, save it to localStorage and read it back when the page opens. Note that it only stays in that browser, on that device.
🛠️ How to fix it
- Save with localStorage.setItem("key", JSON.stringify(data)).
- When the page opens, read it back with JSON.parse(localStorage.getItem("key") || "[]").
- To see the data on other devices too, you need a server or database (e.g. Supabase, Firebase).
- Some hosting services and preview windows may block storage.
🤖 What to ask your AI
Replace the parts in [ ] with your own details, then paste it in.
My to-do list app loses everything when I refresh. Give me the complete code changed to save to and load from localStorage. Here's my current code: [code].
Other errors
CORS errorThe browser blocks your page from fetching data from another site404 Not FoundThe address or file can't be foundundefined / Cannot read properties of undefinedReading a property of a value that isn't thereis not definedUsing a name that was never declaredSyntaxErrorBrackets or quotes don't match upExposed API keyYou put a secret key in your code or on GitHubMixed ContentAn https page loads something from an http addressBlank white pageYou deployed it and all you see is a blank screenis not a functionCalling something that isn't a functionUnexpected token < in JSONYou expected JSON but got HTMLCannot use import statement outside a moduleThe browser won't accept your import statementfavicon.ico 404The console shows a 404 for favicon.icoPage looks broken or tiny on phonesFine on a computer, weird on mobilegit push rejectedA "rejected" / non-fast-forward errornpm: command not foundYour terminal says npm or node doesn't existPort 3000 is already in useYour dev server says the port is takenEnvironment variables (.env) aren't loadingYou put your API key in .env but it comes out undefinedThe AI keeps failing to fix the same errorYou ask for a fix and nothing changes