HyperFetch v8.0.0
website·Indexed 33 days ago
https://hyperfetch.bettertyped.com/An environment-agnostic data fetching and socket management library. It provides a suite of React hooks (such as useSubmit, useQueue, and useStream), socket emitters and listeners, and specialized adapters for GraphQL, Firebase, and Firebase Admin. The ecosystem includes HyperFlow for real-time request and cache insights and an ESLint plugin for static analysis.
What's inside HyperFetch
- HyperFetch is a data-fetching framework that provides a standardized, type-safe approach to handling data across various sources (Axios, GraphQL, Firebase) and platforms (React, React Native, Electron). It ensures type safety for responses, payloads, query parameters, URL parameters, and errors. It also supports real-time communication via adapters for WebSockets, Server-Sent Events (SSE), and Firebase Realtime.
Overview of Hyper Fetch
HyperFetch is a data-fetching framework that provides a single, type-safe API to unify HTTP, GraphQL, Firebase, and real-time sources (such as WebSockets and Server-Sent Events). It is designed to work across React, React Native, and Node.js, offering consistent patterns for caching, queuing, offline support, and request lifecycle management.Overview of the Hyper Fetch Adapter
TheAdapterclass is the core communication layer of Hyper Fetch. It abstracts the execution of requests, enabling the swapping of transport layers (e.g., moving from HTTP to GraphQL or Firebase). Adapters manage the request lifecycle, including mapping payloads and headers, handling query parameters, progress tracking, cancellation, and error handling.Overview of Hyper Fetch Framework
Hyper Fetch is an open-source framework designed for request-based and real-time communication in TypeScript environments. It aims to eliminate boilerplate and streamline data handling by providing a unified solution where fetching logic and state management (hooks) are integrated, rather than detached.Introduction to React Hyper Fetch
React Hyper Fetch is a data fetching library for React 18+ that handles fetching, submitting, streaming, and queueing requests. It adapts the core library's features to the React environment usinguseSyncExternalStoreto ensure correct concurrent mode semantics and prevent tearing. A prerequisite for using its hooks is a previously prepared request object from the core library.Overview of Hyper Fetch
Hyper Fetch is a fetching library that uses class-based architectural patterns to manage server interactions. It is designed to solve complex problems such as request queueing, data caching, offline support, and persistence. It is framework-agnostic but maintains a primary focus on React. The library allows for custom logic additions and supports both REST and GraphQL setups.Overview of HyperFlow DevTools
HyperFlow is a dedicated DevTools suite designed for the Hyper Fetch ecosystem. It allows developers to monitor, debug, and optimize an application's network activity and cache. Key capabilities include real-time visualization of network/cache activity, detailed request/response inspection, performance bottleneck identification, and management of request queues and cache entries.Overview of Hyper Fetch Sockets
The Sockets module for Hyper Fetch provides a unified, type-safe API for real-time, event-driven communication. It supports persistent connections such as WebSockets and Server-Sent Events (SSE), and allows for custom adapters (e.g., for Firebase Realtime Database). The module focuses on consistency and developer experience by using reusable templates for listeners and emitters to ensure type safety across the application.Overview of HyperFetch API layer
HyperFetch is a type-safe API layer for TypeScript applications that replaces fragmented libraries for fetching, caching, and realtime events with a single consistent interface. It supports multiple protocols including REST, GraphQL, Firebase, WebSockets, and SSE using a unified
createRequest()and.send()pattern. Key built-in capabilities include:- Data Layer: Integrated caching, request queuing, retries, deduplication, and offline replay.
- Type Safety: End-to-end TypeScript with inferred parameters from URL strings, typed responses, payloads, and error shapes.
- Realtime: WebSockets, SSE, and Firebase listeners share the same typed request pattern, lifecycle, and retry logic as REST calls.
- Runtime Support: Compatible with Browser, Node, Edge, Mobile, and SSR.
Use Firebase, GraphQL, and Axios adapters
Hyper Fetch 5.0 introduces official adapters for the following:
- Firebase: Supports Admin, Firestore, and Realtime adapters for both Node.js and browser environments.
- GraphQL: A simple adapter with tags parsing, compatible with Node.js and browser.
- Axios: A supercharged adapter for both Node.js and browser.
Use Hyper Fetch in a browser environment
Hyper Fetch is configured to work in browser and mixed environments out-of-the-box. No initial setup or additional configuration is required to integrate it into a browser-based application.Handle errors in Hyper-Fetch without try...catch
Hyper-Fetch requests never reject promises. Instead of usingtry...catchblocks, requests return anerrorobject alongside thedata. This ensures that both success and failure states are handled gracefully as part of the response object.