Skip to main content

A lightweight, flexible routing library for JavaScript.

This package works with Node.js, Deno, Bun
This package works with Node.js
This package works with Deno
This package works with Bun
JSR Score
76%
Published
2 weeks ago (0.3.2)

Pathless

A lightweight, flexible routing library for JavaScript. Designed for simplicity, Pathless provides an intuitive API for handling HTTP requests and organizing your routes.

// CJS
const pathless = require("pathless");
// ESM
import pathless from "pathless";

const app = pathless();

app.get("/", (req, res) => res.send("Hello world!"));

app.listen(3000, () => console.log("Server is listening on port 3000"));

Features

  • Flexible Routing: Easily define routes for various HTTP methods, including support for dynamic and wildcard routes.
  • Middleware Support: Add global or route-specific middleware to handle tasks like authentication, logging, and more.
  • Modular Routers: Organize your application into reusable routers for better scalability and maintainability.

Quick Start

$ npm i pathless@latest
$ yarn add pathless@latest
$ pnpm i pathless@latest

Comparison with other frameworks

Stat Framework 1% 2.5% 50% 97.5% Avg Stdev Min
Req/Sec Pathless 27,215 27,215 32,447 33,983 31,973.82 1,827.87 27,214
Express 6,451 6,451 8,279 8,495 8,023.82 609.14 6,451
Hono 28,079 28,079 34,399 35,327 33,888.73 1,882.39 28,065

(from frolleks/nodejs-http-framework-benchmark)

Documentation

Visit the repository's Wiki.

License

MIT License

Examples

Example 1

import pathless from "pathless";

const app = pathless();

app.get("/", (req, res) => res.send("Hello world!"));

app.listen(3000, () => console.log("Server is listening on port 3000"));

Add Package

deno add jsr:@pathless/pathless

Import symbol

import * as mod from "@pathless/pathless";

---- OR ----

Import directly with a jsr specifier

import * as mod from "jsr:@pathless/pathless";

Add Package

npx jsr add @pathless/pathless

Import symbol

import * as mod from "@pathless/pathless";

Add Package

yarn dlx jsr add @pathless/pathless

Import symbol

import * as mod from "@pathless/pathless";

Add Package

pnpm dlx jsr add @pathless/pathless

Import symbol

import * as mod from "@pathless/pathless";

Add Package

bunx jsr add @pathless/pathless

Import symbol

import * as mod from "@pathless/pathless";