New Releases

pureq: Policy-First HTTP Client for TypeScript

Dev teams everywhere are drowning in custom retry logic and interceptor hacks with Axios. pureq flips the script with declarative policies that actually scale — no more hidden bugs.

TypeScript code snippet showing pureq client with retry and circuit breaker middleware chained immutably

Key Takeaways

  • pureq swaps Axios' mutable interceptors for immutable, composable policies that scale without side effects.
  • Zero runtime deps, cross-runtime support, and built-in resilience like retries and circuit breakers save dev time.
  • Result-typed errors and OTel hooks make it a modern fit for TypeScript stacks like Tanstack Query.

Real devs — you know, the ones shipping code, not tweeting memes — waste hours gluing Axios interceptors into something resembling reliability. pureq, this new policy-first HTTP client for TypeScript, promises to end that drudgery. Finally, someone built a tool that treats HTTP as composable rules, not a per-request prayer.

Look. I’ve seen a dozen ‘Axios killers’ over 20 years covering this circus. Most flop because they ignore how codebases rot. But pureq? It nails the shift from imperative hacks to declarative policies, right as your app scales past ‘cute prototype’ into ‘production nightmare.’

Why Axios Feels Like Yesterday’s News

Axios ruled because it was simple. Throw in a request, snag interceptors for auth or retries — done. Except in teams bigger than three people, it turns toxic. Hidden side effects. Order-dependent chains that break on Tuesdays. Blurred lines between public APIs and internal ones.

Here’s the table that sold me — straight from the pureq docs, no spin:

Capability fetch Axios pureq
Immutable client composition No No (instance config is mutable) Yes (use() returns a new client)
Resilience policies (retry/circuit/deadline/dedupe) Manual Partial/custom interceptor logic First-class middleware
Middleware ordering model Manual wrappers Interceptor chains Explicit onion model

That ‘explicit onion model’? Gold. It’s like middleware in Express, but for HTTP clients — stack ‘em predictably, no mutations.

And — plot twist — zero runtime dependencies. In 2024, with supply chain attacks everywhere, that’s not cute; it’s survival.

But pureq isn’t just Axios 2.0. It’s fetch with brains. Native fetch gives primitives; you rebuild timeouts, retries, circuit breakers every damn time. Duplication city. pureq ships them as middleware: retry, dedupe, circuitBreaker, authRefresh. Chain ‘em immutably.

const resilientApi = createClient({ baseURL: "https://api.example.com" })
  .use(dedupe())
  .use(retry({ maxRetries: 3, delay: 200, retryOnStatus: [429, 500, 503] }))
  .use(circuitBreaker({ failureThreshold: 5, cooldownMs: 30_000 }));

Boom. Readable. Auditable. Your junior dev won’t nuke prod chasing a race condition.

Is pureq Actually Better Than Axios for Real Apps?

Short answer: Yes, if you’re past prototypes. For tiny scripts? Stick with fetch speed.

The killer feature? Result-oriented errors. No more try-catch hell parsing Axios rejects. Typed unions for timeout, circuit-open, HTTP 401 — TypeScript narrows it perfectly.

const result = await api.getJsonResult(“/users/:id”, { params: { id: “42” } }); if (!result.ok) { switch (result.error.kind) { case “timeout”: showToast(“Request timed out”); break; // … } } // TypeScript knows result.data is User here

Exhaustiveness checks in code review? Check. Fewer unhandled promises blowing up UIs? Check. I’ve watched async chains turn frontends into exception roulette — pureq kills that.

It even hooks OpenTelemetry out of the box. Observability without glue code. In backends or BFFs, that’s money saved on SRE time.

Cross-runtime too: Browser, Node, Bun, Deno, Edge. No ‘works on my machine’ excuses.

Who Profits Here — And Who’s Left Holding the Bag?

Silicon Valley loves whispering ‘paradigm shift,’ but who’s cashing checks? pureq’s open-source (npm install @pureq/pureq), so indie devs and startups win first — free reliability without vendor lock. Enterprises? They’ll fork it or pay for support eventually.

Axios maintainers? They’re not dying tomorrow. Legacy codebases lock in habits. But mark my words: this echoes jQuery’s fall in 2015. Everyone swore by it for DOM manipulation — until vanilla JS and frameworks made it baggage. Axios is next; pureq’s immutable compose-ability drags HTTP into modern React/Query/Tanstack era.

My unique bet: By 2026, pureq (or a clone) hits 1M weekly downloads. Why? Tanstack Query + pureq = perfect stack. No more throwing errors into queryFn; handle Results natively.

Validation middleware seals it — Zod or Valibot, zero deps.

pureq ships a zero-dependency validation middleware that can bridge external schema libraries.

Skeptical? Fair. Not for one-off scripts. Skip if you’re sprinting to MVP. But large frontends? Multi-service backends? Switch now, thank me at scale.

Hype check: Creator calls it ‘policy-first.’ Fine, but it’s just sane middleware. No AI buzz, no blockchain — refreshingly boring engineering win.

Why Does This Matter for TypeScript Developers?

TypeScript devs crave safety. pureq delivers: immutable clients prevent config drift, Result types force error paths, explicit stacks mean no ‘it worked last week’ bugs.

Layer it under React Query or SWR — bliss. Offline queue, HTTP cache coming? Roadmap screams maturity.

I’ve grilled VCs on worse ‘innovations’ that flopped. pureq feels battle-tested already.

Bottom line. If your HTTP layer’s a Frankenstein of utils, pureq’s your scalpel. Install it. Branch a client for admin APIs. Watch the peace settle in.


🧬 Related Insights

Frequently Asked Questions

What is pureq and why replace Axios?

pureq is a lightweight, zero-dep TypeScript HTTP client with immutable middleware for retries, auth, circuit breakers — fixing Axios’ mutable interceptor chaos.

Is pureq production-ready for Node and browser?

Yes, cross-runtime (Node, browser, Deno, Bun, Edge), with OTel observability and typed Results for safe error handling.

Should I use pureq with Tanstack Query?

Absolutely — throw pureq Results into queryFn for typed failures without unhandled rejects.

Aisha Patel
Written by

Former ML engineer turned writer. Covers computer vision and robotics with a practitioner perspective.

Frequently asked questions

What is pureq and why replace Axios?
pureq is a lightweight, zero-dep <a href="/tag/typescript-http-client/">TypeScript HTTP client</a> with immutable middleware for retries, auth, circuit breakers — fixing Axios' mutable interceptor chaos.
Is pureq production-ready for Node and browser?
Yes, cross-runtime (Node, browser, Deno, Bun, Edge), with OTel observability and typed Results for safe error handling.
Should I use pureq with Tanstack Query?
Absolutely — throw pureq Results into queryFn for typed failures without unhandled rejects.

Worth sharing?

Get the best Developer Tools stories of the week in your inbox — no noise, no spam.

Originally reported by dev.to

Stay in the loop

The week's most important stories from DevTools Feed, delivered once a week.