Skip to content
public-library›Rules›TanStack Query›Define hierarchical query keys and options in factories

Define hierarchical query keys and options in factories

Build each entity's query keys from general to specific, such as entity, then kind, then ID or filters, and define them, together with their query functions, in one factory per entity. Use the factory everywhere the query is read, prefetched, updated, or invalidated.

In the full rule