ワンクリックで
bun
Default to using Bun instead of Node.js for all JavaScript/TypeScript operations including running files, testing, building, and package management.
メニュー
Default to using Bun instead of Node.js for all JavaScript/TypeScript operations including running files, testing, building, and package management.
| name | bun |
| description | Default to using Bun instead of Node.js for all JavaScript/TypeScript operations including running files, testing, building, and package management. |
Default to using Bun instead of Node.js for all JavaScript/TypeScript operations.
bun <file> instead of node <file> or ts-node <file>bun test instead of jest or vitestbun build <file.html|file.ts|file.css> instead of webpack or esbuildbun install instead of npm install or yarn install or pnpm installbun run <script> instead of npm run <script> or yarn run <script> or pnpm run <script>Prefer Bun's built-in APIs over external packages:
Bun.serve() supports WebSockets, HTTPS, and routes. Don't use express.bun:sqlite for SQLite. Don't use better-sqlite3.Bun.redis for Redis. Don't use ioredis.Bun.sql for Postgres. Don't use pg or postgres.js.WebSocket is built-in. Don't use ws.Bun.file over node:fs's readFile/writeFileBun.$ instead of execa.Use bun test to run tests.
import { test, expect } from "bun:test";
test("hello world", () => {
expect(1).toBe(1);
});
Use HTML imports with Bun.serve(). Don't use vite. HTML imports fully support React, CSS, Tailwind.
import index from "./index.html"
Bun.serve({
routes: {
"/": index,
"/api/users/:id": {
GET: (req) => {
return new Response(JSON.stringify({ id: req.params.id }));
},
},
},
// optional websocket support
websocket: {
open: (ws) => {
ws.send("Hello, world!");
},
message: (ws, message) => {
ws.send(message);
},
close: (ws) => {
// handle close
}
},
development: {
hmr: true,
console: true,
}
})
HTML 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.
<html>
<body>
<h1>Hello, world!</h1>
<script type="module" src="./frontend.tsx"></script>
</body>
</html>
import React from "react";
// import .css files directly and it works
import './index.css';
import { createRoot } from "react-dom/client";
const root = createRoot(document.body);
export default function Frontend() {
return <h1>Hello, world!</h1>;
}
root.render(<Frontend />);
bun --hot ./index.ts
For more information, read the Bun API docs in node_modules/bun-types/docs/**.md.
Assist with Mojolicious web framework development using documentation search, browsing, and testing requests without starting a server.
React development best practices and patterns, including modern data fetching with React 19.
Assist with Hono web framework development using the hono CLI for documentation search, browsing, and testing requests without starting a server.