How to modify Liveblocks Storage from the server

In realtime applications, Liveblocks Storage is generally modified from the browser with useMutation or through conflict-free data methods. However, it can also be useful to modify your realtime storage from server-side Node.js too.

What we’re doing

In this guide, we’ll demonstrate how to easily modify storage from the server. We’ll do this using @liveblocks/node.

Start modifying storage

We can now start modifying storage from the server!

route.ts
// Creating a node client (centrally)const liveblocks = new Liveblocks({  secret: "",});
export async function POST() { console.log("Updating storage");
// Mutate storage await liveblocks.mutateStorage( "my-room",
({ root }) => { root.get("list").push("item3"); } );
console.log("Storage update complete!");}

We use cookies to collect data to improve your experience on our site. Read our Privacy Policy to learn more.