universal-client
v0.1.2
Published
Universal client for web applications
Maintainers
Readme
Universal Client
A flexible and extensible universal client for web applications supporting multiple transport protocols (HTTP, WebSocket, Server-Sent Events) inspired by @ngrx/signals syntax.
Features
- 🔌 Multiple transport protocols support (HTTP, WebSocket, SSE)
- 🎣 Hooks system
- 🛠️ Extensible through features
- 🔧 Configurable through delegates
- 📦 Tree-shakeable
- 🦾 Fully typed
Installation
npm install universal-clientAlso available via
yarn,pnpm,bun, and JSR (deno add @kevinbonnoron/universal-client).
Quick Start
import { universalClient, withDelegate, withMethods } from 'universal-client';
const client = universalClient(
// Can use axios, fetch or better-fetch as implementation
withDelegate({ type: 'http', impl: 'axios', baseURL: 'https://jsonplaceholder.typicode.com' }),
withMethods(({ delegate }) => ({
getUser: (id: string) => delegate.get(`/users/${id}`),
})),
);
const user = await client.getUser('1');
console.log(user);Documentation
Full documentation is available at kevinbonnoron.github.io/universal-client.
- Getting Started
- Basic Usage - HTTP requests, CRUD operations, error handling
- Interceptors - Transform requests/responses, add auth
- WebSocket - Real-time communication
- Server-Sent Events - Real-time updates
- Advanced Features - Telemetry, environments, hooks, offline support
