Spoosh
A type-safe API client with a powerful plugin system
import { Spoosh } from "@spoosh/core";
import { createReactSpoosh } from "@spoosh/react";
import { cachePlugin } from "@spoosh/plugin-cache";
import { deduplicationPlugin } from "@spoosh/plugin-deduplication";
import { invalidationPlugin } from "@spoosh/plugin-invalidation";
const spoosh = new Spoosh<ApiSchema, Error>("/api").use([
cachePlugin({ staleTime: 5000 }),
deduplicationPlugin(), // Prevent duplicate requests
invalidationPlugin(), // Auto-refresh queries after mutations
]);
export const { useRead, useWrite } = createReactSpoosh(spoosh);Choose Your Framework
Spoosh provides first-class support for multiple frontend frameworks
Why Spoosh?
Type-Safe
Define your API schema once, get full TypeScript autocomplete and type checking everywhere.
Plugin System
Extend functionality with plugins for caching, retry, polling, optimistic updates, and more.
Smart Cache Invalidation
Automatic tag-based cache invalidation after mutations. Your queries stay fresh without manual refetching.
Your API is Your Code
API paths become TypeScript code. Define "posts/:id" once, call it as api("posts/:id").GET(). Zero runtime overhead, pure compile-time magic.
Framework Adapters
First-class support for React and Angular with automatic type inference from your server routes.
OpenAPI Conversion
Bidirectional conversion between TypeScript schemas and OpenAPI 3.0/3.1 specs. Import existing APIs or export for documentation.
Simple & Powerful
Fetch data with automatic caching, loading states, and error handling
function UserList() {
const { data, loading, error } = useRead(
(api) => api("users").GET()
);
if (loading) return <Spinner />;
if (error) return <Error message={error.message} />;
return (
<ul>
{data?.map((user) => (
<li key={user.id}>{user.name}</li>
))}
</ul>
);
}Ready to get started?
Install Spoosh and build type-safe API clients in minutes.
npm install @spoosh/core @spoosh/react