
Security News
Open Source CAI Framework Handles Pen Testing Tasks up to 3,600× Faster Than Humans
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
react-api-utils
Advanced tools
A React utility library for making API calls using React Query and Axios, providing context-based configuration and custom hooks for seamless integration.
A utility library for simplifying API requests in React applications. Built on top of React Query and Axios, it provides a seamless way to manage API calls and caching with an intuitive context-based setup.
npm install react-api-utils
# or
yarn add react-api-utils
Wrap your application with the ApiHelperProvider
to set up the context and configuration.
import React from 'react';
import { ApiHelperProvider } from 'react-api-utils';
const App = () => (
<ApiHelperProvider baseURL="https://api.example.com">
<YourApp />
</ApiHelperProvider>
);
export default App;
useApiHelper
Leverage the useApiHelper
hook to perform API requests effortlessly.
import { useApiHelper } from 'react-api-utils';
const MyComponent = () => {
const { data, isLoading, isError } = useApiHelper({
url: '/endpoint',
method: 'GET',
queryKey: ['endpoint-data'],
});
if (isLoading) return <p>Loading...</p>;
if (isError) return <p>Something went wrong!</p>;
return <pre>{JSON.stringify(data, null, 2)}</pre>;
};
ApiHelperProvider
Prop | Type | Default | Description |
---|---|---|---|
baseURL | string | undefined | Base URL for all Axios requests. |
axiosConfig | AxiosRequestConfig | {} | Custom Axios configuration. |
queryClientConfig | QueryClientConfig | {} | React Query client configuration. |
useApiHelper
Option | Type | Description |
---|---|---|
url | string | API endpoint to fetch data from. |
method | 'GET' , 'POST' , 'PUT' , 'DELETE' | HTTP method for the request. |
queryKey | Array<string> | Unique key for React Query's cache management. |
Contributions are welcome! Feel free to submit issues or pull requests.
FAQs
A React utility library for making API calls using React Query and Axios, providing context-based configuration and custom hooks for seamless integration.
The npm package react-api-utils receives a total of 1 weekly downloads. As such, react-api-utils popularity was classified as not popular.
We found that react-api-utils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.