Introduction
Welcome to the documentation for BoltFetch.
What is BoltFetch?
BoltFetch is a fast, flexible, and fully type-safe HTTP client wrapper around the native fetch API, built specifically for TypeScript and Bun.
While the native fetch API is a massive improvement over old tools like XMLHttpRequest, it still leaves a lot to be desired in modern development:
- You have to manually parse JSON (
await response.json()). - It doesn't throw errors on 404s or 500s (only on network failures), forcing you to manually check
response.ok. - Query parameters must be manually serialized into URL strings.
- There are no built-in timeouts.
- It relies entirely on untyped
try/catchblocks for error handling.
BoltFetch solves all of these problems while remaining extremely lightweight and dependency-free.
Why use BoltFetch?
- Type-Safe: Built with TypeScript, providing strict typings for requests, responses, and errors.
- No
try/catchHell: Returns standardized success and error objects, allowing for cleaner, linear error handling without nesting. - Native Fetch: Built entirely on the modern, native
fetchAPI. No bloated dependencies. - Interceptors: Easily hook into requests and responses globally to add auth tokens, logging, or transform data.
- Timeouts: Native support for aborting requests using timeouts via
AbortController. - Response Parsing: Built-in automatic parsing for
Json,Text,Blob, andArrayBuffer. - Query Parameters: Easily pass
paramsobjects which are automatically serialized into URL query strings. - Configurable Client: Create multiple client instances with base URLs and global configs using
configureBoltFetchClient.
Ready to get started? Head over to the Installation guide.