---
title: "Better Axios — Parth Kapoor"
description: "Typed Axios wrapper with built-in auth, interceptors and error handling"
canonical: "https://parthkapoor.me/builds/better-axios"
---

# Better Axios

> Typed Axios wrapper with built-in auth, interceptors and error handling

better-axios is a small TypeScript wrapper around Axios for projects that re-implement the same auth-header and error-handling boilerplate on every API client. It packages that pattern into one class so both API calls and generated CLIs get consistent auth and error behavior.

An `AxiosApi` class wraps an Axios instance, injecting auth tokens onto requests via a configurable header and prefix, and running global or per-call success/error handlers through request and response interceptors, with typed responses and a custom error type. It ships as an npm package with its own CLI (built on Commander and Inquirer) and a docs site.

- Status: shipped
- Language: TypeScript
- Started: Jun 2025
- License: MIT
- Live: https://better-axios.parthkapoor.me
- Source: https://github.com/parthkapoor-dev/better-axios

## Highlights

- Token-based auth with automatic header injection and configurable prefix (e.g. Bearer)
- Global and per-request success/error handlers layered onto Axios interceptors
- Typed responses and a custom error type instead of raw Axios errors
- Ships as a CLI (`axios-wrapper`) built on Commander and Inquirer, alongside the library
- Published to npm as @parthkapoor-dev/better-axios, tested with Jest and axios-mock-adapter

## Stack

- **Language**: TypeScript
- **Core**: Axios
- **CLI**: Commander, Inquirer, Chalk
- **Testing**: Jest, axios-mock-adapter, ts-jest

All builds: [https://parthkapoor.me/builds](https://parthkapoor.me/builds.md)
