Bun & Butter logo

What deserves a place in the next pan.

Some things keep showing up in project after project: a helper, a pattern, a small snippet worth keeping around. Bun & Butter is where we collect those pieces, clean them up, and make them easy to reuse.

main.ts
1import { addMoreButter } from "@bun-and-butter";
2
3const awesomeProject = addMoreButter("super productive");
4run(awesomeProject);

Runtime

Bun and TypeScript-only

Everything here is shaped for a Bun-native workflow, from reusable catalog entries to patterns and snippets that stay close to real TypeScript code.

Use case

Code, ideas, and snippets

We collect the helpers, API shapes, and small copy-pasteable pieces that keep proving useful across more than one project.

Approach

Readable building blocks

Everything stays intentionally small, easy to inspect, and careful about adding complexity or pulling in more external code than it needs.

Growing catalog

The fridge-door staples.

Bun & Butter starts small on purpose and grows one dependable catalog entry at a time. The goal is a catalog of reusable standards and helpers that stays generic, easy to adopt, and worth reaching for in more than one codebase.

error catalog artwork
error
domain-error
typed-error

@bun-and-butter/error

A tiny foundation for strongly typed domain errors in TypeScript. Define consistent error classes with machine-readable codes, default messages, optional causes, and structured metadata. It works well for application domains that need predictable error handling, clear diagnostics, and a small, reusable error surface.

factory catalog artwork
factory
cache

@bun-and-butter/factory

A small factory helper for lazily building and caching shared or isolated values with a consistent API for synchronous and asynchronous builders.

migration catalog artwork
migration
database

@bun-and-butter/migration

A small migration runner for ordered up/down migrations with pluggable stores, useful for schema changes, data backfills, file migrations, and other application upgrade steps.

shutdown catalog artwork
shutdown
graceful-shutdown
cleanup

@bun-and-butter/shutdown

A small helper for graceful shutdowns that coordinates ordered shutdown handlers, parallel cleanup handlers, timeout enforcement, and cancellation via AbortSignal behind a simple shared API.

sqlite catalog artwork
bun
sqlite
sql

@bun-and-butter/sqlite

A Bun-first SQLite helper for creating and configuring Bun SQL connections with sensible defaults, configurable PRAGMAs, typed options, lifecycle hooks, and clear configuration errors.

Patterns

Patterns worth reusing.

Some of the most valuable things in a codebase are not libraries, but reusable ways of modeling data, shaping APIs, and keeping system boundaries honest. This section collects those patterns and explains why they are worth carrying into the next project.

A Better Enum Alternative

Enum ergonomics without enum limitations

For APIs that should feel crisp, named, and hard to misuse, this pattern gives you the clarity of enums plus the flexibility to model richer variants when simple members stop being enough.

Branded Types / Newtype Pattern

Turn raw strings into domain values

Use branded types to model things like IDs, usernames, and display names as distinct domain values. The result is stricter boundaries, clearer APIs, and fewer invalid values leaking through the system.

Branded Better Enum Type

Enum values as real domain types

Combine enum-like ergonomics with branded types when a closed set of values should also become a trusted domain value with parsing, guards, and a safer default.

More to come

More patterns are on the way

This section is still growing. More of the small architectural decisions and API patterns that keep proving useful will land here over time.

Snippets

Ready to copy. Soon.

This section will collect ready-to-copy snippets for the small pieces of code that keep showing up across projects.

More to come

Ready-to-paste helpers and small drop-in snippets will land here next.

Why Bun & Butter exists

We got tired of rebuilding the same useful building blocks in every new project.

At work and in personal projects, the same code, patterns, and small snippets kept showing up again. Bun & Butter is where we turn those repeated bits into reusable pieces we can document, keep in shape, and actually reach for again.

Solve repeated work once

If a helper, pattern, or small snippet keeps showing up in new codebases, we would rather shape it once and keep reusing it than paste slightly different versions around.

Keep it small and legible

Everything here should stay readable. You can inspect the code, understand the tradeoffs, and adopt only the parts that belong in your project.

Keep distribution simple

Bun & Butter is Bun and TypeScript-only, so Git stays the simplest distribution path. The repository remains the source of truth, and Bun can install directly from it.

Ready to browse

Pick the pieces you need, and leave the rest in the pan.

Start with the catalog when you want reusable code. Start with patterns when you want a reusable idea. Snippets are for the small ready-to-paste pieces in between. Bun & Butter is built so you can take exactly what helps and leave the rest behind.