Skip to content
Cloudflare Docs

Storage and Broadcast

The RealtimeKit Stores API allows you to create multiple key-value pair realtime stores. Users can subscribe to changes in a store and receive real-time updates. Data is stored until a session is active.

This page is not available for the Flutterplatform.

Create a Store

You can create a realtime store (changes are synced with other users):

ParamTypeDescriptionRequired
namestringName of the storetrue

To create a store:

TypeScript
const stores = useRealtimeKitSelector((m) => m.stores);
const store = stores.create('myStore');

Update a Store

You can add, update or delete entires in a store:

ParamTypeDescriptionRequired
keystringUnique identifier used to store/update a value in the storeYes
valueStoreValueValue that can be stored agains a keyYes

Subscribe to a Store

You can attach event listeners on a store's key, which fire when the value changes.

Fetch Store Data

You can fetch the data stored in the store:

TypeScript
const stores = useRealtimeKitSelector((m) => m.stores.stores);
const store = stores.get('myStore');
// fetch value for a specific key
const data = store.get('key');
// fetch all the data in the store
const data = store.getAll();