New Project
A collaborative AI spreadsheet powered by Liveblocks.
This example shows how to build a realtime, multiplayer spreadsheet with an AI that edits the grid, using Liveblocks, Handsontable, Next.js, and the Vercel AI SDK.
The grid is backed by Liveblocks Storage, so cells, formatting, column/row sizes,
and order all sync instantly to everyone — along with live selection presence and
per-cell comment threads. Everything is addressed by stable ids, so moving,
sorting, and inserting or deleting rows and columns never breaks comments,
formatting, or presence, and every user sees the same order. The AI lives in a
Feeds-based
chat: it edits the spreadsheet from the server with @liveblocks/node
(mutateStorage) and shows its live selection with setPresence, streaming both
its reply and the grid edits as it works.
Run the following command to try this example locally:
npx create-liveblocks-app@latest --example nextjs-ai-spreadsheet --api-key
This will download the example and ask permission to open your browser, enabling you to automatically get your API key from your liveblocks.io account.
Alternatively, you can set up your project manually:
npm install.env.local file and add your secret key as the
LIVEBLOCKS_SECRET_KEY environment variableAI_GATEWAY_API_KEY from the
Vercel AI Gateway. This is required for
the AI chat — it needs a real, tool-calling model to edit the spreadsheet.npm run dev and go to http://localhost:3000To see the realtime sync, open the page in two browser tabs and edit a cell, drag a row, or ask the AI to fill in some data — it appears instantly in both.
To both deploy on Vercel, and run the example locally, use the following command:
npx create-liveblocks-app@latest --example nextjs-ai-spreadsheet --vercel
This will download the example and ask permission to open your browser, enabling you to deploy to Vercel.
After forking
this example
on CodeSandbox, create the LIVEBLOCKS_SECRET_KEY environment variable as a
secret.