Capxul Docs
Explanation

Cache ownership and identity

Why Capxul owns its query-key namespace and clears it when clients change.

React applications often share one TanStack Query cache across many domains. Capxul therefore roots all package-owned keys at ["capxul"]. This gives the provider a bounded namespace to remove when the active client changes without clearing unrelated application state.

shared QueryClient
├── ["products", ...]       application-owned
├── ["preferences", ...]    application-owned
└── ["capxul", ...]         Capxul-owned

Replacing a Capxul client removes only the last branch. The application's other queries survive.

Identity belongs in the key

Identity and actor inputs are part of scoped keys. Personal Account and Organization reads cannot safely share a cache entry merely because they call the same method family. Mutations invalidate the read models they can affect, including balances, payments, activity, or Organization treasury projections.

Without actor identity in the key, switching from a personal Account to an Organization could briefly display data cached for the wrong scope. The key shape prevents that category of cross-scope reuse.

Let hooks own invalidation

The key catalog is implementation detail. Consumers rely on hook invalidation contracts instead of manually constructing keys, which leaves the package free to strengthen scope identity without breaking application code.

Use the published hooks and their mutation results. Do not build application logic around an observed internal query key, and do not clear the entire shared QueryClient when only the Capxul identity changes.

On this page