Save Data
Accessing the Save Data filesystem
nx.js provides built-in APIs for interacting with the Switch save data filesystem. This allows for two main use cases:
- Allows your app to persist its own save data, such as user configuration or game state
- Allows your app to interact with save data for other installed applications, i.e. for backup purposes
Persisting data using localStorage
The localStorage
API provides a high-level interface for persisting data that is stored in the Switch's save data filesystem. Data stored into local storage is unique across user profiles and individual nx.js apps, and will be persisted across subsequent launches of the app.
The user selection dialog will be shown upon accessing the localStorage
object, if the app was not launched with a profile selected.
Disabling localStorage
If your application does not need to persist save data, then you can disable the localStorage
API by setting the nacp.userAccountSaveDataSize
property in package.json
to 0
:
When this value is set, accessing localStorage
will return undefined
.
This prevents the profile selector from being shown, if any 3rd party modules
attempt to access localStorage
.
Accessing save data for other applications
The low-level save data interface allows mounting the save data filesystem for any installed application and for the various types of save data filesystems (account, cache, bcat, etc.).
Use the Switch.Application
class to mount a save data filesystem: