@@ -1517,45 +1517,46 @@ const { data } = useFetcher('/api/notifications', { staleTime: 600 });
15171517
15181518_fetchff uniquely combines advanced input sanitization, prototype pollution protection, unified cache across React and direct fetches, multiple error handling strategies, and a declarative API repository pattern—all in a single lightweight package._
15191519
1520- | Feature | fetchff | ofetch | wretch | axios | native fetch() | swr |
1521- | -------------------------------------------------- | ----------- | ----------- | ------------ | ------------ | -------------- | ----------- |
1522- | **Unified API Client** | ✅ | -- | -- | -- | -- | -- |
1523- | **Smart Request Cache** | ✅ | -- | -- | -- | -- | ✅ |
1524- | **Automatic Request Deduplication** | ✅ | -- | -- | -- | -- | ✅ |
1525- | **Revalidation on Window Focus** | ✅ | -- | -- | -- | -- | ✅ |
1526- | **Custom Fetching Adapter** | ✅ | -- | -- | -- | -- | ✅ |
1527- | **Built-in Error Handling** | ✅ | -- | ✅ | -- | -- | -- |
1528- | **Customizable Error Handling** | ✅ | -- | ✅ | ✅ | -- | ✅ |
1529- | **Retries with exponential backoff** | ✅ | -- | -- | -- | -- | -- |
1530- | **Advanced Query Params handling** | ✅ | -- | -- | -- | -- | -- |
1531- | **Custom Response Based Retry logic** | ✅ | ✅ | ✅ | -- | -- | -- |
1532- | **Easy Timeouts** | ✅ | ✅ | ✅ | ✅ | -- | -- |
1533- | **Conditional Polling Functionality** | ✅ | -- | -- | -- | -- | -- |
1534- | **Easy Cancellation of stale (previous) requests** | ✅ | -- | -- | -- | -- | -- |
1535- | **Default Responses** | ✅ | -- | -- | -- | -- | ✅ |
1536- | **Custom adapters (fetchers)** | ✅ | -- | -- | ✅ | -- | ✅ |
1537- | **Global Configuration** | ✅ | -- | ✅ | ✅ | -- | ✅ |
1538- | **TypeScript Support** | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
1539- | **Built-in AbortController Support** | ✅ | -- | -- | -- | -- | -- |
1540- | **Request Interceptors** | ✅ | ✅ | ✅ | ✅ | -- | -- |
1541- | **Safe deduping + cancellation** | ✅ | -- | -- | -- | -- | -- |
1542- | **Response-based polling decisions** | ✅ | -- | -- | -- | -- | -- |
1543- | **Request and Response Transformation** | ✅ | ✅ | ✅ | ✅ | -- | -- |
1544- | **Integration with libraries** | ✅ | ✅ | ✅ | ✅ | -- | ✅ |
1545- | **Request Queuing** | ✅ | -- | -- | -- | -- | -- |
1546- | **Multiple Fetching Strategies** | ✅ | -- | -- | -- | -- | -- |
1547- | **Dynamic URLs with Path and query separation** | ✅ | -- | ✅ | -- | -- | -- |
1548- | **Automatic Retry on Failure** | ✅ | ✅ | -- | ✅ | -- | ✅ |
1549- | **Automatically handle 429 Retry-After headers** | ✅ | -- | -- | -- | -- | -- |
1550- | **Built-in Input Sanitization** | ✅ | -- | -- | -- | -- | -- |
1551- | **Prototype Pollution Protection** | ✅ | -- | -- | -- | -- | -- |
1552- | **First Class React Integration** | ✅ | -- | -- | -- | -- | ✅ |
1553- | **Shared cache for React and direct fetches** | ✅ | -- | -- | -- | -- | -- |
1554- | **Per-endpoint and per-request config merging** | ✅ | -- | -- | -- | -- | -- |
1555- | **Declarative API repository pattern** | ✅ | -- | -- | -- | -- | -- |
1556- | **Supports Server-Side Rendering (SSR)** | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
1557- | **SWR Pattern Support** | ✅ | -- | -- | -- | -- | ✅ |
1558- | **Minimal Installation Size** | 🟢 (4.5 KB) | 🟡 (6.5 KB) | 🟢 (2.21 KB) | 🔴 (13.7 KB) | 🟢 (0 KB) | 🟡 (6.2 KB) |
1520+ | Feature | fetchff | ofetch | wretch | axios | native fetch() | swr |
1521+ | -------------------------------------------------- | ----------- | ----------- | ------------ | ------------ | -------------- | --------------- |
1522+ | **Unified API Client** | ✅ | -- | -- | -- | -- | -- |
1523+ | **Smart Request Cache** | ✅ | -- | -- | -- | -- | ✅ |
1524+ | **Automatic Request Deduplication** | ✅ | -- | -- | -- | -- | ✅ |
1525+ | **Revalidation on Window Focus** | ✅ | -- | -- | -- | -- | ✅ |
1526+ | **Custom Fetching Adapter** | ✅ | -- | -- | -- | -- | ✅ |
1527+ | **Built-in Error Handling** | ✅ | -- | ✅ | -- | -- | -- |
1528+ | **Customizable Error Handling** | ✅ | -- | ✅ | ✅ | -- | ✅ |
1529+ | **Retries with exponential backoff** | ✅ | -- | -- | -- | -- | -- |
1530+ | **Advanced Query Params handling** | ✅ | -- | -- | -- | -- | -- |
1531+ | **Custom Response Based Retry logic** | ✅ | ✅ | ✅ | -- | -- | -- |
1532+ | **Easy Timeouts** | ✅ | ✅ | ✅ | ✅ | -- | -- |
1533+ | **Conditional Polling Functionality** | ✅ | -- | -- | -- | -- | -- |
1534+ | **Easy Cancellation of stale (previous) requests** | ✅ | -- | -- | -- | -- | -- |
1535+ | **Default Responses** | ✅ | -- | -- | -- | -- | ✅ |
1536+ | **Custom adapters (fetchers)** | ✅ | -- | -- | ✅ | -- | ✅ |
1537+ | **Global Configuration** | ✅ | -- | ✅ | ✅ | -- | ✅ |
1538+ | **TypeScript Support** | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
1539+ | **Built-in AbortController Support** | ✅ | -- | -- | -- | -- | -- |
1540+ | **Request Interceptors** | ✅ | ✅ | ✅ | ✅ | -- | -- |
1541+ | **Safe deduping + cancellation** | ✅ | -- | -- | -- | -- | -- |
1542+ | **Response-based polling decisions** | ✅ | -- | -- | -- | -- | -- |
1543+ | **Request/Response Data Transformation** | ✅ | ✅ | ✅ | ✅ | -- | -- |
1544+ | **Works with Multiple Frameworks** | ✅ | ✅ | ✅ | ✅ | ✅ | -- |
1545+ | **Works across multiple instances or layers** | ✅ | -- | -- | -- | -- | -- (only React) |
1546+ | **Concurrent Request Deduplication** | ✅ | -- | -- | -- | -- | ✅ |
1547+ | **Flexible Error Handling Strategies** | ✅ | -- | ✅ | ✅ | -- | ✅ |
1548+ | **Dynamic URLs with Path and query separation** | ✅ | -- | ✅ | -- | -- | -- |
1549+ | **Automatic Retry on Failure** | ✅ | ✅ | -- | ✅ | -- | ✅ |
1550+ | **Automatically handle 429 Retry-After headers** | ✅ | -- | -- | -- | -- | -- |
1551+ | **Built-in Input Sanitization** | ✅ | -- | -- | -- | -- | -- |
1552+ | **Prototype Pollution Protection** | ✅ | -- | -- | -- | -- | -- |
1553+ | **First Class React Integration** | ✅ | -- | -- | -- | -- | ✅ |
1554+ | **Shared cache for React and direct fetches** | ✅ | -- | -- | -- | -- | -- |
1555+ | **Per-endpoint and per-request config merging** | ✅ | -- | -- | -- | -- | -- |
1556+ | **Declarative API repository pattern** | ✅ | -- | -- | -- | -- | -- |
1557+ | **Supports Server-Side Rendering (SSR)** | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
1558+ | **SWR Pattern Support** | ✅ | -- | -- | -- | -- | ✅ |
1559+ | **Minimal Installation Size** | 🟢 (4.5 KB) | 🟡 (6.5 KB) | 🟢 (2.21 KB) | 🔴 (13.7 KB) | 🟢 (0 KB) | 🟡 (6.2 KB) |
15591560
15601561## ✏️ Examples
15611562
0 commit comments