How to save data?

How does Needle save data such as score, names, country settings, etc.? In Unity I used the “Easy Save” asset for this.

Original Post on Discord

by user 684154017479524352

Hey :wave: websites in general use LocalStorage API to store state inbetween sessions.
https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage

You can possibly store whole objects which contain data or just specific pieces of information. Let me know how was your experience while using localStorage in oppose to Easy Save (a Unity based solution) and if you were able to easily use it :cactus:

What is also often used and quite elegant (depending on your usecase) is storing things in the URL as query parameters. That way when your website has some state and people share the link the receiving person will be able to get the same state (e.g. they see the same UI state, the same language will be selected…) if your website checks the parameters

We have some utility methods for easily reading and writing to the parameters: setParamWithoutReload and getParam - those are used by the SceneSwitcher component for example to store which scene is currently loaded

Thanks for the information. When I’m ready, I’ll share my knowledge. Thanks again ! Needle Tools rocks!:+1:

by user 684154017479524352

Also if you have additional input on how you’d like this to work we’re all ears, making local state easier is something we discussed too