Skip to main content

Persistence

The Persistence module provides a way to save and load game states, both using a local and remote storage, ensuring a seamless experience for players across sessions.

Setup

To utilize the Persistence module, initialize the SDK and access the persistence component:

import * as ArkadiumApi from '@arkadiuminc/sdk';

const sdk = await ArkadiumApi.getInstance();

sdk.persistence;

Ensure proper initialization to enable saving and loading functionalities.

Local Storage

Loading Item

To load an item from local storage:

const item = await sdk.persistence.getLocalStorageItem("saved-game-123");

Saving Item

To save an item to local storage:

await sdk.persistence.setLocalStorageItem("saved-game-123", item);

Removing Item

To remove an item from local storage:

await sdk.persistence.removeLocalStorageItem("saved-game-123");

Remote Storage

Loading Item

To load an item from remote storage:

const item = await sdk.persistence.getRemoteStorageItem("saved-game-123");

Saving Item

To save an item to remote storage:

await sdk.persistence.setRemoteStorageItem("saved-game-123", item);

Removing Item

To remove an item from remote storage:

await sdk.persistence.removeRemoteStorageItem("saved-game-123");

Cookies

Fetch cookie from arena

const cookie = await sdk.persistence.getCookie('cookie_name');
tip

Use non-circular references to save player progression data, with a limit of 5MB. Focus on saving only essential progression details to maintain performance and prevent issues with large or complex data.

Conclusion

The Persistence module is crucial for enhancing player engagement by allowing them to store players' game state and persist them between game sessions.