db-core/mutations-optimistic
Installation
SKILL.md
Mutations & Optimistic State
Depends on:
db-core/collection-setup-- you need a configured collection (withgetKey, sync adapter, and optionallyonInsert/onUpdate/onDeletehandlers) before you can mutate.
TanStack DB mutations follow a unidirectional loop: optimistic mutation -> handler persists -> handler waits for sync/ack -> confirmed state. Optimistic state is applied in the current tick and dropped when the handler resolves.
Setup -- Collection Write Operations
insert
import { safeRandomUUID } from '@tanstack/db'