bun-types 1.3.2-canary.20251104T140728 → 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 (312) hide show
  1. package/bun.d.ts +4 -4
  2. package/docs/README.md +28 -0
  3. package/globals.d.ts +0 -1
  4. package/overrides.d.ts +45 -15
  5. package/package.json +1 -1
  6. package/test.d.ts +1 -1
  7. package/docs/api/binary-data.md +0 -1038
  8. package/docs/api/cc.md +0 -197
  9. package/docs/api/color.md +0 -262
  10. package/docs/api/console.md +0 -57
  11. package/docs/api/cookie.md +0 -449
  12. package/docs/api/dns.md +0 -110
  13. package/docs/api/fetch.md +0 -463
  14. package/docs/api/ffi.md +0 -557
  15. package/docs/api/file-io.md +0 -366
  16. package/docs/api/file-system-router.md +0 -112
  17. package/docs/api/file.md +0 -19
  18. package/docs/api/glob.md +0 -178
  19. package/docs/api/globals.md +0 -387
  20. package/docs/api/hashing.md +0 -319
  21. package/docs/api/html-rewriter.md +0 -334
  22. package/docs/api/http.md +0 -1408
  23. package/docs/api/import-meta.md +0 -69
  24. package/docs/api/node-api.md +0 -14
  25. package/docs/api/redis.md +0 -597
  26. package/docs/api/s3.md +0 -850
  27. package/docs/api/secrets.md +0 -319
  28. package/docs/api/semver.md +0 -52
  29. package/docs/api/spawn.md +0 -582
  30. package/docs/api/sql.md +0 -1374
  31. package/docs/api/sqlite.md +0 -694
  32. package/docs/api/streams.md +0 -230
  33. package/docs/api/tcp.md +0 -221
  34. package/docs/api/transpiler.md +0 -276
  35. package/docs/api/udp.md +0 -123
  36. package/docs/api/utils.md +0 -891
  37. package/docs/api/websockets.md +0 -573
  38. package/docs/api/workers.md +0 -322
  39. package/docs/api/yaml.md +0 -668
  40. package/docs/benchmarks.md +0 -120
  41. package/docs/bun-flavored-toml.md +0 -42
  42. package/docs/bundler/css.md +0 -1028
  43. package/docs/bundler/css_modules.md +0 -145
  44. package/docs/bundler/executables.md +0 -626
  45. package/docs/bundler/fullstack.md +0 -418
  46. package/docs/bundler/hmr.md +0 -234
  47. package/docs/bundler/html.md +0 -349
  48. package/docs/bundler/index.md +0 -1735
  49. package/docs/bundler/intro.md +0 -75
  50. package/docs/bundler/loaders.md +0 -410
  51. package/docs/bundler/macros.md +0 -329
  52. package/docs/bundler/plugins.md +0 -449
  53. package/docs/bundler/vs-esbuild.md +0 -1127
  54. package/docs/cli/add.md +0 -173
  55. package/docs/cli/bun-completions.md +0 -3
  56. package/docs/cli/bun-create.md +0 -338
  57. package/docs/cli/bun-install.md +0 -349
  58. package/docs/cli/bun-upgrade.md +0 -39
  59. package/docs/cli/bunx.md +0 -89
  60. package/docs/cli/filter.md +0 -90
  61. package/docs/cli/info.md +0 -65
  62. package/docs/cli/init.md +0 -85
  63. package/docs/cli/install.md +0 -344
  64. package/docs/cli/link.md +0 -40
  65. package/docs/cli/outdated.md +0 -90
  66. package/docs/cli/patch-commit.md +0 -11
  67. package/docs/cli/pm.md +0 -285
  68. package/docs/cli/publish.md +0 -120
  69. package/docs/cli/remove.md +0 -7
  70. package/docs/cli/run.md +0 -261
  71. package/docs/cli/test.md +0 -397
  72. package/docs/cli/unlink.md +0 -9
  73. package/docs/cli/update.md +0 -129
  74. package/docs/cli/why.md +0 -67
  75. package/docs/contributing/upgrading-webkit.md +0 -57
  76. package/docs/ecosystem/elysia.md +0 -24
  77. package/docs/ecosystem/express.md +0 -37
  78. package/docs/ecosystem/hono.md +0 -18
  79. package/docs/ecosystem/react.md +0 -65
  80. package/docs/ecosystem/stric.md +0 -38
  81. package/docs/guides/binary/arraybuffer-to-array.md +0 -27
  82. package/docs/guides/binary/arraybuffer-to-blob.md +0 -24
  83. package/docs/guides/binary/arraybuffer-to-buffer.md +0 -25
  84. package/docs/guides/binary/arraybuffer-to-string.md +0 -15
  85. package/docs/guides/binary/arraybuffer-to-typedarray.md +0 -39
  86. package/docs/guides/binary/blob-to-arraybuffer.md +0 -14
  87. package/docs/guides/binary/blob-to-dataview.md +0 -14
  88. package/docs/guides/binary/blob-to-stream.md +0 -14
  89. package/docs/guides/binary/blob-to-string.md +0 -15
  90. package/docs/guides/binary/blob-to-typedarray.md +0 -14
  91. package/docs/guides/binary/buffer-to-arraybuffer.md +0 -14
  92. package/docs/guides/binary/buffer-to-blob.md +0 -14
  93. package/docs/guides/binary/buffer-to-readablestream.md +0 -41
  94. package/docs/guides/binary/buffer-to-string.md +0 -25
  95. package/docs/guides/binary/buffer-to-typedarray.md +0 -14
  96. package/docs/guides/binary/dataview-to-string.md +0 -15
  97. package/docs/guides/binary/typedarray-to-arraybuffer.md +0 -25
  98. package/docs/guides/binary/typedarray-to-blob.md +0 -16
  99. package/docs/guides/binary/typedarray-to-buffer.md +0 -14
  100. package/docs/guides/binary/typedarray-to-dataview.md +0 -14
  101. package/docs/guides/binary/typedarray-to-readablestream.md +0 -41
  102. package/docs/guides/binary/typedarray-to-string.md +0 -16
  103. package/docs/guides/deployment/railway.md +0 -157
  104. package/docs/guides/ecosystem/astro.md +0 -72
  105. package/docs/guides/ecosystem/discordjs.md +0 -77
  106. package/docs/guides/ecosystem/docker.md +0 -140
  107. package/docs/guides/ecosystem/drizzle.md +0 -185
  108. package/docs/guides/ecosystem/edgedb.md +0 -228
  109. package/docs/guides/ecosystem/elysia.md +0 -31
  110. package/docs/guides/ecosystem/express.md +0 -40
  111. package/docs/guides/ecosystem/hono.md +0 -39
  112. package/docs/guides/ecosystem/mongoose.md +0 -87
  113. package/docs/guides/ecosystem/neon-drizzle.md +0 -220
  114. package/docs/guides/ecosystem/neon-serverless-postgres.md +0 -55
  115. package/docs/guides/ecosystem/nextjs.md +0 -49
  116. package/docs/guides/ecosystem/nuxt.md +0 -56
  117. package/docs/guides/ecosystem/pm2.md +0 -57
  118. package/docs/guides/ecosystem/prisma.md +0 -141
  119. package/docs/guides/ecosystem/qwik.md +0 -107
  120. package/docs/guides/ecosystem/react.md +0 -50
  121. package/docs/guides/ecosystem/remix.md +0 -78
  122. package/docs/guides/ecosystem/render.md +0 -79
  123. package/docs/guides/ecosystem/sentry.md +0 -52
  124. package/docs/guides/ecosystem/solidstart.md +0 -58
  125. package/docs/guides/ecosystem/ssr-react.md +0 -51
  126. package/docs/guides/ecosystem/stric.md +0 -55
  127. package/docs/guides/ecosystem/sveltekit.md +0 -125
  128. package/docs/guides/ecosystem/systemd.md +0 -113
  129. package/docs/guides/ecosystem/vite.md +0 -71
  130. package/docs/guides/html-rewriter/extract-links.md +0 -68
  131. package/docs/guides/html-rewriter/extract-social-meta.md +0 -93
  132. package/docs/guides/http/cluster.md +0 -66
  133. package/docs/guides/http/fetch-unix.md +0 -33
  134. package/docs/guides/http/fetch.md +0 -24
  135. package/docs/guides/http/file-uploads.md +0 -94
  136. package/docs/guides/http/hot.md +0 -26
  137. package/docs/guides/http/proxy.md +0 -24
  138. package/docs/guides/http/server.md +0 -46
  139. package/docs/guides/http/simple.md +0 -18
  140. package/docs/guides/http/stream-file.md +0 -48
  141. package/docs/guides/http/stream-iterator.md +0 -47
  142. package/docs/guides/http/stream-node-streams-in-bun.md +0 -20
  143. package/docs/guides/http/tls.md +0 -30
  144. package/docs/guides/install/add-dev.md +0 -26
  145. package/docs/guides/install/add-git.md +0 -36
  146. package/docs/guides/install/add-optional.md +0 -25
  147. package/docs/guides/install/add-peer.md +0 -43
  148. package/docs/guides/install/add-tarball.md +0 -33
  149. package/docs/guides/install/add.md +0 -42
  150. package/docs/guides/install/azure-artifacts.md +0 -73
  151. package/docs/guides/install/cicd.md +0 -41
  152. package/docs/guides/install/custom-registry.md +0 -30
  153. package/docs/guides/install/from-npm-install-to-bun-install.md +0 -214
  154. package/docs/guides/install/git-diff-bun-lockfile.md +0 -44
  155. package/docs/guides/install/jfrog-artifactory.md +0 -28
  156. package/docs/guides/install/npm-alias.md +0 -23
  157. package/docs/guides/install/registry-scope.md +0 -38
  158. package/docs/guides/install/trusted.md +0 -46
  159. package/docs/guides/install/workspaces.md +0 -70
  160. package/docs/guides/install/yarnlock.md +0 -44
  161. package/docs/guides/process/argv.md +0 -58
  162. package/docs/guides/process/ctrl-c.md +0 -16
  163. package/docs/guides/process/ipc.md +0 -66
  164. package/docs/guides/process/nanoseconds.md +0 -13
  165. package/docs/guides/process/os-signals.md +0 -39
  166. package/docs/guides/process/spawn-stderr.md +0 -31
  167. package/docs/guides/process/spawn-stdout.md +0 -26
  168. package/docs/guides/process/spawn.md +0 -41
  169. package/docs/guides/process/stdin.md +0 -54
  170. package/docs/guides/read-file/arraybuffer.md +0 -28
  171. package/docs/guides/read-file/buffer.md +0 -19
  172. package/docs/guides/read-file/exists.md +0 -16
  173. package/docs/guides/read-file/json.md +0 -17
  174. package/docs/guides/read-file/mime.md +0 -20
  175. package/docs/guides/read-file/stream.md +0 -26
  176. package/docs/guides/read-file/string.md +0 -22
  177. package/docs/guides/read-file/uint8array.md +0 -21
  178. package/docs/guides/read-file/watch.md +0 -68
  179. package/docs/guides/runtime/build-time-constants.md +0 -293
  180. package/docs/guides/runtime/cicd.md +0 -43
  181. package/docs/guides/runtime/codesign-macos-executable.md +0 -56
  182. package/docs/guides/runtime/define-constant.md +0 -145
  183. package/docs/guides/runtime/delete-directory.md +0 -37
  184. package/docs/guides/runtime/delete-file.md +0 -19
  185. package/docs/guides/runtime/heap-snapshot.md +0 -26
  186. package/docs/guides/runtime/import-html.md +0 -15
  187. package/docs/guides/runtime/import-json.md +0 -44
  188. package/docs/guides/runtime/import-toml.md +0 -30
  189. package/docs/guides/runtime/import-yaml.md +0 -102
  190. package/docs/guides/runtime/read-env.md +0 -32
  191. package/docs/guides/runtime/set-env.md +0 -47
  192. package/docs/guides/runtime/shell.md +0 -40
  193. package/docs/guides/runtime/timezone.md +0 -35
  194. package/docs/guides/runtime/tsconfig-paths.md +0 -29
  195. package/docs/guides/runtime/typescript.md +0 -49
  196. package/docs/guides/runtime/vscode-debugger.md +0 -47
  197. package/docs/guides/runtime/web-debugger.md +0 -82
  198. package/docs/guides/streams/node-readable-to-arraybuffer.md +0 -11
  199. package/docs/guides/streams/node-readable-to-blob.md +0 -11
  200. package/docs/guides/streams/node-readable-to-json.md +0 -12
  201. package/docs/guides/streams/node-readable-to-string.md +0 -12
  202. package/docs/guides/streams/node-readable-to-uint8array.md +0 -11
  203. package/docs/guides/streams/to-array.md +0 -14
  204. package/docs/guides/streams/to-arraybuffer.md +0 -14
  205. package/docs/guides/streams/to-blob.md +0 -14
  206. package/docs/guides/streams/to-buffer.md +0 -15
  207. package/docs/guides/streams/to-json.md +0 -14
  208. package/docs/guides/streams/to-string.md +0 -14
  209. package/docs/guides/streams/to-typedarray.md +0 -22
  210. package/docs/guides/test/bail.md +0 -22
  211. package/docs/guides/test/coverage-threshold.md +0 -60
  212. package/docs/guides/test/coverage.md +0 -44
  213. package/docs/guides/test/happy-dom.md +0 -68
  214. package/docs/guides/test/migrate-from-jest.md +0 -143
  215. package/docs/guides/test/mock-clock.md +0 -48
  216. package/docs/guides/test/mock-functions.md +0 -68
  217. package/docs/guides/test/rerun-each.md +0 -14
  218. package/docs/guides/test/run-tests.md +0 -111
  219. package/docs/guides/test/skip-tests.md +0 -39
  220. package/docs/guides/test/snapshot.md +0 -95
  221. package/docs/guides/test/spy-on.md +0 -46
  222. package/docs/guides/test/svelte-test.md +0 -120
  223. package/docs/guides/test/testing-library.md +0 -92
  224. package/docs/guides/test/timeout.md +0 -15
  225. package/docs/guides/test/todo-tests.md +0 -67
  226. package/docs/guides/test/update-snapshots.md +0 -46
  227. package/docs/guides/test/watch-mode.md +0 -19
  228. package/docs/guides/util/base64.md +0 -15
  229. package/docs/guides/util/deep-equals.md +0 -39
  230. package/docs/guides/util/deflate.md +0 -18
  231. package/docs/guides/util/detect-bun.md +0 -23
  232. package/docs/guides/util/entrypoint.md +0 -17
  233. package/docs/guides/util/escape-html.md +0 -22
  234. package/docs/guides/util/file-url-to-path.md +0 -14
  235. package/docs/guides/util/gzip.md +0 -18
  236. package/docs/guides/util/hash-a-password.md +0 -54
  237. package/docs/guides/util/import-meta-dir.md +0 -13
  238. package/docs/guides/util/import-meta-file.md +0 -13
  239. package/docs/guides/util/import-meta-path.md +0 -13
  240. package/docs/guides/util/javascript-uuid.md +0 -23
  241. package/docs/guides/util/main.md +0 -32
  242. package/docs/guides/util/path-to-file-url.md +0 -14
  243. package/docs/guides/util/sleep.md +0 -22
  244. package/docs/guides/util/version.md +0 -21
  245. package/docs/guides/util/which-path-to-executable-bin.md +0 -15
  246. package/docs/guides/websocket/compression.md +0 -31
  247. package/docs/guides/websocket/context.md +0 -77
  248. package/docs/guides/websocket/pubsub.md +0 -41
  249. package/docs/guides/websocket/simple.md +0 -33
  250. package/docs/guides/write-file/append.md +0 -52
  251. package/docs/guides/write-file/basic.md +0 -44
  252. package/docs/guides/write-file/blob.md +0 -28
  253. package/docs/guides/write-file/cat.md +0 -17
  254. package/docs/guides/write-file/file-cp.md +0 -16
  255. package/docs/guides/write-file/filesink.md +0 -52
  256. package/docs/guides/write-file/response.md +0 -17
  257. package/docs/guides/write-file/stdout.md +0 -21
  258. package/docs/guides/write-file/stream.md +0 -17
  259. package/docs/guides/write-file/unlink.md +0 -16
  260. package/docs/index.md +0 -77
  261. package/docs/install/audit.md +0 -57
  262. package/docs/install/cache.md +0 -59
  263. package/docs/install/catalogs.md +0 -298
  264. package/docs/install/index.md +0 -248
  265. package/docs/install/isolated.md +0 -197
  266. package/docs/install/lifecycle.md +0 -46
  267. package/docs/install/lockfile.md +0 -58
  268. package/docs/install/npmrc.md +0 -105
  269. package/docs/install/overrides.md +0 -73
  270. package/docs/install/patch.md +0 -59
  271. package/docs/install/registries.md +0 -30
  272. package/docs/install/security-scanner-api.md +0 -81
  273. package/docs/install/workspaces.md +0 -114
  274. package/docs/installation.md +0 -327
  275. package/docs/project/asan.md +0 -124
  276. package/docs/project/benchmarking.md +0 -203
  277. package/docs/project/bindgen.md +0 -225
  278. package/docs/project/building-windows.md +0 -162
  279. package/docs/project/contributing.md +0 -347
  280. package/docs/project/internals/build-process-for-ci.md +0 -75
  281. package/docs/project/licensing.md +0 -73
  282. package/docs/project/roadmap.md +0 -87
  283. package/docs/quickstart.md +0 -157
  284. package/docs/runtime/autoimport.md +0 -94
  285. package/docs/runtime/bun-apis.md +0 -207
  286. package/docs/runtime/bunfig.md +0 -772
  287. package/docs/runtime/debugger.md +0 -325
  288. package/docs/runtime/env.md +0 -253
  289. package/docs/runtime/hot.md +0 -145
  290. package/docs/runtime/index.md +0 -312
  291. package/docs/runtime/jsx.md +0 -385
  292. package/docs/runtime/loaders.md +0 -130
  293. package/docs/runtime/modules.md +0 -320
  294. package/docs/runtime/nodejs-apis.md +0 -463
  295. package/docs/runtime/plugins.md +0 -561
  296. package/docs/runtime/shell.md +0 -605
  297. package/docs/runtime/typescript.md +0 -139
  298. package/docs/runtime/web-apis.md +0 -128
  299. package/docs/test/configuration.md +0 -154
  300. package/docs/test/coverage.md +0 -142
  301. package/docs/test/discovery.md +0 -85
  302. package/docs/test/dom.md +0 -75
  303. package/docs/test/examples/concurrent-test-glob.md +0 -132
  304. package/docs/test/hot.md +0 -15
  305. package/docs/test/lifecycle.md +0 -81
  306. package/docs/test/mocks.md +0 -313
  307. package/docs/test/reporters.md +0 -117
  308. package/docs/test/runtime-behavior.md +0 -95
  309. package/docs/test/snapshots.md +0 -68
  310. package/docs/test/time.md +0 -126
  311. package/docs/test/writing.md +0 -825
  312. package/docs/typescript.md +0 -53
