Axios → ky / native fetch
easyAxios is 13kb minified+gzipped. Ky is 4kb and built on fetch. For most apps the bundle savings and modern API are worth the migration.
Estimated: 1-3h · 5 steps
Progress0%
Step 1: Install ky
npm uninstall axios && npm install ky
Step 2: Create instance
Configure base URL, headers, timeout once.
import ky from 'ky'
export const api = ky.create({ prefixUrl: process.env.NEXT_PUBLIC_API_URL, timeout: 10000 })Step 3: Replace request calls
axios.get(url).then(r => r.data) → api.get(url).json(). Errors throw HTTPError instead of axios error shape.
Step 4: Update interceptors
Axios interceptors → ky hooks (beforeRequest, afterResponse, beforeError). Auth refresh handled in afterResponse.
Step 5: Verify FormData and uploads
✓ All requests succeed. Bundle size reduced. No regressions in error handling.