Meet Xanout: A Tiny, Lightweight Router Built on Web Standards
Building modern web applications often means working with routing, middleware, request handling, and response management. While there are many excellent routing libraries available, sometimes you just need something simple, lightweight, and flexible.
That’s where Xanout comes in.
Xanout is a tiny, lightweight router built around the native Web-standard Request and Response APIs. It provides a simple yet powerful way to handle HTTP requests without introducing unnecessary complexity.
Whether you’re building an API, a backend service, or a lightweight server application, Xanout aims to keep things straightforward.
🌐 Website: https://xanout.devnax.com
📦 npm: https://www.npmjs.com/package/xanout
📖 Documentation: https://xanout.devnax.com/docs
Why Xanout?
Modern JavaScript runtimes increasingly support Web-standard APIs. Instead of relying entirely on runtime-specific request and response objects, Xanout embraces these native APIs.
This makes it easier to write code that works across different JavaScript environments while keeping your routing logic clean and predictable.
Key Features
Here are some of the things that make Xanout useful:
- Lightweight: Minimal footprint with just one dependency.
- Web Standards: Built around native
Request,Response, andHeadersAPIs. - Middleware Support: Flexible middleware architecture with
next()support. - Sub-routers: Organize your application by mounting routers with path prefixes.
- Request Context: Access request-scoped context from anywhere in your application.
- Cookie Management: Built-in cookie management and serialization.
- Static File Serving: Serve static assets with caching support.
- Framework Adapters: Integrate with Express, Fastify, Koa, Hono, and more.
- Multi-runtime Support: Run on Node.js, Bun, Deno, and Cloudflare Workers (
nodejs_compat).
Getting Started
Getting started with Xanout is straightforward.
Get Naxrul Ahmed’s stories in your inbox
Join Medium for free to get updates from this writer.
First, install the package:
npm install xanoutYour First Router
Let’s create a simple router and handle a few HTTP requests.
import { Router } from "xanout";const route = Router();// Middleware
route.use((next) => {
console.log("Request received");
return next();
});// Home route
route.get("/", () => {
return new Response("Hello World");
});// Dynamic route
route.get("/users/:id", () => {
const { params } = route.context(); return Response.json({
id: params.id,
});
});// Handle requests
const response = await route.fetch(
new Request("http://localhost/users/42")
);
That’s it! You now have a router with middleware support, a basic route, and a dynamic route parameter.
Built for Multiple Runtimes
One of the main ideas behind Xanout is portability.
Since it uses standard Web APIs, you can use it across multiple JavaScript runtimes:
- Node.js
- Bun
- Deno
- Cloudflare Workers (
nodejs_compat)
You don’t have to tie your routing logic to a single runtime.
Explore More
This is just a quick introduction to Xanout. There’s much more to explore, including middleware, sub-routers, cookies, static file serving, framework adapters, and advanced request handling.
Check out the official documentation to learn more:
Explore Xanout Documentation →
Final Thoughts
I built Xanout with a simple goal: make HTTP routing lightweight, flexible, and aligned with modern Web standards.
If you’re looking for a minimal router that works across multiple JavaScript runtimes, give Xanout a try.
I’d love to hear your feedback and see what you build with it!
GitHub / npm: https://www.npmjs.com/package/xanout
Website: https://xanout.devnax.com
Documentation: https://xanout.devnax.com/docs
Happy coding! 🚀





