Skip to content

Awesome key factory

A type-safe key factory for managing react-query keys with full TypeScript support.

Quick Example

typescript
import { createKeyFactory } from 'awesome-key-factory';

const queryKeys = createKeyFactory('app', {
  users: {
    all: () => [],
    detail: (params: { id: string }) => [params.id],
  },
  posts: {
    all: () => [],
    detail: (params: { id: string }) => [params.id],
  },
});

// Usage in React Query
useQuery({
  queryKey: queryKeys.users.detail({ id: '123' }),
  queryFn: () => fetchUser('123'),
});

Released under the MIT License.