TinyBase logoTinyBase

PartyKitPersisterConfig

The PartyKitPersisterConfig type describes the configuration of a PartyKit Persister on the client side.

{
  storeProtocol?: "http" | "https";
  storePath?: string;
  messagePrefix?: string;
}
TypeDescription
storeProtocol?"http" | "https"

The HTTP protocol to use (in addition to the websocket channel). This defaults to 'https' but you may wish to use 'http' for local PartyKit development.

storePath?string

The path used to set and get the whole Store over HTTP(S) on the server. This must match the storePath property of the TinyBasePartyKitServerConfig object used on the server. Both default to '/store'.

messagePrefix?string

The prefix at the beginning of the web socket messages sent between the client and the server when synchronizing the Store. Use this to make sure they do not collide with any other message syntax that your room is using. This must match the messagePrefix property of the TinyBasePartyKitServerConfig object used on the server. Both default to an empty string.

The defaults (if used on both the server and client) will work fine, but if you are building more complex PartyKit apps and you need to configure path names, for example, then this is the thing to use.

Example

When applied to a PartyKit Persister, this PartyKitPersisterConfig will load and save a JSON serialization from and to an end point in your room called /my_tinybase, and use HTTP (rather than the default HTTPS) as the protocol.

Note that this would require you to also add the matching storePath setting to the TinyBasePartyKitServerConfig on the server side.

export const partyKitPersisterConfig = {
  storeProtocol: 'http',
  storePath: '/my_tinybase',
};

Since

v4.3.9