You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

axiosx-dev

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

axiosx-dev

A lightweight React hook wrapper around Axios with interceptors, auth, retry, and cancellation support.

1.0.2
latest
npmnpm
Version published
Maintainers
1
Created
Source

AxiosX Dev

AxiosX is a tiny React hook library for smart Axios requests with built-in:

  • Token auth & request interceptors
  • Retry logic & cancellation
  • Clean React state: status, isLoading, data, error
  • Supports GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS

🚀 Install

npm install axiosx-dev axios react

✅ Quick Start

import { init, useGet, usePost } from 'axiosx-dev';

// 1️⃣ Initialize once (e.g. in App.tsx)
init({
  baseURL: 'https://api.example.com',
  withAuth: true,
  tokenKey: 'token',
  maxRetries: 2,
  retryDelay: 500,
  on401: (err) => console.warn('Not authorized!', err),
});

// 2️⃣ Use inside a component
const { get, isLoading, data, error, cancelRequest } = useGet();

get('/users');

if (isLoading) console.log('Loading...');
if (error) console.log(error);

✅ Hooks

HookHTTP MethodDescription
useGetGETPerforms a GET request.
usePostPOSTPerforms a POST request.
usePutPUTPerforms a PUT request.
useDeleteDELETEPerforms a DELETE request.
usePatchPATCHPerforms a PATCH request.
useHeadHEADPerforms a HEAD request.
useOptionsOPTIONSPerforms an OPTIONS request.

✅ Examples

useGet

const { get, data, isLoading, status } = useGet();
useEffect(() => {
  get('/users');
}, []);

usePost

const { post, data } = usePost();
post('/users', { name: 'John' });

✅ Config Options

OptionTypeDescription
baseURLstringBase URL for the Axios instance.
timeoutnumberRequest timeout in milliseconds.
headersRecord<string, string>Custom headers to attach to every request.
withAuthbooleanWhether to add an Authorization header with a Bearer token.
tokenKeystringKey name in localStorage to read the token from.
getToken`() => stringnull`
on401(error: any) => voidCallback for handling 401 Unauthorized errors.
onError(error: any) => voidGlobal error handler callback for failed requests.
maxRetriesnumberNumber of retry attempts for failed requests.
retryDelaynumberDelay in ms between retry attempts.

✅ Docs

👉 Full Docs: https://axiosx-dev-docs.vercel.app (free Vercel subdomain)

MIT License.

Keywords

axios

FAQs

Package last updated on 18 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts