setu.js
v1.4.5
Published
A lightweight HTTP client for Node.js and the browser, with smart adapter selection.
Maintainers
Readme
Setu.js – Modern HTTP Client for JavaScript
Setu.js is a minimal, powerful, and highly customizable HTTP client built for modern JavaScript applications. With built-in support for retries, timeouts, streaming, and smart defaults, Setu.js is ideal for both frontend and backend environments.
Framework Agnostic - Works with React, Vue, Angular, Next.js, Express, and virtually any JavaScript/TypeScript framework! See FRAMEWORK_COMPATIBILITY.md for details.
✨ Features
- 📦 Lightweight and zero-config
- 🔁 Built-in retry mechanism with exponential backoff
- ⏱️ Timeout support for requests
- 📡 Streaming and upload/download progress
- 🧠 Adapter-based engine (browser + Node.js)
- 💎 Clean API inspired by Axios and modern fetch
- ⚡ C++ Optimization Layer - Optional native addon for 2-5x performance boost
🚀 Installation
npm install setu.jsor
yarn add setu.jsNote: The C++ optimization module is optional. If you don't have a C++ compiler installed, Setu.js will automatically use JavaScript implementations. The package works perfectly either way!
📦 Basic Usage
import setu from 'setu.js';
const response = await setu.get('/api/users');
console.log(response.data);await setu.post('/api/upload', {
body: formData,
onUploadProgress: (progress) => {
console.log(`${progress.loaded}/${progress.total}`);
}
});🛠 Core API
setu.get(url, options)
- Make a
GETrequest - Accepts optional retries, timeout, and headers
setu.post(url, options)
- POST request with JSON or multipart form support
- Supports
onUploadProgress
setu.put(url, options) / setu.delete()
- Standard REST methods supported
Request Options
{
headers?: Record<string, string>;
body?: any;
retries?: number; // Default: 0
retryDelay?: number; // Default: 1000ms
timeout?: number; // Default: 0 (no timeout)
onUploadProgress?: (progress) => void;
onDownloadProgress?: (progress) => void;
}♻ Retry Example
const response = await setu.get('/api/reliable-data', {
retries: 3,
retryDelay: 1000
});⏱ Timeout Example
await setu.get('/api/slow-endpoint', {
timeout: 3000 // fail after 3s
});⚡ C++ Optimization Example
Enable native C++ optimizations for 2-5x performance improvements:
await setu.get('/api/data', {
optimized: true // Use C++ optimized functions
});Note: The native module is optional and builds automatically. Setu.js falls back to JavaScript if unavailable. See OPTIMIZATION.md for details.
🎯 Framework Support
Setu.js works with any JavaScript/TypeScript framework:
Frontend
✅ React • Vue.js • Angular • Svelte • Next.js • Nuxt.js • Remix • Solid.js
Backend
✅ Express • Fastify • Koa • NestJS • Hapi • FastAPI (via Node.js)
Runtimes
✅ Node.js • Deno • Bun • Cloudflare Workers • AWS Lambda • Vercel Edge
See FRAMEWORK_COMPATIBILITY.md for detailed examples and integration guides.
🔗 Learn More & Full Documentation
➡️ Full docs with examples, advanced usage and integration guides: https://setujs.dev
❤️ Contributing
We welcome contributions! Open issues, suggest features, or improve the docs.
git clone https://github.com/chaitu426/setu.js.git
cd setu.js
npm install
npm run dev📄 License
MIT © Chaitanya Abhade
Built with ❤️ for the JavaScript community.
