Appearance
Class: DataStorageService
Persistent storage scoped to the app on the channel: a single free-form object (Record<string, any>) saved server-side, which survives refreshes, overlay restarts, and stream sessions.
Remarks
Accessible everywhere via k.dataStorage. You never have to instantiate this service yourself — it is created by the SDK when the app/widget starts.
This is where an app stores its global persistent state (a game's score, internal configuration, a counter, etc.). The data is tied to the app's installation on the channel (the ChannelAppli), not to a particular viewer: for per-viewer state, see k.userDataStorage.
Example
ts
// Load the state on startup, increment it, then save it again
const data = await k.dataStorage.get() ?? { counter: 0 };
data.counter++;
await k.dataStorage.set(data);Implements
Methods
delete()
ts
delete(): Promise<void>;Completely deletes the app's persistent state on the channel.
Returns
Promise<void>
A promise resolved once the deletion is complete.
Remarks
After this call, get will return null.
Deprecated
Use dataStorageV2.delete().
get()
ts
get(): Promise<Record<string, any>>;Retrieves the persistent state saved for this app on the channel.
Returns
Promise<Record<string, any>>
The saved object, or null if nothing has been stored yet.
Example
ts
const data = await k.dataStorage.get();
if (data) {
console.log('Saved score:', data.score);
}See
set to write the state.
Deprecated
Use dataStorageV2.get().
set()
ts
set(data): Promise<Record<string, any>>;Saves (replaces) the app's persistent state on the channel.
Parameters
data
Record<string, any>
The object to save. It fully replaces the previous data — remember to merge it yourself if you want to keep the existing values.
Returns
Promise<Record<string, any>>
The object actually stored server-side.
Example
ts
await k.dataStorage.set({ score: 42, lastWinner: 'penguin' });See
get to read the state back.
Deprecated
Use dataStorageV2.set().