React hooks for data fetching with smart caching, background updates, and full TypeScript support.
npm install qortex-reactimport { useQuery, useMutate, registerFetcher } from 'qortex-react';// Register a fetcherregisterFetcher('users', async () => {const res = await fetch('/api/users');return res.json();});// Use in your componentfunction UserList() {const { data, isLoading, error } = useQuery('users');if (isLoading) return <div>Loading...</div>;if (error) return <div>Error: {error.message}</div>;return (<ul>{data.map(user => (<li key={user.id}>{user.name}</li>))}</ul>);}
Automatic request deduplication and caching
Stale-while-revalidate with previousData
Keep showing old data during refetch
Full type inference for your data
Declarative error states with retry
Optional localStorage/sessionStorage sync
| Hook | Description |
|---|---|
useQuery | Fetch and cache data with loading/error states |
useMutate | Perform mutations with optimistic updates |
useQueryData | Subscribe to cached data reactively |
useQuerySelect | Select and transform cached data |
qortex-react re-exports everything from qortex-core, so you get all the core functionality too.
import { useQuery, registerFetcher, fetchQuery, getQueryData } from 'qortex-react';Lightweight and optimized for performance.
~0.7KB (React) + ~1.9KB (Core)
2.6KB / 10KB Performance Budget