CodingNic

Persistence & Application Preferences

Persistence & Application Preferences

Persistence & Application Preferences 3 min read

Persistence & Application Preferences

Application state is useful only if it survives long enough to be useful.

You will store calculator history in the browser with localStorage. You will also persist the selected theme so a refresh does not reset the user’s preference.

The pattern is:

State changes → save → page reload → load → restore state