mcpField
Y
yjs-nextjs

yjs-nextjs

github.com/pproencaDevelopment21861 installsUpdated 11w ago
Repository

About yjs-nextjs

yjs-nextjs is a coding reference skill for collaborative Yjs editing in Next.js 16 App Router apps. Its rules target Yjs 13.6.31 and address synchronization, persistence, React binding, and subtle data-loss risks under concurrent editing.

Key features

  1. 01Covers sync topology and dependency choices
  2. 02Explains binary update transport and persistence
  3. 03Guides shared-type data modeling
  4. 04Handles React document lifecycle and binding
  5. 05Covers undo, offline loading, and cursors
  6. 06Guides Tiptap and form integration

Use cases

  1. 01Add collaborative editing or offline sync to a Next.js app
  2. 02Debug content loss or duplication under concurrent edits
  3. 03Design Y.Doc persistence and update compaction
  4. 04Review Yjs Provider lifecycle in React

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/pproenca/dot-skills --skill yjs-nextjs

After installing, type/yjs-nextjsin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

AGENTS.md
metadata.json
assets/templates/
_template.md
references/
_sections.md
hist-scope-undo-by-origin.md
hist-snapshots-require-gc-disabled.md
hist-wait-for-indexeddb-sync.md
host-authorize-rooms-not-updates.md
host-pin-the-yjs-13-track.md
host-route-handlers-cannot-upgrade.md
host-trpc-is-not-the-sync-channel.md
host-vercel-lacks-instance-affinity.md
host-websocket-server-is-not-production.md
model-nested-types-not-plain-objects.md
model-seed-the-document-once.md
model-yarray-has-no-move.md
model-ytext-only-for-prose.md
pres-awareness-is-ephemeral.md
pres-relative-positions-for-cursors.md
react-keep-yjs-client-only.md
react-stable-doc-and-provider.md
react-subscribe-via-usesyncexternalstore.md
ui-do-not-drive-inputs-from-the-doc.md
ui-tiptap-collaboration-wiring.md
wire-base64-not-superjson.md
wire-compaction-needs-a-doc-roundtrip.md
wire-rehydrate-to-uint8array.md
wire-send-updates-not-state.md

Details

From the project README

Yjs in Next.js 16, tRPC, and shadcn/ui

Yjs 13.6.31 in an App Router codebase — the decisions collaborative editing forces and how to settle them, written so an agent applies them while writing or reviewing code. Each rule names the wrong default it corrects; there is no rule for things the model already gets right.

Most of these failures are silent. Yjs converges, the editor keeps working, and the data loss surfaces later as "my change reverted" — so the rules below lead with the evidence of the failure, most of it measured directly against Yjs 13.6.31 rather than asserted.

When to Apply

  • Building collaborative editing, presence, or offline sync into a Next.js 16 App Router app
  • Choosing shared types for a document model, or reviewing one that loses edits under concurrency
  • Deciding where the sync backend runs, or wiring tRPC procedures alongside a Yjs provider
  • Persisting Y.Doc state to a database, or compacting stored updates
  • Binding a Yjs document to React — provider lifecycle, subscriptions, Strict Mode, SSR
  • Wiring Tiptap or shadcn/ui form controls to a live document
  • Debugging a document that syncs but duplicates, blanks, or reverts content

This skill does not cover general Next.js App Router patterns (use the nextjs skill), general tRPC usage (trpc), or shadcn/ui component conventions (shadcn) — only where those intersect with a CRDT.

Version Pin

Rules target Yjs 13.6.31 with y-websocket 3.0.0, y-protocols 1.0.7, and y-indexeddb 9.0.12. Yjs is mid-migration to v14 under the @y/* scope, and several packages have already moved latest or main onto that prerelease track — @y/[email protected] depends on yjs@^14.0.0-7. See host-pin-the-yjs-13-track before installing anything.

Rule Categories

#CategoryPrefixCovers
1Sync Topology & Dependencieshost-Where the sync loop runs, which backend to build on, where the trust boundary sits, which versions are on the v13 track
2Binary Transport & Persistencewire-Moving Uint8Array updates across JSON boundaries and into storage
3Modeling State in Shared Typesmodel-Which shared type per field — decides whether concurrent edits merge or destroy each other
4Doc Lifecycle & React Bindingreact-One document across renders, Strict Mode, subscriptions, the server boundary
5Undo, Snapshots & Offline Loadhist-Origin-scoped history, garbage collection, load ordering
6Awareness & Cursorspres-Ephemeral presence and positions that survive concurrent edits
7Editor & Form Integrationui-Tiptap and shadcn/ui form controls against a live document

Quick Reference

1. Sync Topology & Dependencies
2. Binary Transport & Persistence
3. Modeling State in Shared Types
4. Doc Lifecycle & React Binding
5. Undo, Snapshots & Offline Load
6. Awareness & Cursors
7. Editor & Form Integration

How to Use

Read a reference file when its decision comes up. Each rule names the wrong default it corrects, then shows the canonical way, with an incorrect/correct contrast where the wrong way is a real trap.

When debugging rather than writing, start from the symptom:

SymptomRead first
Document loads blankwire-rehydrate-to-uint8array, hist-wait-for-indexeddb-sync
Content appears twicemodel-seed-the-document-once, ui-tiptap-collaboration-wiring
Someone's edit silently revertedmodel-nested-types-not-plain-objects, hist-scope-undo-by-origin
List items duplicate when draggedmodel-yarray-has-no-move
Two editors never see each otherhost-vercel-lacks-instance-affinity
A user edited a field they should not reachhost-authorize-rooms-not-updates
A collaborator's avatar lingers after they leavepres-awareness-is-ephemeral
Caret jumps to the end while typingui-do-not-drive-inputs-from-the-doc
Infinite render loop or snapshot errorreact-subscribe-via-usesyncexternalstore
Works in production, broken in devreact-stable-doc-and-provider

Reference Files

FileDescription
references/_sections.mdCategory definitions and ordering
assets/templates/_template.mdTemplate for new rules
AGENTS.mdAuto-built table of contents across all rules
metadata.jsonVersion and source references

Related Skills

  • nextjs — App Router caching, Server Components, and routing outside the CRDT layer
  • trpc — tRPC v11 router, link, and subscription rules in full
  • shadcn — component composition and form patterns this skill builds on
  • zod — the validators used in the tRPC procedure examples here

Comments

Markdown supported