npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

barejs

v0.1.47

Published

High-performance JIT-specialized web framework for Bun

Readme


📊 Benchmarks: Real-World Performance

BareJS leads in complex, real-world scenarios. We measure engine efficiency using a stress test involving 10+ middlewares and deep radix tree routing to ensure performance holds under high concurrency.

| Framework | Latency | Speed | | :--- | :--- | :--- | | BareJS | 1.79 µs | Baseline | | Elysia | 2.44 µs | 1.36x slower | | Hono | 9.86 µs | 5.52x slower |

Last Updated: 2026-01-14 (github action)

[!TIP] **View our Continuous Benchmark Dashboard** for historical data and detailed performance trends.

🚀 Key Features

  • JIT Pipeline Compilation: Routes and middleware chains are flattened into a single function at runtime.
  • Object Pooling: Recycles Context objects via a circular buffer, drastically reducing GC pressure.
  • Internal High-Performance Logger: Zero-overhead logging integrated directly into the JIT engine.
  • Precise Radix Router: v0.1.46 introduces optimized segment matching for deep-nested paths.
  • Mechanical Sympathy: Intentionally designed to align with V8's optimization and Bun's I/O.

🛠️ Installation

bun add barejs

The "Bare" Minimum

import { BareJS, type Context } from 'barejs';

const app = new BareJS();

// Enable Internal Logger
app.useLog(true);

app.get('/', (ctx: Context) => ctx.json({ hello: "world" }));

app.listen(3000);

📘 Comprehensive Guide

1. ⚡ Standardized Response & Chaining

BareJS v0.1.46 provides a fluent API for building responses.

app.get('/api/v1/health', (ctx: Context) => {
  // Chainable status and standardized send helper
  return ctx.status(200).send("System is healthy", { 
    uptime: process.uptime() 
  });
});

// Output: { "status": "success", "msg": "System is healthy", "uptime": ... }

2. 🛡️ Security & Authentication (Dual-API)

import { bareAuth, createToken, Password, Hash, type Context } from 'barejs';

const SECRET = process.env.JWT_SECRET || "your-secret";

app.post('/register', async (ctx: Context) => {
  const body = await ctx.jsonBody();
  
  // High-performance Argon2id Hashing (64MB default)
  const hash = await Password.make(body.password); 
  
  // Verify with ease
  const isValid = await Hash.verify(body.password, hash);
  
  if (isValid) {
    const token = await createToken({ id: 1 }, SECRET);
    return { token };
  }
});

// Protect routes with built-in JWT middleware
app.get('/me', bareAuth(SECRET), (ctx: Context) => {
  return ctx.send("Authenticated", { user: ctx.get('user') });
});

3. ✅ Data Validation (3 Styles)

BareJS is the only engine that offers JIT-optimized validation paths.

import { typebox, zod, native, t, type Context } from 'barejs';
import { z } from 'zod';

// Style A: TypeBox (JIT Optimized - Recommended)
// Pre-compiled validation to outperform competitors by 55%
const Schema = t.Object({ name: t.String() });
app.post('/user', typebox(Schema), (ctx) => ctx.json(ctx.body));

// Style B: Zod (Industry Standard)
const ZodSchema = z.object({ age: z.number() });
app.post('/age', zod(ZodSchema), (ctx) => ctx.json(ctx.body));

// Style C: Native (Zero Dependency - Simple Checks)
app.post('/native', native({ properties: { id: { type: 'number' } } }), (ctx) => ctx.json(ctx.body));

4. 🔌 Essential Middleware

import { cors, staticFile } from 'barejs';

app.use(cors());
app.use(staticFile("public"));

🧠 Context API

| Method / Property | Description | | --- | --- | | ctx.req | Raw incoming Bun Request object. | | ctx.params | Route parameters (e.g., :id). | | ctx.jsonBody() | [Async] Parses and caches JSON body for performance. | | ctx.status(code) | Sets the HTTP status code (Chainable). | | ctx.send(msg, ext) | Returns a standardized JSON response. | | ctx.json(data) | Returns an optimized raw JSON response. | | ctx.setHeader(k, v) | Sets a response header. | | ctx.set / ctx.get | Manual storage within the request lifecycle. |


⚙️ Performance Tuning

| OS Variable / File | Default | Description | | --- | --- | --- | | bare.config.ts | - | Centralized config for Port and Hash algorithms. | | BARE_POOL_SIZE | 1024 | Context pool size (Must be Power of 2). | | NODE_ENV | development | Set to production to enable peak JIT optimizations. |


Maintained by xarhang | License: MIT