Replies: 1 comment
-
|
Blitz.js doesn't have built-in real-time collaborative editing like Gun.js or Yjs. Those libraries solve a fundamentally different problem (CRDTs/conflict-free replicated data types for concurrent edits), while Blitz focuses on the RPC layer and full-stack data fetching. That said, you can absolutely integrate real-time sync into a Blitz app. Here are your main options: 1. Yjs + Blitz (best for collaborative editing) Yjs is probably your best bet if you need Google Docs-style collaboration on a datagrid. You can wire it up with a WebSocket provider: // Install: npm install yjs y-websocket
import * as Y from "yjs"
import { WebsocketProvider } from "y-websocket"
const ydoc = new Y.Doc()
const provider = new WebsocketProvider("ws://localhost:1234", "datagrid-room", ydoc)
// Shared data structure for your grid
const yArray = ydoc.getArray("grid-rows")
yArray.observe((event) => {
// React to changes from other users
console.log("Grid updated:", yArray.toJSON())
})You'd run a 2. Socket.IO / WebSockets for simpler real-time If you don't need full CRDT conflict resolution (e.g., users edit different rows, not the same cell simultaneously), plain WebSockets are simpler: // In a custom server or API route
import { Server } from "socket.io"
// Emit updates when a Blitz mutation saves data
export const updateGridRow = resolver.pipe(
resolver.authorize(),
async (input, ctx) => {
const row = await db.gridRow.update({ where: { id: input.id }, data: input })
io.to("datagrid-room").emit("row-updated", row)
return row
}
)3. Liveblocks or PartyKit (managed services) If you want to avoid running your own WebSocket server, Liveblocks or PartyKit drop right into a Next.js/Blitz app and give you presence, cursors, and collaborative storage out of the box. For a datagrid specifically with multiple roles, I'd lean toward Yjs if users edit the same cells concurrently, or Socket.IO if they're mostly working on separate rows and you just need live updates. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Does this have a feature like Gun.js or Yjs
for realtime sync of data in datagrid used by multiple users/roles
Beta Was this translation helpful? Give feedback.
All reactions