DB or Localstorage?

Hey everyone, I want to store the settings/preference of users For example If I have to store color preference, theme preference, sound preferences or any settings related preferences So should I store it in Database and every time user loads the react app, it will be fetched and those settings will be applied Or should I store them in localstorage and then apply settings??
12 Replies
Neto
Neto10mo ago
do you want to persist between different devices? if no db if its enough to handle local state only, localstorage is good enough
Noor
NoorOP10mo ago
I am not sure. Does it needs to be persistent?? It's just settings of an app
Neto
Neto10mo ago
you tell me depends on the setting if is audio, sure storing on the device is fine if its a setting that impacts the operations, always in the db like a feature toggle
Noor
NoorOP10mo ago
Settings like Theme color Show/Hide Tags on Startup Show/Hide Deadline by default Like this
Neto
Neto10mo ago
its fine to keep in the client side
Pronsh
Pronsh10mo ago
Imo it makes more sense to cache in client side
Neto
Neto10mo ago
if you dont want to flash content, then its server side
Pronsh
Pronsh10mo ago
Since small
Noor
NoorOP10mo ago
Hmm I guess settings are not that important. I mean user rarely changes the device So I can store in Localstorage
Neto
Neto10mo ago
yep as long as its fine to have a delay between page startup and settings sync akin to dark more on local storage its ssr'd as white theme but gets dark after
Huge Letters
Huge Letters10mo ago
stuff like color preference could be stored in cookies so that you could access them on the server for proper ssr and avoid content flashing. stuff like sound preferences is fine for localStorage since I assume those don't matter on initial render
GStudiosX2
GStudiosX210mo ago
I store theme in local storage and its fine theres a little flash but its basically instant I have like JavaScript some where to change the theme Though im not using nextjs so maybe its different there
Want results from more Discord servers?
Add your server