2description: Use Bun instead of Node.js, npm, pnpm, or vite.
3globs: "*.ts, *.tsx, *.html, *.css, *.js, *.jsx, package.json"
7Default to using Bun instead of Node.js.
9- Use `bun <file>` instead of `node <file>` or `ts-node <file>`
10- Use `bun test` instead of `jest` or `vitest`
11- Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild`
12- Use `bun install` instead of `npm install` or `yarn install` or `pnpm install`
13- Use `bun run <script>` instead of `npm run <script>` or `yarn run <script>` or `pnpm run <script>`
14- Bun automatically loads .env, so don't use dotenv.
18- `Bun.serve()` supports WebSockets, HTTPS, and routes. Don't use `express`.
19- `bun:sqlite` for SQLite. Don't use `better-sqlite3`.
20- `Bun.redis` for Redis. Don't use `ioredis`.
21- `Bun.sql` for Postgres. Don't use `pg` or `postgres.js`.
22- `WebSocket` is built-in. Don't use `ws`.
23- Prefer `Bun.file` over `node:fs`'s readFile/writeFile
24- Bun.$`ls` instead of execa.
28Use `bun test` to run tests.
31import { test, expect } from "bun:test";
33test("hello world", () => {
40Use HTML imports with `Bun.serve()`. Don't use `vite`. HTML imports fully support React, CSS, Tailwind.
45import index from "./index.html"
52 return new Response(JSON.stringify({ id: req.params.id }));
56 // optional websocket support
59 ws.send("Hello, world!");
61 message: (ws, message) => {
75HTML files can import .tsx, .jsx or .js files directly and Bun's bundler will transpile & bundle automatically. `<link>` tags can point to stylesheets and Bun's CSS bundler will bundle.
80 <h1>Hello, world!</h1>
81 <script type="module" src="./frontend.tsx"></script>
86With the following `frontend.tsx`:
89import React from "react";
91// import .css files directly and it works
94import { createRoot } from "react-dom/client";
96const root = createRoot(document.body);
98export default function Frontend() {
99 return <h1>Hello, world!</h1>;
102root.render(<Frontend />);
111For more information, read the Bun API docs in `node_modules/bun-types/docs/**.md`.
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list