Fix a small TypeScript issue introduced in 1.1.7.
When initializing the client with a
custom auth callback,
you can now return { error: "forbidden", reason: ... }
as the response, which
the client will treat as a sign to stop retrying. The client will then
disconnect from the room, instead of remaining in "connecting"
status
indefinitely.
Fix a bug with useSelf()
where it would not correctly re-render after entering
an empty room. It’s now consistent again with useMyPresence()
.
Fix a bug in the Liveblocks DevTools panel where the "me" view would incorrectly stay empty after entering an empty room.
Loosen duplicate import detection so it won't throw when used in test runners that deliberately run multiple instances of a module (like Jest or Playwright can do).
- Ship all of our packages as both ESM and CJS modules again (restore the changes that 1.1.3 originally introduced).
- Auto-detect if multiple copies of Liveblocks are included in your production bundle. If so, a help page is presented that will help you resolve this issue.
- Fix a bug where the room internals could become non-functional when used in combination with Immer due to Immer’s excessive auto-freezing, which would break the room’s internals. (This became an issue since Liveblocks 1.1 was released.)
Undo the changes made in 1.1.3. We’ve got some bug reports where Liveblocks could still be doubly-included in production bundles (in some bundler setups only), with storage data corruptions as a possible result. We’re investigating.
Ship all of our packages as both ESM and CJS modules. By upgrading, your project’s bundler can now perform (better) tree-shaking on the Liveblocks code.
You can expect (at least) the following bundle size reductions:
@liveblocks/client
from 80kB → 70kB@liveblocks/react
from 129kB → 80kB@liveblocks/redux
from 84kB → 38kB@liveblocks/zustand
from 83kB → 37kB@liveblocks/yjs
from 129kB → 74kB
Added Yjs support to open beta through the new @liveblocks/yjs
package
(not stable yet).
Fixes a missing internal export.
Fixes a bug where under certain circumstances the Liveblocks client could
incorrectly throw a Not started yet
error message.
This release improves the client’s internals to ensure a more reliable connection with Liveblocks servers.
- New APIs:
room.getStatus()
: returns the current status of the WebSocket connection:"initial"
,"connecting"
,"connected"
,"reconnecting"
, or"disconnected"
room.subscribe("status")
: subscribe to changes of the connection status.room.subscribe("lost-connection")
: high-level API to get informed when Liveblocks’ automatic reconnection process is taking longer than usual, so you can show a toast message on screen. (See this example for an illustration.)
- New behavior:
- The client will stop retrying to establish a connection in cases where retrying would not help. For example an explicit 403 forbidden response from your backend, or a configuration error.
- The client will more quickly reconnect even after long periods of sleep.
- New APIs:
useStatus()
- React hook version ofroom.getStatus()
useLostConnectionListener()
- React hook version ofroom.subscribe("lost-connection")
(See this example for an illustration.)
- Reconnection would sometimes not work after long periods of sleep. Waking up is now instant.
- React clients using Suspense could sometimes incorrectly bounce back to the Suspense boundary after a successful load. No longer!
- Client could sometimes not load storage after reconnecting. Not anymore!
- Others array will no longer flash during an internal reconnect.
- DevTools now keeps working even when the client goes offline.
These APIs still work, but are replaced by newer APIs. The old APIs will be removed in a future release of Liveblocks.
Old connection status codes are replaced by the new ones:
❌ Old statuses | ✅ New statuses |
---|---|
closed | initial |
authenticating | connecting |
connecting | connecting |
open | connected |
unavailable | reconnecting |
failed | disconnected |
Recommended steps to upgrade:
- ❌
room.getConnectionState()
→ ✅room.getStatus()
- ❌
room.subscribe('connection')
→ ✅room.subscribe('status')
- Old client options:
- ❌
clientOptions.fetchPolyfill
- ❌
clientOptions.WebSocketPolyfill
→ ✅clientOptions.polyfills: { fetch, WebSocket }
- ❌
- Added
export type TypedRoom = Room<...>
to init command for non-React apps
- Fix a bug where undo/redo on
LiveObject
creates exponentially larger deltas
- Fix a bug related to proactive token expiration detection
- Internal refactorings
- Add unstable_fallbackToHTTP option to the core client to support messages over 1MB
- Fix incorrect status code when Liveblocks server cannot be reached temporarily
- Export
LiveListUpdate
,LiveMapUpdate
, andLiveObjectUpdate
types used by the storage update callback. - Export new utility,
toPlainLson
, to assist in calling the initialize storage API - Internal refactorings
- Internal refactorings
- Added
flags
for creating config files with
--init
(e.g.--framework react
) - Added an error if an incorrect flag is used
- Slightly changed the format of the default config file
- Internal refactorings
- Private API changes only.
- Release
create-liveblocks-app
along with other Liveblocks packages, using the same versioning scheme. - Internal refactorings.
Non-existent.
Non-existent.
Non-existent.
Fix bug where passing down shouldInitiallyConnect
connection option would not
always work.
Log stack traces of function calls that resulted in rejected storage mutations to the console in non-production builds to ease debugging.
- Fixes bug where the state of
others
in a room was wrong when:- Client A disconnects improperly (ex: computer goes to sleep)
- Then Client B disconnects (ex: computer goes to sleep)
- Then Client A reconnects: client B still shows in the
others
state
This major release marks the maturity of Liveblocks. For upgrade instructions, see the 1.0 upgrade guide.
authorize
option userId
is now mandatory.
Our new pricing is based on Monthly Active
Users instead of connections. We're using userId
to track MAU associated to a
Liveblocks account.
WebhookHandler
now handlesRoomCreatedEvent
andRoomDeletedEvent
- Allow
createClient
throttle
option to go as low as 16ms.
- Adds a
WebhookHandler
classnew WebhookHandler(secret).verifyRequest({ rawBody, headers })
can be used to verify event requests from Liveblock's Webhook functionality. It also provides fully typedWebhookEvents
.- Check out our Webhooks guide for more details
- Fixes a bug where history didn't reliably undo
LiveObject
key set changes if any pending local changes existed on that key. - Fixes a bug where changes performed inside
room.batch
were incorrectly ordered inside the history resulting in unexpected undo behavior in some cases. - Fixes a bug where under some circumstances the Liveblocks client could get stuck in a "synchronizing" state indefinitely
- Expose
JsonArray
andJsonScalar
types publicly
Fix nested storage event handling issue.
Support authentication with cookies.
Export the StorageStatus
type (introduced with 0.19.3).
Fix CORS issue.
In @liveblocks/client:
Get the storage status.
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.
Subscribe to storage status changes.
Returns an unsubscribe function.
room.subscribe("storage-status", (status) => {
switch (status) {
case "not-loaded":
break;
case "loading":
break;
case "synchronizing":
break;
case "synchronized":
break;
default:
break;
}
});
Close the room connection and try to reconnect.
- Add support for the upcoming Liveblocks browser extension
Fixes some internal type definitions.
Fixes an issue where import
s from Liveblocks packages could not be resolved
correctly in certain build environments.
This release brings Zustand v4 support. This is a breaking change only if you’re using @liveblocks/zustand.
In @liveblocks/zustand:
- Support Zustand v4 (actually v4.1.3 or higher)
- Drop support for Zustand v3 (also v4.1.2 or lower are not supported)
- Fix bug where some usage pattern could cause the Zustand store to stop synching (#491)
To migrate, make the following code changes:
npm install zustand@latest
npm install @liveblocks/zustand@latest
- Change these imports, if applicable:
and
-import { middleware } from "@liveblocks/zustand"; +import { liveblocks } from "@liveblocks/zustand";
and rename accordingly.-import type { LiveblocksState } from "@liveblocks/zustand"; +import type { WithLiveblocks } from "@liveblocks/zustand";
- Change the pattern:
to the Zustand v4 recommended pattern:
create(liveblocks<MyState, ...>(...))
To be clear:create<WithLiveblocks<MyState, ...>>()(liveblocks(...))
- First, move the type annotation away from the
liveblocks
middleware call, and onto thecreate
call. - Next, wrap your
MyState
type in aWithLiveblocks<...>
wrapper. This will make sure the injectedliveblocks
property on your Zustand state will be correctly typed. - Finally, make sure to add the extra call
()
wrapper, needed by Zustand v4 now:create<WithLiveblocks<MyState, ...>>()(liveblocks(...)) // ^^ Not a typo
- First, move the type annotation away from the
- Remove the second argument to
state.liveblocks.enterRoom()
: it no longer takes an explicit initial state. Instead, it's automatically be populated from your Zustand state.
In @liveblocks/redux:
- The main export has been renamed:
-import { enhancer } from "@liveblocks/redux"; +import { liveblocksEnhancer } from "@liveblocks/redux";
- The second argument to
state.liveblocks.enterRoom()
to send in an explicit initial state is no longer supported. It will use the state in your Redux store, for consistency and ease of use.
Bug fix:
- Fixes a small bug in a type definition,
scopes
was removed fromBaseUserMeta
.
Internal updates:
- Switch the monorepo over to Turborepo.
All packages now provide an isReadOnly
flag on user instances. It is available
when getting self or others. isReadOnly
is true when storage is read-only, see
the
room management guide
for more information.
const me = room.getSelf();
me.isReadOnly; // boolean
const others = room.getOthers();
for (const other of others) {
other.isReadOnly; // boolean
}
In @liveblocks/client:
-
Add a new option
shouldInitiallyConnect
toclient.enter
that let you control whether or not the room connects to Liveblocks servers. Default istrue
.Usually set to false when the client is used from the server to not call the authentication endpoint or connect via WebSocket.
In @liveblocks/react:
-
Add a new property
shouldInitiallyConnect
toRoomProvider
that let you control whether or not the room connects to Liveblocks servers. Default istrue
.By default equals to
typeof window !== "undefined"
, meaning the RoomProvider tries to connect to Liveblocks servers only on the client side. -
Internal package restructurings to increase code sharing. You may notice a new dependency show up in your dependency tree:
@liveblocks/core
. It contains private APIs that aren't intended for direct consumption.
-
In @liveblocks/react:
Fixes the "zombie-child" problem that can occur with React 17 or lower. If you’re on React 18: great, you can ignore this! If you’re using React 17 or lower with Liveblocks, we’ll now start to enforce that you pass the
unstable_batchedUpdates
prop to RoomProvider, so this problem can be circumvented. This small addition may save you hours of debugging time!// ⚠️ Only if you’re using React 17 or lower import { unstable_batchedUpdates } from "react-dom"; // 👈 <RoomProvider id="my-room" initialPresence={...} initialStorage={...} unstable_batchedUpdates={unstable_batchedUpdates} // 👈 > <App /> </RoomProvider>
To read more, see https://liveblocks.io/docs/guides/troubleshooting#stale-props-zombie-child
-
In @liveblocks/zustand:
- Fix a confusing error message
-
In @liveblocks/react:
- Make sure that
useOther
will not rerender if tracked users already left the room, so that child components won't get rerendered before the parent got the chance to unmount them. - Disallow
useOther
without selector
- Make sure that
-
In @liveblocks/react:
- Fix a bug that could cause an error when patching presence during local development. Not an issue in production builds. (#505)
For information, please read our Upgrade Guide for 0.18.
-
In @liveblocks/react:
-
In @liveblocks/client:
- New
.toImmutable()
method onLiveObject
,LiveList
, andLiveMap
lets you work with an immutable representation of the storage objects - Improved core performance
- Reduced bundle size
- Others only become visible in the
others
array if their presence is known
- New
- Remove support for directly importing hooks from @liveblocks/client (e.g.
import { useMyPresence } from '@liveblocks/react'
). If you’re still using these imports, see the Upgrade Guide for 0.17 for instructions. - Remove
ClientProvider
anduseClient
hook - Remove
defaultPresence
anddefaultStorageRoot
arguments. (Just useinitialPresence
andinitialStorage
arguments now.) - Remove second argument to
useMap()
,useList()
, anduseObject()
. - Remove
new LiveMap(null)
support. (Just usenew LiveMap()
ornew LiveMap([])
.)
General:
- Fix a packaging bug
In @liveblocks/react:
- Deprecate an undocumented API
- Fix bug that could cause duplicate copies of @liveblocks/client to end up in final bundle, for certain bundler configurations.
- Fix bug where in some conditions the initial presence for a new connection would not come through to all existing clients in the room
- Various internal changes
-
In @liveblocks/client:
- Add
canUndo()
andcanRedo()
utilities toroom.history
- Add
"history"
event type toroom.subscribe()
to subscribe to the current user's history changes
- Add
-
In @liveblocks/react:
- Add
useCanUndo()
anduseCanRedo()
hooks
- Add
-
In @liveblocks/zustand:
- Simplify zustand middleware integration with Typescript.
TPresence
,TStorage
,TUserMeta
, andTRoomEvent
are now optional.
- Simplify zustand middleware integration with Typescript.
Note that @liveblocks/zustand
does not work with zustand > v4 because v3 and
v4 have completely different type definitions. As soon as zustand v4 is out of
the RC phase, we will consider updating our middleware to work with the latest
version.
Let's take a look at our To-do list example. Without our middleware, the store would look like this:
import create from "zustand";
type State = {
draft: string;
isTyping: boolean;
todos: Todo[];
setDraft: (draft: string) => void;
addTodo: () => void;
deleteTodo: (index: number) => void;
};
create<State>(/* ... */);
With our middleware, you simply need to move the State
param at the middleware
level:
import create from "zustand";
import { createClient } from "@liveblocks/client";
import { middleware } from "@liveblocks/zustand";
const client = createClient({ /*...*/ });
type State = {
draft: string;
isTyping: boolean;
todos: Todo[];
setDraft: (draft: string) => void;
addTodo: () => void;
deleteTodo: (index: number) => void;
};
create(
middleware<State>(/* ... */, {
client,
presenceMapping: { isTyping: true },
storageMapping: { todos: true }
})
);
If you want to type others
presence, you can use the TPresence
generic
argument on the middleware.
type Presence = {
isTyping: true;
}
const useStore = create(
middleware<State, Presence>(/* ... */, {
client,
presenceMapping: { isTyping: true },
storageMapping: { todos: true }
})
);
// In your component
useStore(state => state.liveblocks.others[0].presence?.isTyping)
-
In @liveblocks/react:
- Expose
RoomContext
in the return value ofcreateRoomContext()
- Expose
-
In @liveblocks/react:
- Fix bug where changing the
key
argument ofuseMap()
,useList()
,useObject()
did not resubscribe to updates correctly - Ignore changes to the
RoomProvider
's initial presence/storage props on subsequent renders. This makes it behave closer touseState(initialState)
- Fix bug where changing the
Fix missing documentation for hooks created via createRoomContext()
.
Fix @liveblocks/nodes
packaging.
For information, please read our Upgrade Guide.
This release contains major TypeScript improvements. The recommended setup now is that you define your own Presence and Storage types at the highest level (i.e. where you set up the room). After that initial one-time setup, you will no longer need to provide any extra type annotations anywhere for your Liveblocks code! 🙌
To learn how to set that up, follow the instructions in our Upgrade Guide.
- No more
any
types used (in@liveblocks/client
and@liveblocks/react
) - All APIs that work with Presence data will now require it to be JSON-serializable
- All APIs that work with Storage data will now require it to be LSON (= JSON + Live structures)
- All Live structures now take mandatory type params for their payloads, just
like the built-in array, object, and map types do:
LiveMap<K, V>
(likeMap<K, V>
)LiveObject<{ a: number, b: string }>
(like, for example,{ a: number, b: string }
)LiveList<T>
(likeArray<T>
)
We now support React Native! To learn how to use Liveblocks in your React Native projects, see our API reference. It's surprisingly simple!
-
In @liveblocks/react:
createRoomContext()
is now the preferred way to initialize hooks.
-
In the API:
- New endpoint to Get Users in a Room
- New endpoint to Get a list of all Rooms
- Improved conflict resolution on LiveList
- Various minor internal bug fixes
-
In @liveblocks/client:
- Removed old
Room.unsubscribe()
API
- Removed old
-
In @liveblocks/client:
- The
defaultPresence
option toclient.enter()
will get renamed toinitialPresence
- The
defaultStorageRoot
option toclient.enter()
will get renamed toinitialStorage
- Calling
new LiveMap(null)
will stop working. Please usenew LiveMap()
, ornew LiveMap([])
- The
-
In @liveblocks/react:
- Importing the React hooks directly is deprecated, instead use the new
createRoomContext()
helper. For help, read the Recommended Upgrade Steps section within our Upgrade Guide - The second argument to
useList()
,useObject()
, anduseMap()
is deprecated - The RoomProvider's
defaultPresence
is renamed toinitialPresence
- The RoomProvider's
defaultStorageRoot
is renamed toinitialStorage
- Importing the React hooks directly is deprecated, instead use the new
Fix bug in internal code where some legal authentication tokens would be considered invalid.
Internals only.
Internals only.
Fix an issue where the current user's info would not properly display accented characters.
(Unpublished.)
Internals only.
Expose helper type to help users adopt to using Live structures with interfaces they don't own.
Restructures a few more internals.
Restructures a few internals.
Fix bug in private/internal code.
Fix bug in private/internal code.
Fix bug in example code suggested in deprecation warning.
- Various internal refactorings
-
In @liveblocks/client:
- If you're using
@liveblocks/client
in a ES2015 context, you no longer have to polyfillObject.fromEntries()
.
- If you're using
- Improve our generated bundles. They are now even more tree-shakable, and smaller!
- Some APIs are being deprecation and will show warnings in the dev console when used
-
In @liveblocks/client:
- Fix bug where internal presence state could not get restored correctly after undo/redo in certain circumstances.
-
In @liveblocks/zustand and @liveblocks/redux:
-
Fixes an issue when initializing an array with items would result in having duplicated items in other clients. Example:
- Client A updates state :
{ list: [0] }
- Client B states is updated to :
{ list: [0, 0] }
- Client A updates state :
-
-
In @liveblocks/client:
- Fix small bug related to new
JsonObject
type, which would reject some values that were legal JSON objects.
- Fix small bug related to new
-
In @liveblocks/react:
- Fix issue with React 18 and StrictMode.
Set one element at a specified index.
const list = new LiveList(["🦁", "🦊", "🐵"]);
list.set(0, "🐺");
list.toArray(); // equals ["🐺", "🦊", "🐵"]
liveblocks#147 for more information
LiveList.set
, you need to make sure that all connected
clients are using 0.16.0
. If a client is connected to a room with version
< 0.16
, LiveList.set
might lead to slightly unexpected behavior.
@nvie improved our typescript definitions! They are more precise and restrictive
(for your own good :)). If typescript errors appears after upgrading to 0.16.0
and they are not clear, please create a Github issue and we'll help you.
More information here: liveblocks#150