Skip to content

createNizhalMutators

Copy page
import { createNizhalMutators } from "@nizhal/db-collection";
const { mutate } = createNizhalMutators({
collections: { notes: notesCollection },
echo,
mutators: kernelMutators,
onlineDetector, // optional — reactNativeOnlineDetector on RN
});

Wraps kernel defineMutators with TanStack offline-transactions:

  • Optimistic local apply via TanStack DB
  • mutationFn POSTs batches to /sync/push with idempotency key
  • Bounded retries; deterministic failures → poison quarantine (REQ-13)
  • Dependent mutations cascade-cancel so the queue keeps draining

Surface quarantined entries via createNizhalStatus — show the user a fix/retry path instead of a silent stuck sync.

Web: browser online events. RN: reactNativeOnlineDetector() from @nizhal/react-native (NetInfo peer).