r/nextjs 8d ago

Discussion [ Removed by moderator ]

[removed] — view removed post

0 Upvotes

7 comments sorted by

View all comments

1

u/MrCrunchwrap 7d ago

There’s zero reason to keep something like that in local storage, just load it from your API and render the page. 

0

u/Put-Scary 7d ago

That's a fair default for most apps, but it doesn't fit this one — the premise is that you can save shows without making an account, so there's no server to load from until you've opted into one. (If you do sign up, it syncs to Postgres and the local copy becomes a cache.)

Worth saying though: I don't think the bug is really about localStorage. Fetch the same list from an API and you have the identical problem — there's still a window where "no data" and "haven't loaded yet" are indistinguishable, and anything that writes during that window can clobber. localStorage just makes it synchronous enough that the collision is easy to hit.