Last active
October 13, 2025 15:05
-
-
Save up1/1f937ce8e6b1dd1b1cd3f2c6c08ecec8 to your computer and use it in GitHub Desktop.
Hello Bun 1.3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $bun upgrade | |
| Bun v1.3.0 is out! You're on v1.2.4 | |
| [6.15s] Upgraded. | |
| Welcome to Bun v1.3.0! | |
| What's new in Bun v1.3.0: | |
| https://bun.sh/blog/release-notes/bun-v1.3.0 | |
| Report any bugs: | |
| https://github.com/oven-sh/bun/issues | |
| Commit log: | |
| https://github.com/oven-sh/bun/compare/bun-v1.2.4...bun-v1.3.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $bun init | |
| ✓ Select a project template: React | |
| ✓ Select a React template: Default (blank) | |
| + CLAUDE.md | |
| + .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc -> CLAUDE.md | |
| + bunfig.toml | |
| + package.json | |
| + tsconfig.json | |
| + bun-env.d.ts | |
| + README.md | |
| + .gitignore | |
| + src/index.tsx | |
| + src/App.tsx | |
| + src/index.html | |
| + src/index.css | |
| + src/APITester.tsx | |
| + src/react.svg | |
| + src/frontend.tsx | |
| + src/logo.svg | |
| bun install v1.3.0 (b0a6feca) | |
| + @types/[email protected] | |
| + @types/[email protected] | |
| + @types/[email protected] | |
| + [email protected] | |
| + [email protected] | |
| 10 packages installed [1.52s] | |
| ✨ New project configured! | |
| Development - full-stack dev server with hot reload | |
| bun dev | |
| Static Site - build optimized assets to disk (no backend) | |
| bun run build | |
| Production - serve a full-stack production build | |
| bun start | |
| Happy bunning! 🐇 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 1. Build | |
| $bun build --compile ./src/index.tsx --outfile demo01 | |
| [29ms] bundle 19 modules | |
| [105ms] compile demo01 | |
| # 2. Start server จาก Single-file executable | |
| $./demo01 | |
| 🚀 Server running at http://localhost:3000/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { serve } from "bun"; | |
| import index from "./index.html"; | |
| const server = serve({ | |
| routes: { | |
| // Serve index.html for all unmatched routes. | |
| "/*": index, | |
| "/api/hello": { | |
| async GET(req) { | |
| return Response.json({ | |
| message: "Hello, world!", | |
| method: "GET", | |
| }); | |
| }, | |
| async PUT(req) { | |
| return Response.json({ | |
| message: "Hello, world!", | |
| method: "PUT", | |
| }); | |
| }, | |
| }, | |
| "/api/hello/:name": async req => { | |
| const name = req.params.name; | |
| return Response.json({ | |
| message: `Hello, ${name}!`, | |
| }); | |
| }, | |
| }, | |
| development: process.env.NODE_ENV !== "production" && { | |
| // Enable browser hot reloading in development | |
| hmr: true, | |
| // Echo console logs from the browser to the server | |
| console: true, | |
| }, | |
| }); | |
| console.log(`🚀 Server running at ${server.url}`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment