When building modern web applications, serving static assets efficiently across multiple JavaScript runtimes can be surprisingly frustrating. Every runtime handles streams, headers, and file system access slightly differently.
To solve this, I built @rabbx/sirv ā an ultra-fast, zero-dependency, zero-copy streaming static file middleware designed to run seamlessly everywhere.
What is @rabbx/sirv?
@rabbx/sirv is a lightweight (~32.5KB gzipped) middleware built from the ground up for universal compatibility. Whether your application lives on Bun, Deno, Node.js, or Cloudflare Workers, @rabbx/sirv provides consistent, high-performance static asset delivery out of the box.
Core Features
- Run-Anywhere Versatility: Write once, deploy anywhere across all major modern JavaScript runtimes.
- Zero Dependencies: Keeps your bundle clean, secure, and lightning-fast.
- Zero-Copy Streaming: Optimized for maximum throughput and minimal memory overhead.
- Modular Plugin System: Easily hook into the asset lifecycle using composable setHeaders and transform hooks. Quick Example Getting started takes just a few lines:
import { sirv } from '@rabbx/sirv';
// Initialize the middleware with your public directory
const serve = sirv('./public', {
setHeaders: (res, path) => {
if (path.endsWith('.js')) {
res.setHeader('Cache-Control', 'public, max-age=31536000');
}
}
});
Try It Out
- NPM: npm i @rabbx/sirv (v1.0.0)
- Explore & Simulate: Check out the live API sync and test it in the interactive simulator on the project interface. Iād love to hear your thoughts, feedback, or benchmarks if you test it out in your projects! Let's chat in the comments below. š docs
Top comments (0)