Upgrading - Upgrading to 1.0
Liveblocks 1.0 is our first major release, marking the end of the beta period
for storage and conflict-free data types. This release includes improvements to
our pricing model that make billing more predictable. Additionally, we have
vastly improved the ability to animate cursors at up to 60fps by updating the
throttle option in createClient. The primary change you should note is the
transition to making the userId mandatory in the authorize option. This
change is in line with our new pricing model.
Let’s take a look!
Upgrading steps by package
@liveblocks/node
To update @liveblocks/node to 1.0, run the following command using your
preferred package manager:
We have updated the authorize method to make userId mandatory. This change
ties into our new pricing model, which is based
on Monthly Active Users (MAU) instead of connections. We use userId to track
MAU associated with a Liveblocks account.
If you do not use the authorize function because you are using the public API
key method, a cookie will be set in the browser when a user connects to a room.
This cookie will be used to track MAU associated with a Liveblocks account and
will expire after 30 days.
If you do not use the authorize function, but call the authorize endpoint
with a secret key instead, you should pass the userId even though it is not
mandatory on the API level because the userID will be used for MAU. Set the
Authorization: Bearer header to your secret key.
Set the following the request body:
Improvements
We added additional features to Webhooks,
enhancements to the Room class, and more. You can review the
release notes for more
details.
@liveblocks/client
To update @liveblocks/client to 1.0, run the following command using your
preferred package manager:
Improvements to throttle allow animation of up to 60fps
You can now specify the throttle option in
createClient
that can go as low as 16ms. If not set, the default value is 100ms.
You can see the marked improvement in the animation from 80ms (original limit) to 16ms in this tweet. If you want to try it out for yourself, check out live cursors example.
New methods available on the Room class
We added new methods to the Room class that you can use to obtain the storage
status of a room, subscribe to storage status changes, or reconnect to a room
whenever necessary. You can also use the
Liveblocks DevTools extension to visualize realtime changes to
storage while implementing these changes.
Use room.getStorageStatus to retrieve the storage status of a room. The
statuses are:
not-loaded: Initial state when entering the room.loading: Once the storage has been requested via room.getStorage().synchronizing: When some local updates have not been acknowledged by Liveblocks servers.synchronized: Storage is in sync with Liveblocks servers.
Use room.subscribe to subscribe to storage status changes. This method returns
an unsubscribe function.
You can use room.reconnect() to close the room connection and try to
reconnect.
@liveblocks/node
Webhooks enhancements
We have added two new events to our Webhooks functionality: RoomCreatedEvent
and RoomDeletedEvent. We have also added a WebhookHandler class to make it
easier to verify event requests from Liveblocks’ Webhooks functionality. It also
provides fully typed WebhookEvents.
Verification of events is critical to ensure that the events are coming from Liveblocks and not from a malicious source. Check out our Webhooks guide for more details.
That’s it!
If you have issues with these new patterns and need help, please let us know by email or by joining our Discord community! We’re here to help!