We've significantly enhanced our dashboard, alongside other changes, such as conditionally rendering Liveblocks hooks, fetching unread notifications, a better search dialog, and improved Comments examples.
In the past month we’ve made a huge amount of enhancements to our dashboard,
helping improve observability and developer experience. For example, you can now
visualize Comments and Text Editor state directly in the dashboard.
When building a collaborative React application, it can be helpful to re-use
components both inside and outside Liveblocks rooms. For example in a Liveblocks
document, a header bar could display a live avatar stack of every connected
user, but outside the document, you won’t need it.
Previously, it wasn’t possible to conditionally render Liveblocks hooks in this
way, but we’ve added a new hook that makes this much easier,
useIsInsideRoom.
Below, we’re only rendering <LiveAvatars /> inside Liveblocks rooms.
functionHeaderAvatars(){// `true` if inside a Liveblocks room, `false` otherwiseconst isInsideRoom =useIsInsideRoom(); if(!isInsideRoom){returnnull;} return<LiveAvatars/>;} functionLiveAvatars(){const others =useOthers();return others.map((other)=><imgsrc={other.info.picture}/>);}
Along with hiding components completely,
useIsInsideRoom can
also be used to render alternative parts. Let’s say you have an interactive list
of tags built with Storage.
Outside of rooms, you could instead render non-interactive data, for example
with a data-fetching library instead, such as SWR.
When fetching inbox notifications in your back end, you can now filter by unread
notifications, making it easier than before to create email notifications, or
render from your back end.
We’ve taken time to upgrade the search dialog in our documentation—it
now searches through more of our website, and is much better at finding results.
Make sure to try it out next time you’re developing, you can open it with
Cmd/Ctrl + K or by pressing the input at the top right of the docs.
It’s particularly helpful as it can search through headings on each page, and
will scroll down to the exact section you need.
We’ve spent some time polishing our canvas-based Comments examples, showing you
how to take care of various edge cases, such as flipping comments before they go
off the edge of the screen. You can try a live demo of our
Next.js Canvas Comments
example below, a simple example using x/y coordinates.
We’ve similarly improved
Next.js Overlay Comments,
a complex example which demonstrates how you might attach comments to any HTML
elements, or website, enabling preview comments.