Skip to content

Mutation Hooks

Mutation hooks live in use-<entity>-mutations.ts and provide the React hook interface for executing writes with safety enforcement.

Mutation hooks are the authoritative write boundary of the entity system.

They:

  1. wrap raw mutations from <entity>.mutations.ts
  2. enforce hard invariants before writing
  3. convert runtime context into transactional writes and notifications

There is currently no package-wide hooks/mutations barrel export.

Import mutation hooks from entity subpaths:

import { useWorkProjectMutations } from "@life-manager/db/entities/work/project";

If a business rule protects data integrity, it must be enforced here, not only in actions. The mutation hook is the last line of defense before data hits the local database.

  • derive the required current-state facts internally before writing
  • or require the validated guard input when that is the only practical source
  • optional guard input that disables enforcement when omitted

The package is moving toward strong enforcement for all safety-relevant writes.

  • finance/single-cashflow
  • finance/recurring-cashflow
  • work/time-entry
  • work/project