@liveblocks/core
Advanced tools
Changelog
v1.1.0
This release improves the client’s internals to ensure a more reliable connection with Liveblocks servers.
@liveblocks/client
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.)@liveblocks/react
useStatus()
- React hook version of room.getStatus()
useLostConnectionListener()
- React hook version of
room.subscribe("lost-connection")
(See this
example for an
illustration.)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')
clientOptions.fetchPolyfill
clientOptions.WebSocketPolyfill
→ ✅
clientOptions.polyfills: { fetch, WebSocket }