Repository navigation
Replies: 2 comments
|
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. |
|
Blitz doesn't have a built-in equivalent to Gun/Yjs/Liveblocks-style collaborative sync. Blitz gives you the full-stack app foundation (RPC, auth, DB access, etc.), but the real-time / concurrency layer is something you would add separately. A practical split is:
So for a collaborative datagrid:
Blitz still fits nicely here for auth, permissions, persistence, and server-side business logic — it just is not the CRDT layer by itself. |
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
All reactions