
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
@simple-api/react
Advanced tools
Production-grade TanStack Query adapter for simple-api.
@simple-api/react provides a seamless bridge between your API definitions and React components. It automatically generates type-safe hooks for every endpoint, with built-in support for mutations, intelligent query invalidation, and global synchronization.
api.users().get()).invalidates: ['users'] to a mutation to automatically refresh related data across the entire application.isPending, isError, and the improved useMutation API.npm install @simple-api/react @simple-api/core @tanstack/react-query
// api.ts
import { createApi } from "@simple-api/core";
import { createReactAdapter } from "@simple-api/react";
const api = createApi({
baseUrl: "https://api.example.com",
services: {
users: {
get: { method: "GET", path: "/users/:id" },
update: { method: "PATCH", path: "/users/:id" },
},
},
});
export const useApi = createReactAdapter(api);
The React adapter creates a structured hook system that mirrors your API definition.
export const UserProfile = ({ id }) => {
const { users } = useApi();
// The queryKey is automatically managed: ['users', 'get', { id }]
const { data, isLoading, error } = users().get({ params: { id } });
if (isLoading) return <div>Loading...</div>;
if (error) return <div>Error: {error.message}</div>;
return <h1>{data.name}</h1>;
};
The adapter simplifies mutations by handling the execute function and query invalidation automatically.
export const UpdateProfile = () => {
const { users } = useApi();
const { execute, isPending } = users().update({
params: { id: "123" },
invalidates: ["users"], // Automatically refreshes the user list!
});
return (
<button disabled={isPending} onClick={() => execute({ name: "New Name" })}>
{isPending ? "Saving..." : "Save Changes"}
</button>
);
};
The invalidates property is powerful. You can invalidate by service name or by specific query keys.
invalidates: ["users"]: Invalidates every query within the users service.invalidates: ["users.list"]: Refines invalidation to a specific endpoint.Since the adapter is built on @simple-api/core, hooks will throw structured ApiError instances.
const { error } = users().get({ params: { id } });
if (error instanceof ApiError) {
console.log(error.status); // e.g., 401
console.log(error.data); // Server-side error payload
}
You can pass standard TanStack Query options directly to the hooks via the hookOptions property:
users().get({
params: { id },
hookOptions: {
staleTime: 1000 * 60 * 10,
gcTime: 1000 * 60 * 60,
enabled: !!id,
},
});
queryKey manually again.MIT © Elnatan Samuel
FAQs
React TanStack Query adapter for SimpleAPI Engine
The npm package @simple-api/react receives a total of 12 weekly downloads. As such, @simple-api/react popularity was classified as not popular.
We found that @simple-api/react 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.