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

@naticha/bunbase

v0.0.2

Published

TypeScript-native Backend-as-a-Service built on Bun — REST API, auth, realtime, storage, and admin UI from a Drizzle schema

Readme

bunbase

bunbase is a TypeScript-native Backend-as-a-Service built on Bun. Point it at a Drizzle ORM schema and it generates a full REST API, auth, file storage, realtime WebSockets, and an admin UI — with zero configuration.

Quick start

// server.ts
import { createServer, defineRules, defineConfig } from "bunbase";
import { sqliteTable, text } from "drizzle-orm/sqlite-core";

const tasks = sqliteTable("tasks", {
  id: text("id").primaryKey().$defaultFn(() => Bun.randomUUIDv7()),
  title: text("title").notNull(),
  done: text("done").notNull().default("false"),
});

const rules = defineRules({
  tasks: {
    list: () => true,
    get: () => true,
    create: ({ auth }) => auth !== null,
    update: ({ auth }) => auth !== null,
    delete: ({ auth }) => auth?.role === "admin",
  },
});

createServer({ schema: { tasks }, rules }).listen(3000);
bun server.ts
# REST API at http://localhost:3000/api/tasks
# Admin UI  at http://localhost:3000/_admin

New project

bunx bunbase init my-app
cd my-app
bun install
bun dev

bunbase init walks you through an interactive setup (schema, auth, OAuth providers) and scaffolds a ready-to-run project. Pass -y to accept all defaults non-interactively.

Installation (existing project)

bun add bunbase

Core concepts

| Concept | Description | |---|---| | Schema | Standard Drizzle tables — bunbase generates REST endpoints for each one | | Rules | Per-table, per-operation functions that return true / false / SQL — deny-by-default | | Client | createBunBaseClient({ url, schema }) — typed proxy for all CRUD, auth, files, and realtime | | Realtime | config: { realtime: { enabled: true } } — WebSocket subscriptions via client.realtime.subscribe(table, cb) | | Storage | File upload/download per record, local or S3 | | Admin UI | Built-in management UI at /_admin |

Running the example

The examples/task-manager directory is a full running app demonstrating:

  • Server-side filters + cursor pagination
  • expand: ["assignee"] relational queries
  • API key creation and management
  • Realtime live task feed
bun install
bun run --cwd examples/task-manager dev

Patterns reference

See docs/examples.ts for compile-checked code snippets covering every pattern: filters, pagination, expand, rules, hooks, jobs, OAuth, and more.

Fetching all records with listAll()

listAll() returns every matching record in a single HTTP request — no cursor loop, no pagination. Internally it passes limit=-1 to the server, which queries without a LIMIT clause and returns hasMore: false.

const allTasks = await client.api.tasks.listAll({ filter: { done: false } });

With TanStack Query:

const { data = [] } = useQuery(api.tasks.listAll.queryOptions({ sort: "createdAt" }));

Filter, sort, and expand params work the same as list(). For very large tables where you want to process records incrementally, use list() with manual cursor handling instead.

Frontend (SPA) serving

BunBase can serve your React/Vue/Svelte SPA alongside the API in a single process. Enable it with the frontend config option.

Static import required. Bun's HTML bundler processes imports at module load time. Dynamic import() does not work for HTML files — the import must be a static top-level statement.

// server.ts
import indexHtml from "./frontend/index.html";   // static import — required
import { createServer, defineConfig } from "bunbase";

createServer({
  schema,
  rules,
  config: defineConfig({
    frontend: { html: indexHtml },
  }),
}).listen(3000);

With frontend.html set, BunBase adds /* as a SPA catch-all in Bun.serve(). All API namespaces (/api/*, /auth/*, /_admin/api/*, /files/*, /realtime) remain more specific and continue to reach BunBase's handlers — Bun's router is specificity-based, not order-based.

Run with bun --hot server.ts for hot module replacement during development. Tailwind, TSX, and CSS bundling are handled natively by Bun — no Vite needed.

License

MIT