
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
use-multi-fetch-lite
Advanced tools
A lightweight React hook for handling multiple API calls with built-in protection against infinite re-fetching and React StrictMode issues.
Perfect for when React Query feels like overkill.
npm install use-multi-fetch-lite
Or with yarn:
yarn add use-multi-fetch-lite
use-multi-fetch-lite is fully compatible with React 18 and StrictMode.
The hook safely handles React's development double-invocation by:
import { useMultiFetch } from "use-multi-fetch-lite";
const fetchUsers = () =>
fetch("https://jsonplaceholder.typicode.com/users").then(r => r.json());
const fetchPosts = () =>
fetch("https://jsonplaceholder.typicode.com/posts").then(r => r.json());
export default function App() {
const { data, loading, error } = useMultiFetch({
users: fetchUsers,
posts: fetchPosts,
});
if (loading) return <p>Loading...</p>;
if (error) return <p>Error: {error.message}</p>;
return (
<div>
<h2>Users: {data.users?.length ?? 0}</h2>
<h2>Users: {data.users?.length ?? 0}</h2>
<pre>{JSON.stringify(data, null, 2)}</pre>
</div>
);
}
import { useMultiFetch } from "use-multi-fetch-lite";
type User = {
id: number;
name: string;
email: string;
};
type Post = {
id: number;
title: string;
body: string;
};
const fetchUsers = async (): Promise<User[]> => {
const res = await fetch("https://jsonplaceholder.typicode.com/users");
return res.json();
};
const fetchPosts = async (): Promise<Post[]> => {
const res = await fetch("https://jsonplaceholder.typicode.com/posts");
return res.json();
};
export default function App() {
const { data, loading, error } = useMultiFetch({
users: fetchUsers,
posts: fetchPosts,
});
// data is fully typed as { users: User[]; posts: Post[] }
if (loading) return <p>Loading...</p>;
if (error) return <p>Error: {error.message}</p>;
return (
<div>
{data.users.map(user => (
<div key={user.id}>{user.name}</div>
))}
</div>
);
}
const { data, loading, error } = useMultiFetch(
{
users: fetchUsers,
posts: fetchPosts,
comments: fetchComments,
},
{
retry: 2,
onSuccess: (data) => {
console.log("✅ All requests succeeded:", data);
},
onError: (error) => {
console.error("❌ Request failed:", error);
},
}
);
| Option | Type | Default | Description |
|---|---|---|---|
retry | number | 0 | Number of retry attempts per request |
onSuccess | (data) => void | — | Callback fired when all requests succeed |
onError | (error) => void | — | Callback fired when any request fails |
The hook returns an object with the following properties:
{
data: Record<string, any> // `data` is always an object. Before the first successful fetch, it will be an empty object (`{}`).
loading: boolean; // True while any request is pending
error: Error | null; // First error encountered, if any
}
The data object keys match your fetch function keys:
// Input:
useMultiFetch({
users: fetchUsers,
posts: fetchPosts,
})
// Output data:
{
users: User[],
posts: Post[]
}
Great for:
Consider alternatives when:
MIT
Found a bug? Open an issue
Have a feature request? Start a discussion
FAQs
Lightweight React hook for handling multiple API calls
We found that use-multi-fetch-lite demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.