@vielzeug/courier
v2.3.1
Published
HTTP client with caching, request deduplication, typed mutations, SSE streaming, and interceptors
Downloads
1,219
Readme
@vielzeug/courier
Type-safe HTTP, query cache, mutations, SSE, and streaming built on native fetch.
Package: @vielzeug/courier · Category: Http
Key exports: createCourier, CourierError, CourierHttpError, CourierNetworkError, CourierTimeoutError, CourierAbortError
When to use: Typed HTTP, caching, mutations, SSE, and readable streaming with a shared interceptor pipeline.
Related: @vielzeug/spell · @vielzeug/ripple · @vielzeug/vault
@vielzeug/courier is part of Vielzeug and ships as a zero-dependency TypeScript package with ESM+CJS output.
Installation
pnpm add @vielzeug/courier
npm install @vielzeug/courier
yarn add @vielzeug/courierQuick Start
import { createCourier } from '@vielzeug/courier';
type NewUser = { name: string };
type User = { id: number; name: string };
const client = createCourier({
baseUrl: 'https://api.example.com',
query: { staleTime: 5_000 },
});
const userKey = ['users', 1] as const;
await client.queries.fetch({
fetch: ({ signal }) => client.get<User>('/users/{id}', { params: { id: 1 }, signal }),
key: userKey,
staleTime: 5_000,
});
const nextUser = await client.mutate({
request: ({ signal }) => client.post<User>('/users', { body: { name: 'Alice' }, signal }),
invalidateKeys: [['users']],
});Documentation
Full docs: https://vielzeug.dev/courier/
License
MIT © Helmuth Saatkamp — part of the Vielzeug monorepo.
