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-fly-api

v1.0.13

Published

Fast communication system based on Axios and React Query for React

Readme

React Fly Api

react-fly-api

Fast communication system based on Axios and React Query for React

React Fly Api is a utility library designed to simplify API interactions in React applications. It leverages axios for HTTP requests and react-query for state management, offering a dynamic and easy-to-use API solution.

Features

  • Dynamic API Methods: Automatically generates useQuery and useMutation hooks for API endpoints.
  • Axios Integration: Pre-configured Axios client for flexible and efficient HTTP requests.
  • React Query Support: Seamless integration with react-query for state management and caching.
  • TypeScript Ready: Full support for TypeScript with strict type definitions.

Installation

npm install react-fly-api

Usage

Step 1: Wrap Your Application with the Provider

To enable react-query's features, wrap your application with the ReactFlyApiProvider.

import React from 'react';
import ReactDOM from 'react-dom';
import { ReactFlyApiProvider } from 'react-fly-api';

ReactDOM.render(
  <ReactFlyApiProvider>
    <App />
  </ReactFlyApiProvider>,
  document.getElementById('root')
);

Step 2: Configure APIs

Before using the library, configure your API list and Axios client settings using the configureApis function.

import { configureApis } from 'react-fly-api';

const apilist = {
  user: [
    { name: 'getUser', method: 'GET', endpoint: '/user' },
    { name: 'createUser', method: 'POST', endpoint: '/user' },
    { name: 'user_info', method: 'POST', endpoint: '/user_info' },

  ],
};

const clientConfig = {
  ssl: true,
  domain: 'api.example.com',
  port: 443,
  prefix: '/v1',
  headers: { Authorization: 'Bearer token' },
};

configureApis(apilist, clientConfig);

Step 3: Use APIs

Use the useApis hook to access dynamically generated methods for a specific category.

import { useApis } from 'react-fly-api';

function App() {
  const { getUser, user_info } = useApis('user');

  const { data, isLoading } = getUser();
  const { data: infoData, isLoading: infoIsLoading, isError: infoIsError, mutate: infoMutate, isSuccess: infoIsSuccess } = user_info();
  
  const getUserInfo=()=>{
      infoMutate(
            {userid:"custom-id"},
            {
              onSuccess: async (rd: any) => {
              },
              onError: (error: any) => {
                console.log('Error:', error);
              },
            }
          );

  }

  return (
    <div>
      <h1>User Info</h1>
      {isLoading ? <p>Loading...</p> : <pre>{JSON.stringify(data)}</pre>}
      <button onClick={() => getUserInfo("custom-id")}>get User info</button>
    </div>
  );
}

export default App;

API Reference

configureApis

Configures the global API client and API list.

Parameters:

  • apilist: An object defining categories and their API configurations.
  • clientConfig: (Optional) Axios client configuration. Defaults to the provided default settings.

useApis

Returns dynamically generated API methods for a given category.

Parameters:

  • category: The name of the category (must exist in the configured apilist).

Returns:

  • An object containing useQuery and useMutation hooks for each API in the category.

Example Configuration

const apilist = {
  product: [
    { name: 'getProducts', method: 'GET', endpoint: '/products' },
    { name: 'createProduct', method: 'POST', endpoint: '/products' },
  ],
};

const clientConfig = {
  ssl: true,
  domain: 'api.example.com',
  port: 443,
  prefix: '/api',
  headers: { Authorization: 'Bearer example-token' },
  timeout: 10000,
};

configureApis(apilist, clientConfig);

License

This project is licensed under the MIT License.