bun-types 1.3.2-canary.20251105T140650 → 1.3.2-canary.20251106T140813

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (308) hide show
  1. package/docs/README.md +28 -0
  2. package/package.json +1 -1
  3. package/docs/api/binary-data.md +0 -1038
  4. package/docs/api/cc.md +0 -197
  5. package/docs/api/color.md +0 -262
  6. package/docs/api/console.md +0 -57
  7. package/docs/api/cookie.md +0 -449
  8. package/docs/api/dns.md +0 -110
  9. package/docs/api/fetch.md +0 -463
  10. package/docs/api/ffi.md +0 -557
  11. package/docs/api/file-io.md +0 -366
  12. package/docs/api/file-system-router.md +0 -112
  13. package/docs/api/file.md +0 -19
  14. package/docs/api/glob.md +0 -178
  15. package/docs/api/globals.md +0 -387
  16. package/docs/api/hashing.md +0 -319
  17. package/docs/api/html-rewriter.md +0 -334
  18. package/docs/api/http.md +0 -1408
  19. package/docs/api/import-meta.md +0 -69
  20. package/docs/api/node-api.md +0 -14
  21. package/docs/api/redis.md +0 -597
  22. package/docs/api/s3.md +0 -850
  23. package/docs/api/secrets.md +0 -319
  24. package/docs/api/semver.md +0 -52
  25. package/docs/api/spawn.md +0 -582
  26. package/docs/api/sql.md +0 -1374
  27. package/docs/api/sqlite.md +0 -694
  28. package/docs/api/streams.md +0 -230
  29. package/docs/api/tcp.md +0 -221
  30. package/docs/api/transpiler.md +0 -276
  31. package/docs/api/udp.md +0 -123
  32. package/docs/api/utils.md +0 -891
  33. package/docs/api/websockets.md +0 -573
  34. package/docs/api/workers.md +0 -322
  35. package/docs/api/yaml.md +0 -668
  36. package/docs/benchmarks.md +0 -120
  37. package/docs/bun-flavored-toml.md +0 -42
  38. package/docs/bundler/css.md +0 -1028
  39. package/docs/bundler/css_modules.md +0 -145
  40. package/docs/bundler/executables.md +0 -626
  41. package/docs/bundler/fullstack.md +0 -418
  42. package/docs/bundler/hmr.md +0 -234
  43. package/docs/bundler/html.md +0 -349
  44. package/docs/bundler/index.md +0 -1735
  45. package/docs/bundler/intro.md +0 -75
  46. package/docs/bundler/loaders.md +0 -410
  47. package/docs/bundler/macros.md +0 -329
  48. package/docs/bundler/plugins.md +0 -449
  49. package/docs/bundler/vs-esbuild.md +0 -1127
  50. package/docs/cli/add.md +0 -173
  51. package/docs/cli/bun-completions.md +0 -3
  52. package/docs/cli/bun-create.md +0 -338
  53. package/docs/cli/bun-install.md +0 -349
  54. package/docs/cli/bun-upgrade.md +0 -39
  55. package/docs/cli/bunx.md +0 -89
  56. package/docs/cli/filter.md +0 -90
  57. package/docs/cli/info.md +0 -65
  58. package/docs/cli/init.md +0 -85
  59. package/docs/cli/install.md +0 -344
  60. package/docs/cli/link.md +0 -40
  61. package/docs/cli/outdated.md +0 -90
  62. package/docs/cli/patch-commit.md +0 -11
  63. package/docs/cli/pm.md +0 -285
  64. package/docs/cli/publish.md +0 -120
  65. package/docs/cli/remove.md +0 -7
  66. package/docs/cli/run.md +0 -261
  67. package/docs/cli/test.md +0 -397
  68. package/docs/cli/unlink.md +0 -9
  69. package/docs/cli/update.md +0 -129
  70. package/docs/cli/why.md +0 -67
  71. package/docs/contributing/upgrading-webkit.md +0 -57
  72. package/docs/ecosystem/elysia.md +0 -24
  73. package/docs/ecosystem/express.md +0 -37
  74. package/docs/ecosystem/hono.md +0 -18
  75. package/docs/ecosystem/react.md +0 -65
  76. package/docs/ecosystem/stric.md +0 -38
  77. package/docs/guides/binary/arraybuffer-to-array.md +0 -27
  78. package/docs/guides/binary/arraybuffer-to-blob.md +0 -24
  79. package/docs/guides/binary/arraybuffer-to-buffer.md +0 -25
  80. package/docs/guides/binary/arraybuffer-to-string.md +0 -15
  81. package/docs/guides/binary/arraybuffer-to-typedarray.md +0 -39
  82. package/docs/guides/binary/blob-to-arraybuffer.md +0 -14
  83. package/docs/guides/binary/blob-to-dataview.md +0 -14
  84. package/docs/guides/binary/blob-to-stream.md +0 -14
  85. package/docs/guides/binary/blob-to-string.md +0 -15
  86. package/docs/guides/binary/blob-to-typedarray.md +0 -14
  87. package/docs/guides/binary/buffer-to-arraybuffer.md +0 -14
  88. package/docs/guides/binary/buffer-to-blob.md +0 -14
  89. package/docs/guides/binary/buffer-to-readablestream.md +0 -41
  90. package/docs/guides/binary/buffer-to-string.md +0 -25
  91. package/docs/guides/binary/buffer-to-typedarray.md +0 -14
  92. package/docs/guides/binary/dataview-to-string.md +0 -15
  93. package/docs/guides/binary/typedarray-to-arraybuffer.md +0 -25
  94. package/docs/guides/binary/typedarray-to-blob.md +0 -16
  95. package/docs/guides/binary/typedarray-to-buffer.md +0 -14
  96. package/docs/guides/binary/typedarray-to-dataview.md +0 -14
  97. package/docs/guides/binary/typedarray-to-readablestream.md +0 -41
  98. package/docs/guides/binary/typedarray-to-string.md +0 -16
  99. package/docs/guides/deployment/railway.md +0 -157
  100. package/docs/guides/ecosystem/astro.md +0 -72
  101. package/docs/guides/ecosystem/discordjs.md +0 -77
  102. package/docs/guides/ecosystem/docker.md +0 -140
  103. package/docs/guides/ecosystem/drizzle.md +0 -185
  104. package/docs/guides/ecosystem/edgedb.md +0 -228
  105. package/docs/guides/ecosystem/elysia.md +0 -31
  106. package/docs/guides/ecosystem/express.md +0 -40
  107. package/docs/guides/ecosystem/hono.md +0 -39
  108. package/docs/guides/ecosystem/mongoose.md +0 -87
  109. package/docs/guides/ecosystem/neon-drizzle.md +0 -220
  110. package/docs/guides/ecosystem/neon-serverless-postgres.md +0 -55
  111. package/docs/guides/ecosystem/nextjs.md +0 -49
  112. package/docs/guides/ecosystem/nuxt.md +0 -56
  113. package/docs/guides/ecosystem/pm2.md +0 -57
  114. package/docs/guides/ecosystem/prisma.md +0 -141
  115. package/docs/guides/ecosystem/qwik.md +0 -107
  116. package/docs/guides/ecosystem/react.md +0 -50
  117. package/docs/guides/ecosystem/remix.md +0 -78
  118. package/docs/guides/ecosystem/render.md +0 -79
  119. package/docs/guides/ecosystem/sentry.md +0 -52
  120. package/docs/guides/ecosystem/solidstart.md +0 -58
  121. package/docs/guides/ecosystem/ssr-react.md +0 -51
  122. package/docs/guides/ecosystem/stric.md +0 -55
  123. package/docs/guides/ecosystem/sveltekit.md +0 -125
  124. package/docs/guides/ecosystem/systemd.md +0 -113
  125. package/docs/guides/ecosystem/vite.md +0 -71
  126. package/docs/guides/html-rewriter/extract-links.md +0 -68
  127. package/docs/guides/html-rewriter/extract-social-meta.md +0 -93
  128. package/docs/guides/http/cluster.md +0 -66
  129. package/docs/guides/http/fetch-unix.md +0 -33
  130. package/docs/guides/http/fetch.md +0 -24
  131. package/docs/guides/http/file-uploads.md +0 -94
  132. package/docs/guides/http/hot.md +0 -26
  133. package/docs/guides/http/proxy.md +0 -24
  134. package/docs/guides/http/server.md +0 -46
  135. package/docs/guides/http/simple.md +0 -18
  136. package/docs/guides/http/stream-file.md +0 -48
  137. package/docs/guides/http/stream-iterator.md +0 -47
  138. package/docs/guides/http/stream-node-streams-in-bun.md +0 -20
  139. package/docs/guides/http/tls.md +0 -30
  140. package/docs/guides/install/add-dev.md +0 -26
  141. package/docs/guides/install/add-git.md +0 -36
  142. package/docs/guides/install/add-optional.md +0 -25
  143. package/docs/guides/install/add-peer.md +0 -43
  144. package/docs/guides/install/add-tarball.md +0 -33
  145. package/docs/guides/install/add.md +0 -42
  146. package/docs/guides/install/azure-artifacts.md +0 -73
  147. package/docs/guides/install/cicd.md +0 -41
  148. package/docs/guides/install/custom-registry.md +0 -30
  149. package/docs/guides/install/from-npm-install-to-bun-install.md +0 -214
  150. package/docs/guides/install/git-diff-bun-lockfile.md +0 -44
  151. package/docs/guides/install/jfrog-artifactory.md +0 -28
  152. package/docs/guides/install/npm-alias.md +0 -23
  153. package/docs/guides/install/registry-scope.md +0 -38
  154. package/docs/guides/install/trusted.md +0 -46
  155. package/docs/guides/install/workspaces.md +0 -70
  156. package/docs/guides/install/yarnlock.md +0 -44
  157. package/docs/guides/process/argv.md +0 -58
  158. package/docs/guides/process/ctrl-c.md +0 -16
  159. package/docs/guides/process/ipc.md +0 -66
  160. package/docs/guides/process/nanoseconds.md +0 -13
  161. package/docs/guides/process/os-signals.md +0 -39
  162. package/docs/guides/process/spawn-stderr.md +0 -31
  163. package/docs/guides/process/spawn-stdout.md +0 -26
  164. package/docs/guides/process/spawn.md +0 -41
  165. package/docs/guides/process/stdin.md +0 -54
  166. package/docs/guides/read-file/arraybuffer.md +0 -28
  167. package/docs/guides/read-file/buffer.md +0 -19
  168. package/docs/guides/read-file/exists.md +0 -16
  169. package/docs/guides/read-file/json.md +0 -17
  170. package/docs/guides/read-file/mime.md +0 -20
  171. package/docs/guides/read-file/stream.md +0 -26
  172. package/docs/guides/read-file/string.md +0 -22
  173. package/docs/guides/read-file/uint8array.md +0 -21
  174. package/docs/guides/read-file/watch.md +0 -68
  175. package/docs/guides/runtime/build-time-constants.md +0 -293
  176. package/docs/guides/runtime/cicd.md +0 -43
  177. package/docs/guides/runtime/codesign-macos-executable.md +0 -56
  178. package/docs/guides/runtime/define-constant.md +0 -145
  179. package/docs/guides/runtime/delete-directory.md +0 -37
  180. package/docs/guides/runtime/delete-file.md +0 -19
  181. package/docs/guides/runtime/heap-snapshot.md +0 -26
  182. package/docs/guides/runtime/import-html.md +0 -15
  183. package/docs/guides/runtime/import-json.md +0 -44
  184. package/docs/guides/runtime/import-toml.md +0 -30
  185. package/docs/guides/runtime/import-yaml.md +0 -102
  186. package/docs/guides/runtime/read-env.md +0 -32
  187. package/docs/guides/runtime/set-env.md +0 -47
  188. package/docs/guides/runtime/shell.md +0 -40
  189. package/docs/guides/runtime/timezone.md +0 -35
  190. package/docs/guides/runtime/tsconfig-paths.md +0 -29
  191. package/docs/guides/runtime/typescript.md +0 -49
  192. package/docs/guides/runtime/vscode-debugger.md +0 -47
  193. package/docs/guides/runtime/web-debugger.md +0 -82
  194. package/docs/guides/streams/node-readable-to-arraybuffer.md +0 -11
  195. package/docs/guides/streams/node-readable-to-blob.md +0 -11
  196. package/docs/guides/streams/node-readable-to-json.md +0 -12
  197. package/docs/guides/streams/node-readable-to-string.md +0 -12
  198. package/docs/guides/streams/node-readable-to-uint8array.md +0 -11
  199. package/docs/guides/streams/to-array.md +0 -14
  200. package/docs/guides/streams/to-arraybuffer.md +0 -14
  201. package/docs/guides/streams/to-blob.md +0 -14
  202. package/docs/guides/streams/to-buffer.md +0 -15
  203. package/docs/guides/streams/to-json.md +0 -14
  204. package/docs/guides/streams/to-string.md +0 -14
  205. package/docs/guides/streams/to-typedarray.md +0 -22
  206. package/docs/guides/test/bail.md +0 -22
  207. package/docs/guides/test/coverage-threshold.md +0 -60
  208. package/docs/guides/test/coverage.md +0 -44
  209. package/docs/guides/test/happy-dom.md +0 -68
  210. package/docs/guides/test/migrate-from-jest.md +0 -143
  211. package/docs/guides/test/mock-clock.md +0 -48
  212. package/docs/guides/test/mock-functions.md +0 -68
  213. package/docs/guides/test/rerun-each.md +0 -14
  214. package/docs/guides/test/run-tests.md +0 -111
  215. package/docs/guides/test/skip-tests.md +0 -39
  216. package/docs/guides/test/snapshot.md +0 -95
  217. package/docs/guides/test/spy-on.md +0 -46
  218. package/docs/guides/test/svelte-test.md +0 -120
  219. package/docs/guides/test/testing-library.md +0 -92
  220. package/docs/guides/test/timeout.md +0 -15
  221. package/docs/guides/test/todo-tests.md +0 -67
  222. package/docs/guides/test/update-snapshots.md +0 -46
  223. package/docs/guides/test/watch-mode.md +0 -19
  224. package/docs/guides/util/base64.md +0 -15
  225. package/docs/guides/util/deep-equals.md +0 -39
  226. package/docs/guides/util/deflate.md +0 -18
  227. package/docs/guides/util/detect-bun.md +0 -23
  228. package/docs/guides/util/entrypoint.md +0 -17
  229. package/docs/guides/util/escape-html.md +0 -22
  230. package/docs/guides/util/file-url-to-path.md +0 -14
  231. package/docs/guides/util/gzip.md +0 -18
  232. package/docs/guides/util/hash-a-password.md +0 -54
  233. package/docs/guides/util/import-meta-dir.md +0 -13
  234. package/docs/guides/util/import-meta-file.md +0 -13
  235. package/docs/guides/util/import-meta-path.md +0 -13
  236. package/docs/guides/util/javascript-uuid.md +0 -23
  237. package/docs/guides/util/main.md +0 -32
  238. package/docs/guides/util/path-to-file-url.md +0 -14
  239. package/docs/guides/util/sleep.md +0 -22
  240. package/docs/guides/util/version.md +0 -21
  241. package/docs/guides/util/which-path-to-executable-bin.md +0 -15
  242. package/docs/guides/websocket/compression.md +0 -31
  243. package/docs/guides/websocket/context.md +0 -77
  244. package/docs/guides/websocket/pubsub.md +0 -41
  245. package/docs/guides/websocket/simple.md +0 -33
  246. package/docs/guides/write-file/append.md +0 -52
  247. package/docs/guides/write-file/basic.md +0 -44
  248. package/docs/guides/write-file/blob.md +0 -28
  249. package/docs/guides/write-file/cat.md +0 -17
  250. package/docs/guides/write-file/file-cp.md +0 -16
  251. package/docs/guides/write-file/filesink.md +0 -52
  252. package/docs/guides/write-file/response.md +0 -17
  253. package/docs/guides/write-file/stdout.md +0 -21
  254. package/docs/guides/write-file/stream.md +0 -17
  255. package/docs/guides/write-file/unlink.md +0 -16
  256. package/docs/index.md +0 -77
  257. package/docs/install/audit.md +0 -57
  258. package/docs/install/cache.md +0 -59
  259. package/docs/install/catalogs.md +0 -298
  260. package/docs/install/index.md +0 -248
  261. package/docs/install/isolated.md +0 -197
  262. package/docs/install/lifecycle.md +0 -46
  263. package/docs/install/lockfile.md +0 -58
  264. package/docs/install/npmrc.md +0 -105
  265. package/docs/install/overrides.md +0 -73
  266. package/docs/install/patch.md +0 -59
  267. package/docs/install/registries.md +0 -30
  268. package/docs/install/security-scanner-api.md +0 -81
  269. package/docs/install/workspaces.md +0 -114
  270. package/docs/installation.md +0 -327
  271. package/docs/project/asan.md +0 -124
  272. package/docs/project/benchmarking.md +0 -203
  273. package/docs/project/bindgen.md +0 -225
  274. package/docs/project/building-windows.md +0 -162
  275. package/docs/project/contributing.md +0 -347
  276. package/docs/project/internals/build-process-for-ci.md +0 -75
  277. package/docs/project/licensing.md +0 -73
  278. package/docs/project/roadmap.md +0 -87
  279. package/docs/quickstart.md +0 -157
  280. package/docs/runtime/autoimport.md +0 -94
  281. package/docs/runtime/bun-apis.md +0 -207
  282. package/docs/runtime/bunfig.md +0 -772
  283. package/docs/runtime/debugger.md +0 -325
  284. package/docs/runtime/env.md +0 -253
  285. package/docs/runtime/hot.md +0 -145
  286. package/docs/runtime/index.md +0 -312
  287. package/docs/runtime/jsx.md +0 -385
  288. package/docs/runtime/loaders.md +0 -130
  289. package/docs/runtime/modules.md +0 -320
  290. package/docs/runtime/nodejs-apis.md +0 -463
  291. package/docs/runtime/plugins.md +0 -561
  292. package/docs/runtime/shell.md +0 -605
  293. package/docs/runtime/typescript.md +0 -139
  294. package/docs/runtime/web-apis.md +0 -128
  295. package/docs/test/configuration.md +0 -154
  296. package/docs/test/coverage.md +0 -142
  297. package/docs/test/discovery.md +0 -85
  298. package/docs/test/dom.md +0 -75
  299. package/docs/test/examples/concurrent-test-glob.md +0 -132
  300. package/docs/test/hot.md +0 -15
  301. package/docs/test/lifecycle.md +0 -81
  302. package/docs/test/mocks.md +0 -313
  303. package/docs/test/reporters.md +0 -117
  304. package/docs/test/runtime-behavior.md +0 -95
  305. package/docs/test/snapshots.md +0 -68
  306. package/docs/test/time.md +0 -126
  307. package/docs/test/writing.md +0 -825
  308. package/docs/typescript.md +0 -53
