qmetrics.net

Axios Hooks

React hooks layer for axios HTTP requests

axios-hooks wraps axios in React hooks with optional caching, manual execution, automatic refetch on config changes, and built-in server-side rendering support.

Overview

axios-hooks is a small React library that exposes HTTP calls through a `useAxios` hook while keeping axios as the underlying client. You install it alongside axios as a peer dependency and use a one-line hook signature for typical GET-style data loading.

Returned state includes data, loading, error, and response objects, plus `execute` for manual requests and `manualCancel` to abort in-flight calls. Options control immediate versus manual firing, per-hook caching, SSR participation, and whether pending requests auto-cancel when parameters change.

The package ships helpers to configure global axios instances, LRU-backed response caches, and default hook options. `makeUseAxios` creates isolated hook factories when different APIs or cache policies are needed. `serializeCache` and `loadCache` pass preloaded request results from server render to client hydration.

Hook arguments are compared deeply, so memoize functions in config objects to avoid refetch loops. Testing guidance notes that default caching can leak between tests unless caching is disabled in test setup.

Key features

  • useAxios hook around axios
  • Built-in SSR cache serialize and load
  • Manual and automatic request modes
  • LRU response caching
  • Global configure and makeUseAxios
  • Auto-cancel on config changes
  • Deep-equality driven refetching

Use cases

  • React data fetching with axios
  • SSR apps hydrating API cache
  • Deferred POST and PUT submissions
  • Multiple APIs via hook instances

Tags

Similar software

FastAPI

Python web framework for building APIs with type hints

FastAPI is a Python web framework for building APIs using standard type hints. It builds on Starlette and Pydantic and generates interactive OpenAPI documentation for the endpoints you define.

★ 105.1k⟳ 9 days agoMIT

NestJS

Progressive TypeScript framework for Node.js backends

Nest organizes Node server apps with modules, dependency injection, and first-party packages for auth, data, queues, and observability.

★ 77.2k⟳ todayMIT

OkHttp

HTTP client for JVM, Android, and GraalVM

OkHttp is an HTTP client library tuned for efficient networking on Android, Java, and GraalVM native images. It offers synchronous and asynchronous call APIs with a fluent request builder.

★ 47.1k⟳ yesterdayApache-2.0
Frameworks & PlatformsDesktop/CLI app

gRPC

Cross-language remote procedure call framework

gRPC is an RPC framework that lets client and server programs communicate transparently and supports building connected, multi-language systems.

★ 45.5k⟳ todayApache-2.0

tRPC

End-to-end typesafe TypeScript APIs without code generation

tRPC helps teams define server procedures and call them from clients with full TypeScript types for inputs, outputs, and errors—no schemas or codegen step.

★ 40.9k⟳ todayMIT
Frameworks & PlatformsDesktop/CLI app

go-zero

Cloud-native Go microservices and RPC framework

go-zero is a Go web and RPC framework with code generation, built-in resilience middleware, and tooling aimed at stable high-traffic services.

★ 33.5k⟳ 9 days agoMIT