TinyBase logoTinyBase

TinyBasePartyKitServer

This extends the PartyKit Server class, which provides a selection of methods you are expected to implement. The TinyBasePartyKitServer implements only two of them, the onMessage method and the onRequest method, as well as the constructor.

If you wish to use TinyBasePartyKitServer as a general PartyKit server, you can implement other methods. But you must remember to call the super implementations of those methods to ensure the TinyBase synchronization stays supported in addition to your own custom functionality. The same applies to the constructor if you choose to implement that.

// This is your PartyKit server entry point.

class MyServer extends TinyBasePartyKitServer {
  constructor(party) {
    super(party);
    // custom constructor code
  }

  async onStart() {
    // no need to call super.onStart()
    console.log('Server started');
  }

  async onMessage(message, connection) {
    await super.onMessage(message, connection);
    // custom onMessage code
  }

  async onRequest(request) {
    // custom onRequest code, else:
    return await super.onRequest(request);
  }
}

See the PartyKit server API documentation for more details.

Since

v4.3.0

Constructors

There is one constructor, constructor, within the TinyBasePartyKitServer class.

Methods

These are the methods within the TinyBasePartyKitServer class.

Properties

There is one property, config, within the TinyBasePartyKitServer class.