@@ -1,49 +0,0 @@
1
- ---
2
- name: Build an app with Next.js and Bun
3
- ---
4
-
5
- Initialize a Next.js app with `create-next-app`. This will scaffold a new Next.js project and automatically install dependencies.
6
-
7
- ```sh
8
- $ bun create next-app
9
- ✔ What is your project named? … my-app
10
- ✔ Would you like to use TypeScript with this project? … No / Yes
11
- ✔ Would you like to use ESLint with this project? … No / Yes
12
- ✔ Would you like to use Tailwind CSS? ... No / Yes
13
- ✔ Would you like to use `src/` directory with this project? … No / Yes
14
- ✔ Would you like to use App Router? (recommended) ... No / Yes
15
- ✔ What import alias would you like configured? … @/*
16
- Creating a new Next.js app in /path/to/my-app.
17
- ```
18
-
19
- ---
20
-
21
- You can specify a starter template using the `--example` flag.
22
-
23
- ```sh
24
- $ bun create next-app --example with-supabase
25
- ✔ What is your project named? … my-app
26
- ...
27
- ```
28
-
29
- ---
30
-
31
- To start the dev server with Bun, run `bun --bun run dev` from the project root.
32
-
33
- ```sh
34
- $ cd my-app
35
- $ bun --bun run dev
36
- ```
37
-
38
- ---
39
-
40
- To run the dev server with Node.js instead, omit `--bun`.
41
-
42
- ```sh
43
- $ cd my-app
44
- $ bun run dev
45
- ```
46
-
47
- ---
48
-
49
- Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. Any changes you make to `(pages/app)/index.tsx` will be hot-reloaded in the browser.
@@ -1,56 +0,0 @@
1
- ---
2
- name: Build an app with Nuxt and Bun
3
- ---
4
-
5
- Bun supports [Nuxt](https://nuxt.com) out of the box. Initialize a Nuxt app with official `nuxi` CLI.
6
-
7
- ```sh
8
- $ bunx nuxi init my-nuxt-app
9
- ✔ Which package manager would you like to use?
10
- bun
11
- ◐ Installing dependencies...
12
- bun install v1.3.2-canary.20251105T140650 (16b4bf34)
13
- + @nuxt/devtools@0.8.2
14
- + nuxt@3.7.0
15
- 785 packages installed [2.67s]
16
- ✔ Installation completed.
17
- ✔ Types generated in .nuxt
18
- ✨ Nuxt project has been created with the v3 template. Next steps:
19
- › cd my-nuxt-app
20
- › Start development server with bun run dev
21
- ```
22
-
23
- ---
24
-
25
- To start the dev server, run `bun --bun run dev` from the project root. This will execute the `nuxt dev` command (as defined in the `"dev"` script in `package.json`).
26
-
27
- {% callout %}
28
- The `nuxt` CLI uses Node.js by default; passing the `--bun` flag forces the dev server to use the Bun runtime instead.
29
- {% /callout %}
30
-
31
- ```
32
- $ cd my-nuxt-app
33
- $ bun --bun run dev
34
- $ nuxt dev
35
- Nuxi 3.6.5
36
- Nuxt 3.6.5 with Nitro 2.5.2
37
- > Local: http://localhost:3000/
38
- > Network: http://192.168.0.21:3000/
39
- > Network: http://[fd8a:d31d:481c:4883:1c64:3d90:9f83:d8a2]:3000/
40
-
41
- ✔ Nuxt DevTools is enabled v0.8.0 (experimental)
42
- ℹ Vite client warmed up in 547ms
43
- ✔ Nitro built in 244 ms
44
- ```
45
-
46
- ---
47
-
48
- Once the dev server spins up, open [http://localhost:3000](http://localhost:3000) to see the app. The app will render Nuxt's built-in `NuxtWelcome` template component.
49
-
50
- To start developing your app, replace `<NuxtWelcome />` in `app.vue` with your own UI.
51
-
52
- {% image src="https://github.com/oven-sh/bun/assets/3084745/2c683ecc-3298-4bb0-b8c0-cf4cfaea1daa" caption="Demo Nuxt app running on localhost" /%}
53
-
54
- ---
55
-
56
- Refer to the [Nuxt website](https://nuxt.com/docs) for complete documentation.
@@ -1,57 +0,0 @@
1
- ---
2
- name: Run Bun as a daemon with PM2
3
- ---
4
-
5
- [PM2](https://pm2.keymetrics.io/) is a popular process manager that manages and runs your applications as daemons (background processes).
6
-
7
- It offers features like process monitoring, automatic restarts, and easy scaling. Using a process manager is common when deploying a Bun application on a cloud-hosted virtual private server (VPS), as it:
8
-
9
- - Keeps your Node.js application running continuously.
10
- - Ensure high availability and reliability of your application.
11
- - Monitor and manage multiple processes with ease.
12
- - Simplify the deployment process.
13
-
14
- ---
15
-
16
- You can use PM2 with Bun in two ways: as a CLI option or in a configuration file.
17
-
18
- ### With `--interpreter`
19
-
20
- ---
21
-
22
- To start your application with PM2 and Bun as the interpreter, open your terminal and run the following command:
23
-
24
- ```bash
25
- pm2 start --interpreter ~/.bun/bin/bun index.ts
26
- ```
27
-
28
- ---
29
-
30
- ### With a configuration file
31
-
32
- ---
33
-
34
- Alternatively, you can create a PM2 configuration file. Create a file named `pm2.config.js` in your project directory and add the following content.
35
-
36
- ```javascript
37
- module.exports = {
38
- name: "app", // Name of your application
39
- script: "index.ts", // Entry point of your application
40
- interpreter: "bun", // Bun interpreter
41
- env: {
42
- PATH: `${process.env.HOME}/.bun/bin:${process.env.PATH}`, // Add "~/.bun/bin/bun" to PATH
43
- },
44
- };
45
- ```
46
-
47
- ---
48
-
49
- After saving the file, you can start your application with PM2
50
-
51
- ```bash
52
- pm2 start pm2.config.js
53
- ```
54
-
55
- ---
56
-
57
- That’s it! Your JavaScript/TypeScript web server is now running as a daemon with PM2 using Bun as the interpreter.
@@ -1,141 +0,0 @@
1
- ---
2
- name: Use Prisma with Bun
3
- ---
4
-
5
- {% callout %}
6
- **Note** — At the moment Prisma needs Node.js to be installed to run certain generation code. Make sure Node.js is installed in the environment where you're running `bunx prisma` commands.
7
- {% /callout %}
8
-
9
- ---
10
-
11
- Prisma works out of the box with Bun. First, create a directory and initialize it with `bun init`.
12
-
13
- ```bash
14
- $ mkdir prisma-app
15
- $ cd prisma-app
16
- $ bun init
17
- ```
18
-
19
- ---
20
-
21
- Then install the Prisma CLI (`prisma`) and Prisma Client (`@prisma/client`) as dependencies.
22
-
23
- ```bash
24
- $ bun add -d prisma
25
- $ bun add @prisma/client
26
- ```
27
-
28
- ---
29
-
30
- We'll use the Prisma CLI with `bunx` to initialize our schema and migration directory. For simplicity we'll be using an in-memory SQLite database.
31
-
32
- ```bash
33
- $ bunx --bun prisma init --datasource-provider sqlite
34
- ```
35
-
36
- ---
37
-
38
- Open `prisma/schema.prisma` and add a simple `User` model.
39
-
40
- ```prisma-diff#prisma/schema.prisma
41
- generator client {
42
- provider = "prisma-client-js"
43
- output = "../generated/prisma"
44
- }
45
-
46
- datasource db {
47
- provider = "sqlite"
48
- url = env("DATABASE_URL")
49
- }
50
-
51
- + model User {
52
- + id Int @id @default(autoincrement())
53
- + email String @unique
54
- + name String?
55
- + }
56
- ```
57
-
58
- ---
59
-
60
- Then generate and run initial migration.
61
-
62
- This will generate a `.sql` migration file in `prisma/migrations`, create a new SQLite instance, and execute the migration against the new instance.
63
-
64
- ```bash
65
- $ bunx prisma migrate dev --name init
66
- Environment variables loaded from .env
67
- Prisma schema loaded from prisma/schema.prisma
68
- Datasource "db": SQLite database "dev.db" at "file:./dev.db"
69
-
70
- SQLite database dev.db created at file:./dev.db
71
-
72
- Applying migration `20230928182242_init`
73
-
74
- The following migration(s) have been created and applied from new schema changes:
75
-
76
- migrations/
77
- └─ 20230928182242_init/
78
- └─ migration.sql
79
-
80
- Your database is now in sync with your schema.
81
-
82
- ✔ Generated Prisma Client (v6.11.1) to ./generated/prisma in 41ms
83
- ```
84
-
85
- ---
86
-
87
- As indicated in the output, Prisma re-generates our _Prisma client_ whenever we execute a new migration. The client provides a fully typed API for reading and writing from our database. You can manually re-generate the client with the Prisma CLI.
88
-
89
- ```sh
90
- $ bunx prisma generate
91
- ```
92
-
93
- ---
94
-
95
- We can import the generated client from `@prisma/client`.
96
-
97
- ```ts#src/index.ts
98
- import {PrismaClient} from "@prisma/client";
99
- ```
100
-
101
- ---
102
-
103
- Let's write a simple script to create a new user, then count the number of users in the database.
104
-
105
- ```ts#index.ts
106
- import { PrismaClient } from "@prisma/client";
107
-
108
- const prisma = new PrismaClient();
109
-
110
- // create a new user
111
- await prisma.user.create({
112
- data: {
113
- name: "John Dough",
114
- email: `john-${Math.random()}@example.com`,
115
- },
116
- });
117
-
118
- // count the number of users
119
- const count = await prisma.user.count();
120
- console.log(`There are ${count} users in the database.`);
121
- ```
122
-
123
- ---
124
-
125
- Let's run this script with `bun run`. Each time we run it, a new user is created.
126
-
127
- ```bash
128
- $ bun run index.ts
129
- Created john-0.12802932895402364@example.com
130
- There are 1 users in the database.
131
- $ bun run index.ts
132
- Created john-0.8671308799782803@example.com
133
- There are 2 users in the database.
134
- $ bun run index.ts
135
- Created john-0.4465968383115295@example.com
136
- There are 3 users in the database.
137
- ```
138
-
139
- ---
140
-
141
- That's it! Now that you've set up Prisma using Bun, we recommend referring to the [official Prisma docs](https://www.prisma.io/docs/concepts/components/prisma-client) as you continue to develop your application.
@@ -1,107 +0,0 @@
1
- ---
2
- name: Build an app with Qwik and Bun
3
- ---
4
-
5
- Initialize a new Qwik app with `bunx create-qwik`.
6
-
7
- The `create-qwik` package detects when you are using `bunx` and will automatically install dependencies using `bun`.
8
-
9
- ```sh
10
- $ bun create qwik
11
-
12
- ............
13
- .::: :--------:.
14
- .:::: .:-------:.
15
- .:::::. .:-------.
16
- ::::::. .:------.
17
- ::::::. :-----:
18
- ::::::. .:-----.
19
- :::::::. .-----.
20
- ::::::::.. ---:.
21
- .:::::::::. :-:.
22
- ..::::::::::::
23
- ...::::
24
-
25
-
26
- ┌ Let's create a Qwik App ✨ (v1.2.10)
27
-
28
- ◇ Where would you like to create your new project? (Use '.' or './' for current directory)
29
- │ ./my-app
30
-
31
- ● Creating new project in /path/to/my-app ... 🐇
32
-
33
- ◇ Select a starter
34
- │ Basic App
35
-
36
- ◇ Would you like to install bun dependencies?
37
- │ Yes
38
-
39
- ◇ Initialize a new git repository?
40
- │ No
41
-
42
- ◇ Finishing the install. Wanna hear a joke?
43
- │ Yes
44
-
45
- ○ ────────────────────────────────────────────────────────╮
46
- │ │
47
- │ How do you know if there’s an elephant under your bed? │
48
- │ Your head hits the ceiling! │
49
- │ │
50
- ├──────────────────────────────────────────────────────────╯
51
-
52
- ◇ App Created 🐰
53
-
54
- ◇ Installed bun dependencies 📋
55
-
56
- ○ Result ─────────────────────────────────────────────╮
57
- │ │
58
- │ Success! Project created in my-app directory │
59
- │ │
60
- │ Integrations? Add Netlify, Cloudflare, Tailwind... │
61
- │ bun qwik add │
62
- │ │
63
- │ Relevant docs: │
64
- │ https://qwik.builder.io/docs/getting-started/ │
65
- │ │
66
- │ Questions? Start the conversation at: │
67
- │ https://qwik.builder.io/chat │
68
- │ https://twitter.com/QwikDev │
69
- │ │
70
- │ Presentations, Podcasts and Videos: │
71
- │ https://qwik.builder.io/media/ │
72
- │ │
73
- │ Next steps: │
74
- │ cd my-app │
75
- │ bun start │
76
- │ │
77
- │ │
78
- ├──────────────────────────────────────────────────────╯
79
-
80
- └ Happy coding! 🎉
81
-
82
- ```
83
-
84
- ---
85
-
86
- Run `bun run dev` to start the development server.
87
-
88
- ```sh
89
- $ bun run dev
90
- $ vite--mode ssr
91
-
92
- VITE v4.4.7 ready in 1190 ms
93
-
94
- ➜ Local: http://localhost:5173/
95
- ➜ Network: use --host to expose
96
- ➜ press h to show help
97
- ```
98
-
99
- ---
100
-
101
- Open [http://localhost:5173](http://localhost:5173) with your browser to see the result. Qwik will hot-reload your app as you edit your source files.
102
-
103
- {% image src="https://github.com/oven-sh/bun/assets/3084745/ec35f2f7-03dd-4c90-851e-fb4ad150bb28" alt="Qwik screenshot" /%}
104
-
105
- ---
106
-
107
- Refer to the [Qwik docs](https://qwik.builder.io/docs/getting-started/) for complete documentation.
@@ -1,50 +0,0 @@
1
- ---
2
- name: Build a React app with Bun
3
- ---
4
-
5
- Bun supports `.jsx` and `.tsx` files out of the box. React just works with Bun.
6
-
7
- Create a new React app with `bun init --react`. This gives you a template with a simple React app and a simple API server together in one full-stack app.
8
-
9
- ```bash
10
- # Create a new React app
11
- $ bun init --react
12
-
13
- # Run the app in development mode
14
- $ bun dev
15
-
16
- # Build as a static site for production
17
- $ bun run build
18
-
19
- # Run the server in production
20
- $ bun start
21
- ```
22
-
23
- ---
24
-
25
- ### Hot Reloading
26
-
27
- Run `bun dev` to start the app in development mode. This will start the API server and the React app with hot reloading.
28
-
29
- ### Full-Stack App
30
-
31
- Run `bun start` to start the API server and frontend together in one process.
32
-
33
- ### Static Site
34
-
35
- Run `bun run build` to build the app as a static site. This will create a `dist` directory with the built app and all the assets.
36
-
37
- ```
38
- ├── src/
39
- │ ├── index.tsx # Server entry point with API routes
40
- │ ├── frontend.tsx # React app entry point with HMR
41
- │ ├── App.tsx # Main React component
42
- │ ├── APITester.tsx # Component for testing API endpoints
43
- │ ├── index.html # HTML template
44
- │ ├── index.css # Styles
45
- │ └── *.svg # Static assets
46
- ├── package.json # Dependencies and scripts
47
- ├── tsconfig.json # TypeScript configuration
48
- ├── bunfig.toml # Bun configuration
49
- └── bun.lock # Lock file
50
- ```
@@ -1,78 +0,0 @@
1
- ---
2
- name: Build an app with Remix and Bun
3
- ---
4
-
5
- {% callout %}
6
- Currently the Remix development server (`remix dev`) relies on Node.js APIs that Bun does not yet implement. The guide below uses Bun to initialize a project and install dependencies, but it uses Node.js to run the dev server.
7
- {% /callout %}
8
-
9
- ---
10
-
11
- Initialize a Remix app with `create-remix`.
12
-
13
- ```sh
14
- $ bun create remix
15
-
16
- remix v1.19.3 💿 Let's build a better website...
17
-
18
- dir Where should we create your new project?
19
- ./my-app
20
-
21
- ◼ Using basic template See https://remix.run/docs/en/main/guides/templates#templates for more
22
- ✔ Template copied
23
-
24
- git Initialize a new git repository?
25
- Yes
26
-
27
- deps Install dependencies with bun?
28
- Yes
29
-
30
- ✔ Dependencies installed
31
-
32
- ✔ Git initialized
33
-
34
- done That's it!
35
-
36
- Enter your project directory using cd ./my-app
37
- Check out README.md for development and deploy instructions.
38
- ```
39
-
40
- ---
41
-
42
- To start the dev server, run `bun run dev` from the project root. This will start the dev server using the `remix dev` command. Note that Node.js will be used to run the dev server.
43
-
44
- ```sh
45
- $ cd my-app
46
- $ bun run dev
47
- $ remix dev
48
-
49
- 💿 remix dev
50
-
51
- info building...
52
- info built (263ms)
53
- Remix App Server started at http://localhost:3000 (http://172.20.0.143:3000)
54
- ```
55
-
56
- ---
57
-
58
- Open [http://localhost:3000](http://localhost:3000) to see the app. Any changes you make to `app/routes/_index.tsx` will be hot-reloaded in the browser.
59
-
60
- {% image src="https://github.com/oven-sh/bun/assets/3084745/c26f1059-a5d4-4c0b-9a88-d9902472fd77" caption="Remix app running on localhost" /%}
61
-
62
- ---
63
-
64
- To build and start your app, run `bun run build` then `bun run start` from the project root.
65
-
66
- ```sh
67
- $ bun run build
68
- $ remix build
69
- info building... (NODE_ENV=production)
70
- info built (158ms)
71
- $ bun start
72
- $ remix-serve ./build/index.js
73
- [remix-serve] http://localhost:3000 (http://192.168.86.237:3000)
74
- ```
75
-
76
- ---
77
-
78
- Read the [Remix docs](https://remix.run/) for more information on how to build apps with Remix.
@@ -1,79 +0,0 @@
1
- ---
2
- name: Deploy a Bun application on Render
3
- ---
4
-
5
- [Render](https://render.com/) is a cloud platform that lets you flexibly build, deploy, and scale your apps.
6
-
7
- It offers features like auto deploys from GitHub, a global CDN, private networks, automatic HTTPS setup, and managed PostgreSQL and Redis.
8
-
9
- Render supports Bun natively. You can deploy Bun apps as web services, background workers, cron jobs, and more.
10
-
11
- ---
12
-
13
- As an example, let's deploy a simple Express HTTP server to Render.
14
-
15
- ---
16
-
17
- Create a new GitHub repo named `myapp`. Git clone it locally.
18
-
19
- ```sh
20
- $ git clone git@github.com:my-github-username/myapp.git
21
- $ cd myapp
22
- ```
23
-
24
- ---
25
-
26
- Add the Express library.
27
-
28
- ```sh
29
- $ bun add express
30
- ```
31
-
32
- ---
33
-
34
- Define a simple server with Express:
35
-
36
- ```ts#app.ts
37
- import express from "express";
38
-
39
- const app = express();
40
- const port = process.env.PORT || 3001;
41
-
42
- app.get("/", (req, res) => {
43
- res.send("Hello World!");
44
- });
45
-
46
- app.listen(port, () => {
47
- console.log(`Listening on port ${port}...`);
48
- });
49
- ```
50
-
51
- ---
52
-
53
- Commit your changes and push to GitHub.
54
-
55
- ```sh
56
- $ git add app.ts bun.lock package.json
57
- $ git commit -m "Create simple Express app"
58
- $ git push origin main
59
- ```
60
-
61
- ---
62
-
63
- In your [Render Dashboard](https://dashboard.render.com/), click `New` > `Web Service` and connect your `myapp` repo.
64
-
65
- ---
66
-
67
- In the Render UI, provide the following values during web service creation:
68
-
69
- | | |
70
- | ----------------- | ------------- |
71
- | **Runtime** | `Node` |
72
- | **Build Command** | `bun install` |
73
- | **Start Command** | `bun app.ts` |
74
-
75
- ---
76
-
77
- That's it! Your web service will be live at its assigned `onrender.com` URL as soon as the build finishes.
78
-
79
- You can view the [deploy logs](https://docs.render.com/logging#logs-for-an-individual-deploy-or-job) for details. Refer to [Render's documentation](https://docs.render.com/deploys) for a complete overview of deploying on Render.
@@ -1,52 +0,0 @@
1
- ---
2
- name: Add Sentry to a Bun app
3
- ---
4
-
5
- [Sentry](https://sentry.io) is a developer-first error tracking and performance monitoring platform. Sentry has a first-class SDK for Bun, `@sentry/bun`, that instruments your Bun application to automatically collect error and performance data.
6
-
7
- Don't already have an account and Sentry project established? Head over to [sentry.io](https://sentry.io/signup/), then return to this page.
8
-
9
- ---
10
-
11
- To start using Sentry with Bun, first install the Sentry Bun SDK.
12
-
13
- ```sh
14
- $ bun add @sentry/bun
15
- ```
16
-
17
- ---
18
-
19
- Then, initialize the Sentry SDK with your Sentry DSN in your app's entry file. You can find your DSN in your Sentry project settings.
20
-
21
- ```js
22
- import * as Sentry from "@sentry/bun";
23
-
24
- // Ensure to call this before importing any other modules!
25
- Sentry.init({
26
- dsn: "__SENTRY_DSN__",
27
-
28
- // Add Performance Monitoring by setting tracesSampleRate
29
- // We recommend adjusting this value in production
30
- tracesSampleRate: 1.0,
31
- });
32
- ```
33
-
34
- ---
35
-
36
- You can verify that Sentry is working by capturing a test error:
37
-
38
- ```js
39
- setTimeout(() => {
40
- try {
41
- foo();
42
- } catch (e) {
43
- Sentry.captureException(e);
44
- }
45
- }, 99);
46
- ```
47
-
48
- To view and resolve the recorded error, log into [sentry.io](https://sentry.io/) and open your project. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved.
49
-
50
- ---
51
-
52
- To learn more about Sentry and using the Sentry Bun SDK, view the [Sentry documentation](https://docs.sentry.io/platforms/javascript/guides/bun).