Project Bun is an experiment exploring a minimal Bun app that uses core Bun APIs and as few dependencies as possible.
It includes:
- A vanilla Bun HTTP server that handles requests, including:
- form posts
- streaming React from the server using the
renderToReadableStream
API - a websocket server
- serving a client-side bundle using
Bun.build
that hydrates the server-rendered React
- A basic example using a counter to increment and decrement a counter stored in global state
- A basic example using server-rendered react that lets you create tasks via traditional form posts and store them in a SQLite database using Bun's native SQLite driver
- A basic chat app that hydrates React on the client, connects to the Bun websocket server and allows a user to send messages
- Watchs and reloads the dev server using Bun watch
Bun has a lot of interesting APIs that are surprisingly capable and fun to build with. The only dependencies used are React and React DOM.
Obligatory Disclaimer: this was purely for fun, is not production ready, and should be used for reference only.
To install dependencies:
bun install
To run:
bun migrate src/db/migrations/2024-10-04-tasks.sql # migrate the tiny sqlite database
bun dev
This project was created using bun init
in bun v1.1.29. Bun is a fast all-in-one JavaScript runtime.