惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Apple Machine Learning Research
Apple Machine Learning Research
Last Week in AI
Last Week in AI
Blog — PlanetScale
Blog — PlanetScale
V
Visual Studio Blog
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
博客园 - Franky
IT之家
IT之家
博客园 - 叶小钗
Engineering at Meta
Engineering at Meta
The GitHub Blog
The GitHub Blog
雷峰网
雷峰网
腾讯CDC
博客园 - 聂微东
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
V2EX
人人都是产品经理
人人都是产品经理
MongoDB | Blog
MongoDB | Blog
大猫的无限游戏
大猫的无限游戏
Martin Fowler
Martin Fowler
宝玉的分享
宝玉的分享
博客园_首页
G
Google Developers Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
I built a 1.73 KB axios alternative with zero dependencie...
Yash Garudka · 2026-05-17 · via DEV Community

Yash Garudkar

I got mass an email from npm in March 2026 about the axios supply chain attack. A North Korean state actor compromised a maintainer and injected malicious code into the most popular HTTP client on npm. Millions of projects affected overnight.

That's when I looked at what axios actually does: it merges config, builds URLs, adds headers, runs interceptors, and wraps the response. All of that is maybe 200 lines of TypeScript on top of native fetch. But axios ships 53 KB gzipped with 2 dependencies that have their own dependencies.

So I built glyde - a TypeScript-first HTTP client with zero runtime dependencies. 1.73 KB gzipped.

What it looks like

import plane from "glyde"

const api = plane({ baseURL: "https://api.example.com" })

// Typed GET
const { data } = await api.get<User[]>("/users")

// POST with body
await api.post("/users", { name: "Yash", role: "admin" })

// Query params
await api.get("/search", { params: { q: "glyde", page: 1 } })

Enter fullscreen mode Exit fullscreen mode

plane() creates an independent instance with its own config and interceptors. No shared global state.

Typed errors instead of status code checking

This is what error handling looks like with most HTTP clients:

// The old way
try {
  await axios.get("/data")
} catch (err) {
  if (err.response?.status === 404) { /* maybe? */ }
  // What type is err? Who knows.
}

Enter fullscreen mode Exit fullscreen mode

With glyde, errors have a type hierarchy with type guards:

import { isHttpError, isTimeoutError, isGlydeError } from "glyde"

try {
  await api.get("/data")
} catch (err) {
  if (isHttpError(err)) {
    // TypeScript knows: err.status, err.response, err.config
    console.log(err.status)        // 404
    console.log(err.response?.data) // parsed body
  }

  if (isTimeoutError(err)) {
    // request exceeded timeout
  }
}

Enter fullscreen mode Exit fullscreen mode

The error hierarchy:

GlydeError (base)
+-- HttpError      - non-2xx response (has status, response, config)
+-- TimeoutError   - request exceeded timeout
+-- NetworkError   - fetch failed (DNS, offline, CORS)

Enter fullscreen mode Exit fullscreen mode

Async interceptors

Unlike most libraries that only support synchronous transforms, glyde interceptors are fully async:

// Refresh a token before every request
api.interceptors.request.use(async (config) => {
  const token = await getToken()
  return {
    ...config,
    headers: { ...config.headers, Authorization: `Bearer ${token}` },
  }
})

// Unwrap nested API responses
api.interceptors.response.use((response) => ({
  ...response,
  data: response.data.result,
}))

Enter fullscreen mode Exit fullscreen mode

Next.js App Router pattern

glyde works anywhere fetch exists, but I designed it with Next.js in mind. The recommended pattern:

Server-side (tower):

import plane from "glyde"
import { cookies } from "next/headers"

export async function tower() {
  const api = plane({ baseURL: process.env.API_BASE_URL })
  const cookieStore = await cookies()

  api.interceptors.request.use((config) => {
    const token = cookieStore.get("access_token")?.value
    if (token) {
      config.headers = { ...config.headers, Authorization: `Bearer ${token}` }
    }
    return config
  })

  return api
}

Enter fullscreen mode Exit fullscreen mode

Client-side (passenger):

"use client"
import plane from "glyde"

export const passenger = plane({ baseURL: "/api/proxy" })

passenger.interceptors.response.use(
  (response) => response,
  (error) => {
    if (error?.status === 401) window.location.href = "/login"
    throw error
  }
)

Enter fullscreen mode Exit fullscreen mode

Token refresh? Handle it in Next.js middleware where you can actually write cookies. Don't fight the framework.

The numbers

glyde axios
Size (gzipped) 1.73 KB 53 KB
Dependencies 0 2
TypeScript Written in TS Types bolted on
Engine Native fetch Legacy XHR

Install

npm install glyde

Enter fullscreen mode Exit fullscreen mode

Works in browsers, Node.js 18+, Bun, Deno, and Cloudflare Workers.


I'm actively working on retry plugins, request deduplication, and more interceptor examples. If you have feedback or feature requests, open an issue on GitHub.