This API is a pro feature and currently in Free Trial.

Persistent Storage in Playroom

Playroom State is cleared when all players leave the room. For some types of games, you may want to persist some data in your room that can be retrieved later when the player comes back to the same room.

Playroom provides a simple persistent storage API. The data is stored in the room until it is explicitly deleted or the expiry time is reached.


Create room with persistent storage enabled

await insertCoin({persistentMode: true});

Store data in the room

await setPersistentData('somekey', {foo: 'bar'});

Retrieve data from the room

const data = await getPersistentData('somekey'); // {foo: 'bar'}

Delete data from the room

await setPersistentData('somekey', undefined);

Insert Data into an Array

await insertPersistentData('somekey', 'value1');
await insertPersistentData('somekey', 'value2');
// getting the data
const data = await getPersistentData('somekey'); // ['value1', 'value2']