Home > Enterprise >  What is the equivalent of NSUserDefaults/SharedPreferences for a web application?
What is the equivalent of NSUserDefaults/SharedPreferences for a web application?

Time:10-19

From what I understand iOS and Android can use a thing called "NS User Defaults / Shared Preferences" to work with small bits of non-complex data.

I was wondering in a web application, what would the equivalent of this be? Or does it even exist? If not, what would a recommended / best-practice solution be?

Thank you.

CodePudding user response:

It looks like the equivalent of "NSUserDefaults / SharedPreferences" that flutter provides out of the box for web is "local storage", which will not permanently persist data if the user clears browser cookies or is browsing in private/incognito mode.

This is not an ideal solution since I need data to persist permanently on the web-side of things.

The browser does not let you store data permanently, users can always clear their data whenever they choose to.

I will have to create a custom database table and sync the data from the local "NSUserDefaults/SharedPreferences" to the custom table on a server that the web app can utilize.

CodePudding user response:

If you want to use SharedPreferences in Android, iOS & Web try shared_preferences package

  • Related