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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@godsreveal/vercel-bun

v0.2.7

Published

Bun runtime for Vercel serverless functions

Readme

vercel-bun

Bun runtime for Vercel serverless functions

Important

Bun is now an officially supported runtime on Vercel, so I do NOT recommend using this custom Bun runtime unless:

  1. You have critical, unsolvable issues with the official runtime
  2. You want to run your serverless functions with a specific version of Bun

Please reference the Vercel documentation here for more information: https://vercel.com/docs/functions/runtimes/bun

Overview

vercel-bun is a custom Vercel runtime that enables you to run serverless functions using the Bun JavaScript runtime instead of Node.js. This runtime provides improved performance, better TypeScript support, and access to Bun's native APIs.

Features

  • 🚀 High Performance: Uses Bun's fast JavaScript runtime (version 1.2.15 by default)
  • 📦 Native TypeScript: Built-in TypeScript support without additional compilation
  • 🌐 Web Standard APIs: Uses native Request and Response interfaces
  • 🏗️ Framework Agnostic: Works with any framework that supports Bun (Elysia, Hono, etc.)
  • 🔧 Configurable: Customizable Bun version

Usage

1. Configure your vercel.json file

{
  "$schema": "https://openapi.vercel.sh/vercel.json",
  "functions": {
    "api/index.ts": {
      "runtime": "@godsreveal/[email protected]"
    }
  },
  // Optional: use if you want all /api routes to be handled by /api/index.ts
  "rewrites": [{ "source": "/api/(.*)", "destination": "/api/index.ts" }]
}

2. Create a Bun serverless function

Basic Handler (Vanilla)

// api/index.ts
export default function handler(req: Request) {
  return new Response(
    JSON.stringify({ message: `Hello from bun@${Bun.version}` }),
    {
      headers: { "Content-Type": "application/json" },
    }
  );
}

Advanced Handler (with Elysia)

// api/index.ts
import { Elysia, t } from "elysia";

const app = new Elysia({ prefix: "/api" })
  .get("/", () => `Hello from bun@${Bun.version}`)
  .get("/hello", ({ query }) => `Hello ${query.firstName} ${query.lastName}`, {
    query: t.Object({
      firstName: t.String(),
      lastName: t.String(),
    }),
  })
  .post(
    "/users",
    async ({ body }) => {
      // Your logic here
      return { success: true, data: body };
    },
    {
      body: t.Object({
        name: t.String(),
        email: t.String(),
      }),
    }
  );

// Development server (runs locally with `bun run api/index.ts`)
if (process.env.NODE_ENV !== "production") {
  app.listen({ port: 3000 });
  console.log("Server is running on http://localhost:3000");
}

export default app.handle;

3. Deploy to Vercel

Deploy your GitHub repository to Vercel.

Configuration

Environment Variables

| Variable | Description | Default | Example | | ------------- | ------------------------------ | -------- | -------- | | BUN_VERSION | Specify the Bun version to use | 1.2.15 | 1.2.15 |

Examples

See the examples directory for several examples:

  • Vanilla - A comprehensive benchmarking suite comparing Bun and Node.js runtime performance on Vercel serverless functions, including cold start, throughput, concurrency, and payload size tests.

  • Next.js + ElysiaJS - A full-stack Next.js application demonstrating high-performance serverless functions with Elysia REST API, Redis integration, Cloudflare R2 image uploads, and end-to-end type safety using Eden Treaty.

  • Next.js + Hono - A lightweight and fast Next.js application showcasing serverless functions with the Hono web framework, featuring type-safe request validation with Zod and optimized performance for edge computing.

  • grammY - A Telegram bot built with the grammY framework, showcasing how to deploy chatbots as serverless functions using the Bun runtime with webhook support and modular command structure.

Goals

  • [ ] First-class Vercel Integration: Native Bun runtime support in Vercel's platform for both serverless and edge functions.
  • [ ] Next.js Integration: Runtime specification in next.config.js for API routes and React Server Components.