npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-api-kit

v1.0.3

Published

Reusable Axios + TanStack Query API hooks for React

Downloads

325

Readme

🚀 API Client (Axios + TanStack Query)

A lightweight, opinion-free API client built on Axios and TanStack Query, designed for modern React applications.

✔ No UI dependencies
✔ Global success & error hooks
✔ Works with any toast library
✔ React Query–ready
✔ Production-grade architecture


📦 Installation

npm install axios @tanstack/react-query

Peer requirements

  • React 18+
  • TanStack Query v5+

🔧 Quick Start

1️⃣ Setup React Query Provider

import { QueryClient, QueryClientProvider } from "@tanstack/react-query";

const queryClient = new QueryClient();

export function AppProviders({ children }) {
  return (
    <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
  );
}

2️⃣ Configure the API (Required)

Call setupApi once, ideally at application startup.

import { setupApi } from "react-api-kit";
import { toast } from "react-toastify";

setupApi({
  baseURL: "/api",

  getToken: () => localStorage.getItem("token"),

  toast: {
    success: (msg) => toast.success(msg),
    error: (msg) => toast.error(msg),
  },

  errorMessages: {
    401: "Session expired",
    403: "Access denied",
    500: "Server error",
  },

  onSuccess: (data) => {
    console.log("Global success:", data);
  },

  onError: (error, message) => {
    console.error("Global error:", message, error);
  },

  onLogout: () => {
    localStorage.clear();
    window.location.href = "/login";
  },
});

🔔 Toast Integration (Optional)

This package does not ship a toast library.

You pass your own implementation.


🪝 Hooks

api

import { api } from "react-api-kit";

const fetchUsers = () => api.get("/users").then((res) => res.data);

useApiQuery get

const { data, isLoading } = useApiQuery( ["users"],"GET","/ENDPOINT/,{parems:value},{ ...options} );

useApiMutation

import { useApiMutation, api } from "react-api-kit";

// POST Req
const { mutate, isPending } = useApiMutation(["POST KEY"], "POST", "/users", [
  "Validate",
]);

// GET Req
const { mutate, isPending } = useApiMutation(["GET KEY"], "GET", "/users", [
  "Validate",
]);

// PATCH Req
const { mutate, isPending } = useApiMutation(["PATCH KEY"], "PATCH", "/users", [
  "Validate",
]);

//Delete Feq
const { mutate, isPending } = useApiMutation(
  ["DELETE KEY"],
  "DELETE",
  "/users",
  ["Validate"]
);