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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@amirsohail1/react-super-api

v1.3.9

Published

react-super-api allows you to easily fetch, send, update, and delete data from any database with minimal code. No need to manage useState or useEffect

Downloads

43

Readme

React Super API

Node Super Logger License Downloads

🚀 Welcome Developers!

react-super-api allows you to easily fetch, send, update, and delete data from any database with minimal code. No need to manage useState or useEffect—our library handles everything efficiently using TanStack Query under the hood.

⚠️ This library is currently under development, and only basic API operations with optimizations have been added.


📦 Installation

Install via npm:

npm install @amirsohail1/react-super-api

Or using Yarn:

yarn add @amirsohail1/react-super-api

🔌 Setup

Wrap your application with the Wrapper component to initialize the library.

Make sure to wrap your main file (where you render your React app):

import { createRoot } from "react-dom/client";
import { Wrapper } from "@amirsohail1/react-super-api";
import App from "./App.jsx";

createRoot(document.getElementById("root")).render(
  <Wrapper>
    <App />
  </Wrapper>
);

🔥 Usage

1️⃣ Fetch Data using useGetData

Import the library and use useGetData:

import { useGetData } from "@amirsohail1/react-super-api";

const { data, isPending, error } = useGetData({
  name: "users",
  url: "https://jsonplaceholder.typicode.com/users",
});

Parameters:

  • name (required): A unique identifier for caching.
  • url (required): API endpoint for fetching data.
  • options (optional): An object for additional configurations.

Returned Values:

  1. data → Contains the fetched data.
  2. isPending → Boolean to check if data is loading.
  3. error → Contains any errors encountered.

⏳ Optional Optimizations

You can pass an options object with additional settings:

const { data, isPending, error } = useGetData({
  name: "users",
  url: "https://jsonplaceholder.typicode.com/users",
  options: { refetchInterval: 10000, staleTime: 60000, cacheTime: 300000 },
});
  • refetchInterval → Auto-fetch data every X milliseconds.
  • staleTime → Duration before data is considered stale.
  • cacheTime → How long data remains cached after becoming unused.

2️⃣ Send Data using useSendData

import { useSendData } from "@amirsohail1/react-super-api";

const CreateUser = () => {
  // also have mutate
  const { mutate, data, isPending, error } = useSendData({
    name: "createUser",
    url: "https://jsonplaceholder.typicode.com/users",
  });

  const handleCreate = () => {
    // wrap all the data and pass into mutate function
    mutate({ name: "John Doe", email: "[email protected]" });
  };

  return (
    <div>
      <button onClick={handleCreate} disabled={isPending}>
        {isPending ? "Creating..." : "Create User"}
      </button>
      {error && <p>Error: {error.message}</p>}
      {data && <p>User Created: {data.name}</p>}
    </div>
  );
};

3️⃣ Update Data using useUpdateData

import { useUpdateData } from "@amirsohail1/react-super-api";

const UpdateUser = () => {
  // also have mutate
  const { mutate, data, isPending, error } = useUpdateData({
    name: "updateUser",
    url: "https://jsonplaceholder.typicode.com/users/1",
  });

  const handleUpdate = () => {
    // wrap all the data and pass into mutate function
    mutate({ name: "Jane Doe", email: "[email protected]" });
  };

  return (
    <div>
      <button onClick={handleUpdate} disabled={isPending}>
        {isPending ? "Updating..." : "Update User"}
      </button>
      {error && <p>Error: {error.message}</p>}
      {data && <p>User Updated: {data.name}</p>}
    </div>
  );
};

4️⃣ Delete Data using useDeleteData

import { useDeleteData } from "@amirsohail1/react-super-api";

const DeleteUser = () => {
  // also have mutate
  const { mutate, isPending, error } = useDeleteData({
    name: "deleteUser",
    url: "https://jsonplaceholder.typicode.com/users/1",
  });

  const handleDelete = () => {
    // in case of delete just call the function
    mutate();
  };

  return (
    <div>
      <button onClick={handleDelete} disabled={isPending}>
        {isPending ? "Deleting..." : "Delete User"}
      </button>
      {error && <p>Error: {error.message}</p>}
    </div>
  );
};

New Update in version: "1.3.6"

Now when use useSendData , useUpdateData , useDeleteData you should see the promise success or fail massage


Also you can now Get isError & isSuccess form useSendData , useUpdateData , useDeleteData that return boolean value


🎯 Why Use react-super-api?

Minimal Boilerplate – Fetch, send, update, and delete data in just 1-2 lines of code.
Optimized Performance – Uses caching and automatic refetching to minimize API calls.
No Need for useState & useEffect – The library handles state and side effects for you.
Error Handling Built-in – Get structured error responses for debugging.


📜 License

This project is licensed under the MIT License.


Start coding efficiently with react-super-api today! 🚀