spoosh-reactlisted
Install: claude install-skill spooshdev/skills
# Spoosh React
Spoosh is a type-safe API toolkit with a composable plugin architecture for TypeScript. This skill covers the React integration including hooks API, plugins, and component patterns.
## Setup
```bash
pnpm add @spoosh/core @spoosh/react
```
```typescript
import { Spoosh } from "@spoosh/core";
import { create } from "@spoosh/react";
type ApiSchema = {
users: {
GET: { data: User[] };
POST: { data: User; body: CreateUserBody };
};
"users/:id": {
GET: { data: User };
DELETE: { data: void };
};
};
const spoosh = new Spoosh<ApiSchema, Error>("/api").use([
cachePlugin(),
retryPlugin(),
]);
export const { useRead, useWrite, usePages, useQueue, useSSE } = create(spoosh);
```
## createClient (Lightweight)
For simple use cases without hooks or plugins:
```typescript
import { createClient } from "@spoosh/core";
const api = createClient<ApiSchema, Error>("/api");
const { data, error } = await api("users").GET();
const { data: user } = await api("users/:id").GET({ params: { id: "123" } });
await api("users").POST({ body: { name: "John" } });
```
## Hooks API
### useRead
Fetch data with automatic caching and state management.
```typescript
const { data, loading, error, trigger } = useRead((api) => api("users").GET(), {
staleTime: 30000,
enabled: true,
});
```
**Returns:** `data`, `loading`, `fetching`, `error`, `trigger()`, `abort()`, `meta`
**Options:** `enabled`, `tags`, `staleTime`, `retry`, `pollingInterval`, `refetch`, `deb