A modern, typed wrapper around Axios β with clean APIs, built-in token management, interceptors, and smart global handlers.
Say goodbye to repetitive axios setup in every project.
better-axios
helps you build scalable APIs faster with features like:
- β Global and custom error/success handlers
- β Token-based auth with automatic header injection
- β Type-safe responses with custom error types
- β Request/response interceptors
- β Easy-to-extend and override
- β Built-in support for UI feedback patterns
npm install @parthkapoor-dev/better-axios
# or
yarn add @parthkapoor-dev/better-axios
- π Fully typed API with TypeScript
- π Token auth with prefix config (
Bearer
, etc.) - π Interceptors (great for refresh tokens)
β οΈ Global & local success/error handlers- π§ Easy to use
setDefaultHeader()
,removeAuthToken()
, etc. - π¦ Minimal bundle, no runtime dependencies except
axios
import { AxiosApi } from "@parthkapoor-dev/better-axios"
const api = new AxiosApi({
baseURL: "https://api.example.com",
})
api.get("/users").then((res) => {
console.log(res.data)
})
π Explore the full docs here: https://better-axios.parthkapoor.me
- Getting Started
- Auth Token Management
- Interceptors (Request / Response)
- Global vs Custom Handlers
- Error Handling Strategies
- Recipes & Use Cases
Found a bug or have a feature request? We welcome contributions!
# clone the repo
git clone https://github.com/parthkapoor-dev/better-axios.git
# install deps
npm install
# run tests
npm run test
MIT License Β© Parth Kapoor