A type-safe, resilient, and tiny fetch wrapper for TypeScript that never throws on non-200 responses.
gretchen is a lightweight fetch wrapper for TypeScript that enhances the native fetch API with type safety, configurable retries, timeouts, and lifecycle hooks. It ensures errors are handled gracefully by never throwing on non-200 responses and provides precise typing for both success and error responses. The library is designed to be minimal, resilient, and easy to integrate into modern web applications.
TypeScript developers building web applications who need a reliable, type-safe HTTP client with built-in error handling and retry capabilities. It's ideal for projects prioritizing predictable API interactions and minimal bundle size.
Developers choose gretchen for its combination of type safety, non-throwing error handling, and lightweight design. Unlike other fetch wrappers, it uses discriminated unions for precise typing of both success and error responses, offers configurable retries and hooks, and maintains a tiny footprint.
Making fetch happen in TypeScript.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses TypeScript discriminated unions to precisely type both success and error responses, ensuring compile-time safety and eliminating runtime surprises.
Offers automatic retries with customizable attempts, status codes, methods, and exponential backoff, including respect for the Retry-After header for resilient requests.
Designed to be lightweight, with a tiny footprint that won't bloat your application, as evidenced by its small bundle size on bundlephobia.
Provides before and after hooks for intercepting requests and responses, enabling easy logging, header modification, or error tracking without cluttering business logic.
Requires manual polyfilling of fetch, Promise, and Object.assign in IE11 and Node.js environments, adding setup overhead and complexity.
Lacks built-in support for request cancellation (beyond timeouts), response caching, or advanced interceptors, making it less suitable for complex HTTP scenarios compared to libraries like Axios.
Its primary benefits are tied to TypeScript, so it offers minimal advantage for JavaScript-only projects, potentially limiting its appeal in mixed or non-TypeScript codebases.