package/docs/cli/add.md DELETED
@@ -1,173 +0,0 @@
1
- To add a particular package:
2
-
3
- ```bash
4
- $ bun add preact
5
- ```
6
-
7
- To specify a version, version range, or tag:
8
-
9
- ```bash
10
- $ bun add zod@3.20.0
11
- $ bun add zod@^3.0.0
12
- $ bun add zod@latest
13
- ```
14
-
15
- ## `--dev`
16
-
17
- {% callout %}
18
- **Alias** — `--development`, `-d`, `-D`
19
- {% /callout %}
20
-
21
- To add a package as a dev dependency (`"devDependencies"`):
22
-
23
- ```bash
24
- $ bun add --dev @types/react
25
- $ bun add -d @types/react
26
- ```
27
-
28
- ## `--optional`
29
-
30
- To add a package as an optional dependency (`"optionalDependencies"`):
31
-
32
- ```bash
33
- $ bun add --optional lodash
34
- ```
35
-
36
- ## `--peer`
37
-
38
- To add a package as a peer dependency (`"peerDependencies"`):
39
-
40
- ```bash
41
- $ bun add --peer @types/bun
42
- ```
43
-
44
- ## `--exact`
45
-
46
- {% callout %}
47
- **Alias** — `-E`
48
- {% /callout %}
49
-
50
- To add a package and pin to the resolved version, use `--exact`. This will resolve the version of the package and add it to your `package.json` with an exact version number instead of a version range.
51
-
52
- ```bash
53
- $ bun add react --exact
54
- $ bun add react -E
55
- ```
56
-
57
- This will add the following to your `package.json`:
58
-
59
- ```jsonc
60
- {
61
- "dependencies": {
62
- // without --exact
63
- "react": "^18.2.0", // this matches >= 18.2.0 < 19.0.0
64
-
65
- // with --exact
66
- "react": "18.2.0", // this matches only 18.2.0 exactly
67
- },
68
- }
69
- ```
70
-
71
- To view a complete list of options for this command:
72
-
73
- ```bash
74
- $ bun add --help
75
- ```
76
-
77
- ## `--global`
78
-
79
- {% callout %}
80
- **Note** — This would not modify package.json of your current project folder.
81
- **Alias** - `bun add --global`, `bun add -g`, `bun install --global` and `bun install -g`
82
- {% /callout %}
83
-
84
- To install a package globally, use the `-g`/`--global` flag. This will not modify the `package.json` of your current project. Typically this is used for installing command-line tools.
85
-
86
- ```bash
87
- $ bun add --global cowsay # or `bun add -g cowsay`
88
- $ cowsay "Bun!"
89
- ______
90
- < Bun! >
91
- ------
92
- \ ^__^
93
- \ (oo)\_______
94
- (__)\ )\/\
95
- ||----w |
96
- || ||
97
- ```
98
-
99
- {% details summary="Configuring global installation behavior" %}
100
-
101
- ```toml
102
- [install]
103
- # where `bun add --global` installs packages
104
- globalDir = "~/.bun/install/global"
105
-
106
- # where globally-installed package bins are linked
107
- globalBinDir = "~/.bun/bin"
108
- ```
109
-
110
- {% /details %}
111
-
112
- ## Trusted dependencies
113
-
114
- Unlike other npm clients, Bun does not execute arbitrary lifecycle scripts for installed dependencies, such as `postinstall`. These scripts represent a potential security risk, as they can execute arbitrary code on your machine.
115
-
116
- To tell Bun to allow lifecycle scripts for a particular package, add the package to `trustedDependencies` in your package.json.
117
-
118
- ```json-diff
119
- {
120
- "name": "my-app",
121
- "version": "1.0.0",
122
- + "trustedDependencies": ["my-trusted-package"]
123
- }
124
- ```
125
-
126
- Bun reads this field and will run lifecycle scripts for `my-trusted-package`.
127
-
128
- <!-- Bun maintains an allow-list of popular packages containing `postinstall` scripts that are known to be safe. To run lifecycle scripts for packages that aren't on this list, add the package to `trustedDependencies` in your package.json. -->
129
-
130
- ## Git dependencies
131
-
132
- To add a dependency from a public or private git repository:
133
-
134
- ```bash
135
- $ bun add git@github.com:moment/moment.git
136
- ```
137
-
138
- {% callout %}
139
- **Note** — To install private repositories, your system needs the appropriate SSH credentials to access the repository.
140
- {% /callout %}
141
-
142
- Bun supports a variety of protocols, including [`github`](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#github-urls), [`git`](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#git-urls-as-dependencies), `git+ssh`, `git+https`, and many more.
143
-
144
- ```json
145
- {
146
- "dependencies": {
147
- "dayjs": "git+https://github.com/iamkun/dayjs.git",
148
- "lodash": "git+ssh://github.com/lodash/lodash.git#4.17.21",
149
- "moment": "git@github.com:moment/moment.git",
150
- "zod": "github:colinhacks/zod"
151
- }
152
- }
153
- ```
154
-
155
- ## Tarball dependencies
156
-
157
- A package name can correspond to a publicly hosted `.tgz` file. During installation, Bun will download and install the package from the specified tarball URL, rather than from the package registry.
158
-
159
- ```sh
160
- $ bun add zod@https://registry.npmjs.org/zod/-/zod-3.21.4.tgz
161
- ```
162
-
163
- This will add the following line to your `package.json`:
164
-
165
- ```json#package.json
166
- {
167
- "dependencies": {
168
- "zod": "https://registry.npmjs.org/zod/-/zod-3.21.4.tgz"
169
- }
170
- }
171
- ```
172
-
173
- {% bunCLIUsage command="add" /%}
@@ -1,3 +0,0 @@
1
- This command installs completions for `zsh` and/or `fish`. It runs automatically on every `bun upgrade` and on install. It reads from `$SHELL` to determine which shell to install for. It tries several common shell completion directories for your shell and OS.
2
-
3
- If you want to copy the completions manually, run `bun completions > path-to-file`. If you know the completions directory to install them to, run `bun completions /path/to/directory`.
@@ -1,338 +0,0 @@
1
- {% callout %}
2
- **Note** — You don’t need `bun create` to use Bun. You don’t need any configuration at all. This command exists to make getting started a bit quicker and easier.
3
- {% /callout %}
4
-
5
- Template a new Bun project with `bun create`. This is a flexible command that can be used to create a new project from a React component, a `create-<template>` npm package, a GitHub repo, or a local template.
6
-
7
- If you're looking to create a brand new empty project, use [`bun init`](https://bun.com/docs/cli/init).
8
-
9
- ## From a React component
10
-
11
- `bun create ./MyComponent.tsx` turns an existing React component into a complete dev environment with hot reload and production builds in one command.
12
-
13
- ```bash
14
- $ bun create ./MyComponent.jsx # .tsx also supported
15
- ```
16
-
17
- {% raw %}
18
-
19
- <video style="aspect-ratio: 2062 / 1344; width: 100%; height: 100%; object-fit: contain;" loop autoplay muted playsinline>
20
- <source src="/bun-create-shadcn.mp4" style="width: 100%; height: 100%; object-fit: contain;" type="video/mp4">
21
- </video>
22
-
23
- {% /raw %}
24
-
25
- {% callout %}
26
- 🚀 **Create React App Successor** — `bun create <component>` provides everything developers loved about Create React App, but with modern tooling, faster builds, and backend support.
27
- {% /callout %}
28
-
29
- #### How this works
30
-
31
- When you run `bun create <component>`, Bun:
32
-
33
- 1. Uses [Bun's JavaScript bundler](https://bun.com/docs/bundler) to analyze your module graph.
34
- 2. Collects all the dependencies needed to run the component.
35
- 3. Scans the exports of the entry point for a React component.
36
- 4. Generates a `package.json` file with the dependencies and scripts needed to run the component.
37
- 5. Installs any missing dependencies using [`bun install --only-missing`](https://bun.com/docs/cli/install).
38
- 6. Generates the following files:
39
- - `${component}.html`
40
- - `${component}.client.tsx` (entry point for the frontend)
41
- - `${component}.css` (css file)
42
- 7. Starts a frontend dev server automatically.
43
-
44
- ### Using TailwindCSS with Bun
45
-
46
- [TailwindCSS](https://tailwindcss.com/) is an extremely popular utility-first CSS framework used to style web applications.
47
-
48
- When you run `bun create <component>`, Bun scans your JSX/TSX file for TailwindCSS class names (and any files it imports). If it detects TailwindCSS class names, it will add the following dependencies to your `package.json`:
49
-
50
- ```json#package.json
51
- {
52
- "dependencies": {
53
- "tailwindcss": "^4",
54
- "bun-plugin-tailwind": "latest"
55
- }
56
- }
57
- ```
58
-
59
- We also configure `bunfig.toml` to use Bun's TailwindCSS plugin with `Bun.serve()`
60
-
61
- ```toml#bunfig.toml
62
- [serve.static]
63
- plugins = ["bun-plugin-tailwind"]
64
- ```
65
-
66
- And a `${component}.css` file with `@import "tailwindcss";` at the top:
67
-
68
- ```css#MyComponent.css
69
- @import "tailwindcss";
70
- ```
71
-
72
- ### Using `shadcn/ui` with Bun
73
-
74
- [`shadcn/ui`](https://ui.shadcn.com/) is an extremely popular component library tool for building web applications.
75
-
76
- `bun create <component>` scans for any shadcn/ui components imported from `@/components/ui`.
77
-
78
- If it finds any, it runs:
79
-
80
- ```bash
81
- # Assuming bun detected imports to @/components/ui/accordion and @/components/ui/button
82
- $ bunx shadcn@canary add accordion button # and any other components
83
- ```
84
-
85
- Since `shadcn/ui` itself uses TailwindCSS, `bun create` also adds the necessary TailwindCSS dependencies to your `package.json` and configures `bunfig.toml` to use Bun's TailwindCSS plugin with `Bun.serve()` as described above.
86
-
87
- Additionally, we setup the following:
88
-
89
- - `tsconfig.json` to alias `"@/*"` to `"src/*"` or `.` (depending on if there is a `src/` directory)
90
- - `components.json` so that shadcn/ui knows its a shadcn/ui project
91
- - `styles/globals.css` file that configures Tailwind v4 in the way that shadcn/ui expects
92
- - `${component}.build.ts` file that builds the component for production with `bun-plugin-tailwind` configured
93
-
94
- `bun create ./MyComponent.jsx` is one of the easiest ways to run code generated from LLMs like [Claude](https://claude.ai) or ChatGPT locally.
95
-
96
- ## From `npm`
97
-
98
- ```sh
99
- $ bun create <template> [<destination>]
100
- ```
101
-
102
- Assuming you don't have a [local template](#from-a-local-template) with the same name, this command will download and execute the `create-<template>` package from npm. The following two commands will behave identically:
103
-
104
- ```sh
105
- $ bun create remix
106
- $ bunx create-remix
107
- ```
108
-
109
- Refer to the documentation of the associated `create-<template>` package for complete documentation and usage instructions.
110
-
111
- ## From GitHub
112
-
113
- This will download the contents of the GitHub repo to disk.
114
-
115
- ```bash
116
- $ bun create <user>/<repo>
117
- $ bun create github.com/<user>/<repo>
118
- ```
119
-
120
- Optionally specify a name for the destination folder. If no destination is specified, the repo name will be used.
121
-
122
- ```bash
123
- $ bun create <user>/<repo> mydir
124
- $ bun create github.com/<user>/<repo> mydir
125
- ```
126
-
127
- Bun will perform the following steps:
128
-
129
- - Download the template
130
- - Copy all template files into the destination folder
131
- - Install dependencies with `bun install`.
132
- - Initialize a fresh Git repo. Opt out with the `--no-git` flag.
133
- - Run the template's configured `start` script, if defined.
134
-
135
- {% callout %}
136
- By default Bun will _not overwrite_ any existing files. Use the `--force` flag to overwrite existing files.
137
- {% /callout %}
138
-
139
- <!-- ### Official templates
140
-
141
- The following official templates are available.
142
-
143
- ```bash
144
- bun create next ./myapp
145
- bun create react ./myapp
146
- bun create svelte-kit ./myapp
147
- bun create elysia ./myapp
148
- bun create hono ./myapp
149
- bun create kingworld ./myapp
150
- ```
151
-
152
- Each of these corresponds to a directory in the [bun-community/create-templates](https://github.com/bun-community/create-templates) repo. If you think a major framework is missing, please open a PR there. This list will change over time as additional examples are added. To see an up-to-date list, run `bun create` with no arguments.
153
-
154
- ```bash
155
- $ bun create
156
- Welcome to bun! Create a new project by pasting any of the following:
157
- <list of templates>
158
- ```
159
-
160
- {% callout %}
161
- ⚡️ **Speed** — At the time of writing, `bun create react app` runs ~11x faster on a M1 Macbook Pro than `yarn create react-app app`.
162
- {% /callout %} -->
163
-
164
- <!-- ### GitHub repos
165
-
166
- A template of the form `<username>/<repo>` will be downloaded from GitHub.
167
-
168
- ```bash
169
- $ bun create ahfarmer/calculator ./myapp
170
- ```
171
-
172
- Complete GitHub URLs will also work:
173
-
174
- ```bash
175
- $ bun create github.com/ahfarmer/calculator ./myapp
176
- $ bun create https://github.com/ahfarmer/calculator ./myapp
177
- ```
178
-
179
- Bun installs the files as they currently exist current default branch (usually `main` or `master`). Unlike `git clone` it doesn't download the commit history or configure a remote. -->
180
-
181
- ## From a local template
182
-
183
- {% callout %}
184
- **⚠️ Warning** — Unlike remote templates, running `bun create` with a local template will delete the entire destination folder if it already exists! Be careful.
185
- {% /callout %}
186
- Bun's templater can be extended to support custom templates defined on your local file system. These templates should live in one of the following directories:
187
-
188
- - `$HOME/.bun-create/<name>`: global templates
189
- - `<project root>/.bun-create/<name>`: project-specific templates
190
-
191
- {% callout %}
192
- **Note** — You can customize the global template path by setting the `BUN_CREATE_DIR` environment variable.
193
- {% /callout %}
194
-
195
- To create a local template, navigate to `$HOME/.bun-create` and create a new directory with the desired name of your template.
196
-
197
- ```bash
198
- $ cd $HOME/.bun-create
199
- $ mkdir foo
200
- $ cd foo
201
- ```
202
-
203
- Then, create a `package.json` file in that directory with the following contents:
204
-
205
- ```json
206
- {
207
- "name": "foo"
208
- }
209
- ```
210
-
211
- You can run `bun create foo` elsewhere on your file system to verify that Bun is correctly finding your local template.
212
-
213
- #### Setup logic
214
-
215
- You can specify pre- and post-install setup scripts in the `"bun-create"` section of your local template's `package.json`.
216
-
217
- ```json
218
- {
219
- "name": "@bun-examples/simplereact",
220
- "version": "0.0.1",
221
- "main": "index.js",
222
- "dependencies": {
223
- "react": "^17.0.2",
224
- "react-dom": "^17.0.2"
225
- },
226
- "bun-create": {
227
- "preinstall": "echo 'Installing...'", // a single command
228
- "postinstall": ["echo 'Done!'"], // an array of commands
229
- "start": "bun run echo 'Hello world!'"
230
- }
231
- }
232
- ```
233
-
234
- The following fields are supported. Each of these can correspond to a string or array of strings. An array of commands will be executed in order.
235
-
236
- {% table %}
237
-
238
- ---
239
-
240
- - `postinstall`
241
- - runs after installing dependencies
242
-
243
- ---
244
-
245
- - `preinstall`
246
- - runs before installing dependencies
247
-
248
- {% /table %}
249
-
250
- After cloning a template, `bun create` will automatically remove the `"bun-create"` section from `package.json` before writing it to the destination folder.
251
-
252
- ## Reference
253
-
254
- ### CLI flags
255
-
256
- {% table %}
257
-
258
- - Flag
259
- - Description
260
-
261
- ---
262
-
263
- - `--force`
264
- - Overwrite existing files
265
-
266
- ---
267
-
268
- - `--no-install`
269
- - Skip installing `node_modules` & tasks
270
-
271
- ---
272
-
273
- - `--no-git`
274
- - Don’t initialize a git repository
275
-
276
- ---
277
-
278
- - `--open`
279
- - Start & open in-browser after finish
280
-
281
- {% /table %}
282
-
283
- ### Environment variables
284
-
285
- {% table %}
286
-
287
- - Name
288
- - Description
289
-
290
- ---
291
-
292
- - `GITHUB_API_DOMAIN`
293
- - If you’re using a GitHub enterprise or a proxy, you can customize the GitHub domain Bun pings for downloads
294
-
295
- ---
296
-
297
- - `GITHUB_TOKEN` (or `GITHUB_ACCESS_TOKEN`)
298
- - This lets `bun create` work with private repositories or if you get rate-limited. `GITHUB_TOKEN` is chosen over `GITHUB_ACCESS_TOKEN` if both exist.
299
-
300
- {% /table %}
301
-
302
- {% details summary="How `bun create` works" %}
303
-
304
- When you run `bun create ${template} ${destination}`, here’s what happens:
305
-
306
- IF remote template
307
-
308
- 1. GET `registry.npmjs.org/@bun-examples/${template}/latest` and parse it
309
- 2. GET `registry.npmjs.org/@bun-examples/${template}/-/${template}-${latestVersion}.tgz`
310
- 3. Decompress & extract `${template}-${latestVersion}.tgz` into `${destination}`
311
- - If there are files that would overwrite, warn and exit unless `--force` is passed
312
-
313
- IF GitHub repo
314
-
315
- 1. Download the tarball from GitHub’s API
316
- 2. Decompress & extract into `${destination}`
317
- - If there are files that would overwrite, warn and exit unless `--force` is passed
318
-
319
- ELSE IF local template
320
-
321
- 1. Open local template folder
322
- 2. Delete destination directory recursively
323
- 3. Copy files recursively using the fastest system calls available (on macOS `fcopyfile` and Linux, `copy_file_range`). Do not copy or traverse into `node_modules` folder if exists (this alone makes it faster than `cp`)
324
-
325
- 4. Parse the `package.json` (again!), update `name` to be `${basename(destination)}`, remove the `bun-create` section from the `package.json` and save the updated `package.json` to disk.
326
- - IF Next.js is detected, add `bun-framework-next` to the list of dependencies
327
- - IF Create React App is detected, add the entry point in /src/index.{js,jsx,ts,tsx} to `public/index.html`
328
- - IF Relay is detected, add `bun-macro-relay` so that Relay works
329
- 5. Auto-detect the npm client, preferring `pnpm`, `yarn` (v1), and lastly `npm`
330
- 6. Run any tasks defined in `"bun-create": { "preinstall" }` with the npm client
331
- 7. Run `${npmClient} install` unless `--no-install` is passed OR no dependencies are in package.json
332
- 8. Run any tasks defined in `"bun-create": { "postinstall" }` with the npm client
333
- 9. Run `git init; git add -A .; git commit -am "Initial Commit";`
334
- - Rename `gitignore` to `.gitignore`. NPM automatically removes `.gitignore` files from appearing in packages.
335
- - If there are dependencies, this runs in a separate thread concurrently while node_modules are being installed
336
- - Using libgit2 if available was tested and performed 3x slower in microbenchmarks
337
-
338
- {% /details %}