Upgrading - Upgrading to 3.0
Liveblocks 3.0 is our third major release, focusing on our newest product, AI Copilots. We’ve used this as an opportunity to tidy up some of our existing APIs, ensuring consistency throughout our offering.
How to upgrade
First of all, let’s upgrade all Liveblocks dependencies to their latest versions. The easiest way to do that is to run the following command:
There are some breaking changes in this update.
Does this affect you?
If you’re using TypeScript 4.9 or lower, TypeScript 5.0 is now the minimum supported version.
If you’re using Comments and/or Text Editor, please read about changes to mentions.
If you’re using Notifications, please read about a change related to notification settings.
If you’re using
@liveblocks/emails, please read
about changes to its returned values.
If you’re using
LiveblocksUIConfig,
please read about its renaming.
If you’re using any deprecated APIs (e.g. useBatch, useStorageStatus,
useEditorStatus…), please read about the ones being removed.
Otherwise, you can simply upgrade your packages and no changes will affect you.
Mentions
We’re making some changes to mentions in Comments and Text Editor to support different mention kinds in future releases: user mentions, group mentions, etc.
Components
The onMentionClick prop on Thread and Comment now receives a
MentionData object as its first argument instead of a userId string.
Primitives
When customizing the
Mention
component on the Comment.Body and Composer.Editor primitives, the
userId prop has been replaced by a mention one which is a MentionData
object.
When customizing the
MentionSuggestions
component on the Composer.Editor primitive, the userIds prop has been
replaced by a mentions one which is an array of MentionData objects, and the
selectedUserId prop has been renamed to selectedMentionId.
@liveblocks/emails
The prepareTextMentionNotificationEmailAsReact and
prepareTextMentionNotificationEmailAsHtml functions’ returned data changed
slightly:
- The
idproperty is now namedtextMentionId, it refers to the mention’s Text Mention ID, not the user ID used for the mention - The
idproperty now refers to the mention’s ID, as in the user ID used for the mention - The
kindproperty now indicates the mention’s kind (e.g."user","group", etc.)
When customizing the
Mention
component in the prepareTextMentionNotificationEmailAsReact function, the
element prop’s userId property has been renamed to id, and element.kind
now indicates the mention’s kind.
Utilities
The getMentionedIdsFromCommentBody utility (from
@liveblocks/client and
@liveblocks/node) has been replaced by
getMentionsFromCommentBody.
By default, if the optional second argument is not provided, all mentions are returned, including future mention kinds (e.g. group mentions in the future).
Notification settings
2.24 introduced a few naming changes around the concepts of “notification settings” and “subscription settings” to improve clarity. 3.0 removes the aliases for the previous names but it also introduces one change that we couldn’t make in 2.24:
The UPDATE_USER_NOTIFICATION_SETTINGS_ERROR error has been renamed to
UPDATE_NOTIFICATION_SETTINGS_ERROR.
@liveblocks/emails
The functions to prepare HTML/React emails are now more consistent, using the
same body and content properties instead of reactBody/htmlBody and
reactContent/htmlContent.
LiveblocksUiConfig
The
LiveblocksUIConfig
utility has been renamed to LiveblocksUiConfig (UI → Ui) for consistency
with other Liveblocks APIs.
Run the following codemod or manually make the changes:
Removed deprecated APIs
All of the following APIs have been removed in 3.0, as they were deprecated multiple versions ago.
Affecting all packages:
- The
codeproperty has been removed fromLiveblocksError, useLiveblocksError.context.codeinstead for better TypeScript support. - The deprecated aliases from the
2.24 naming changes have been removed, use
their new names instead. There’s a codemod available to automatically use the
new names:
npx @liveblocks/codemod@latest rename-notification-settings.
Affecting @liveblocks/client:
- The
unstable_fallbackToHTTPclient option has been removed, setlargeMessageStrategyto"experimental-fallback-to-http"instead.
Affecting @liveblocks/node:
- The
metadataoption has been removed from thegetRoomsmethod, usequery.metadatainstead. - The
nextPageproperty has been removed from thegetRoomsmethod’s response, usequery.nextPageinstead. - The
RoomDatatype has been removed, useRoomInfoinstead. There’s a codemod available to automatically use the new type:npx @liveblocks/codemod@latest room-info-to-room-data.
Affecting @liveblocks/react:
- The
useBatchhook has been removed, useuseMutationinstead for writing to Storage, which will automatically batch all mutations. - The
useStorageStatushook has been removed, useuseSyncStatusinstead for tracking sync status, it reflects the sync status of all parts of Liveblocks.
Affecting @liveblocks/react-lexical:
- The
useEditorStatushook has been removed, useuseSyncStatusinstead for tracking sync status, it reflects the sync status of all parts of Liveblocks.