bun-types 1.1.37-canary.20241123T140655 → 1.1.37-canary.20241125T140601

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 (272) hide show
  1. package/docs/api/binary-data.md +1028 -0
  2. package/docs/api/cc.md +197 -0
  3. package/docs/api/color.md +262 -0
  4. package/docs/api/console.md +38 -0
  5. package/docs/api/dns.md +113 -0
  6. package/docs/api/fetch.md +308 -0
  7. package/docs/api/ffi.md +536 -0
  8. package/docs/api/file-io.md +358 -0
  9. package/docs/api/file-system-router.md +112 -0
  10. package/docs/api/file.md +19 -0
  11. package/docs/api/glob.md +157 -0
  12. package/docs/api/globals.md +387 -0
  13. package/docs/api/hashing.md +314 -0
  14. package/docs/api/html-rewriter.md +31 -0
  15. package/docs/api/http.md +661 -0
  16. package/docs/api/import-meta.md +69 -0
  17. package/docs/api/node-api.md +16 -0
  18. package/docs/api/semver.md +52 -0
  19. package/docs/api/spawn.md +441 -0
  20. package/docs/api/sqlite.md +692 -0
  21. package/docs/api/streams.md +214 -0
  22. package/docs/api/tcp.md +221 -0
  23. package/docs/api/test.md +1 -0
  24. package/docs/api/transpiler.md +274 -0
  25. package/docs/api/udp.md +125 -0
  26. package/docs/api/utils.md +773 -0
  27. package/docs/api/websockets.md +547 -0
  28. package/docs/api/workers.md +230 -0
  29. package/docs/benchmarks.md +120 -0
  30. package/docs/bun-flavored-toml.md +42 -0
  31. package/docs/bundler/executables.md +291 -0
  32. package/docs/bundler/index.md +1543 -0
  33. package/docs/bundler/intro.md +75 -0
  34. package/docs/bundler/loaders.md +288 -0
  35. package/docs/bundler/macros.md +327 -0
  36. package/docs/bundler/plugins.md +30 -0
  37. package/docs/bundler/vs-esbuild.md +1127 -0
  38. package/docs/cli/add.md +163 -0
  39. package/docs/cli/bun-completions.md +3 -0
  40. package/docs/cli/bun-create.md +254 -0
  41. package/docs/cli/bun-dev.md +21 -0
  42. package/docs/cli/bun-install.md +255 -0
  43. package/docs/cli/bun-upgrade.md +39 -0
  44. package/docs/cli/bunx.md +80 -0
  45. package/docs/cli/filter.md +57 -0
  46. package/docs/cli/init.md +40 -0
  47. package/docs/cli/install.md +205 -0
  48. package/docs/cli/link.md +38 -0
  49. package/docs/cli/outdated.md +61 -0
  50. package/docs/cli/patch-commit.md +9 -0
  51. package/docs/cli/pm.md +150 -0
  52. package/docs/cli/publish.md +107 -0
  53. package/docs/cli/remove.md +5 -0
  54. package/docs/cli/run.md +196 -0
  55. package/docs/cli/test.md +247 -0
  56. package/docs/cli/unlink.md +7 -0
  57. package/docs/cli/update.md +34 -0
  58. package/docs/contributing/upgrading-webkit.md +57 -0
  59. package/docs/ecosystem/elysia.md +24 -0
  60. package/docs/ecosystem/express.md +37 -0
  61. package/docs/ecosystem/hono.md +18 -0
  62. package/docs/ecosystem/react.md +65 -0
  63. package/docs/ecosystem/stric.md +37 -0
  64. package/docs/guides/binary/arraybuffer-to-array.md +27 -0
  65. package/docs/guides/binary/arraybuffer-to-blob.md +24 -0
  66. package/docs/guides/binary/arraybuffer-to-buffer.md +25 -0
  67. package/docs/guides/binary/arraybuffer-to-string.md +15 -0
  68. package/docs/guides/binary/arraybuffer-to-typedarray.md +39 -0
  69. package/docs/guides/binary/blob-to-arraybuffer.md +14 -0
  70. package/docs/guides/binary/blob-to-dataview.md +14 -0
  71. package/docs/guides/binary/blob-to-stream.md +14 -0
  72. package/docs/guides/binary/blob-to-string.md +15 -0
  73. package/docs/guides/binary/blob-to-typedarray.md +14 -0
  74. package/docs/guides/binary/buffer-to-arraybuffer.md +14 -0
  75. package/docs/guides/binary/buffer-to-blob.md +14 -0
  76. package/docs/guides/binary/buffer-to-readablestream.md +41 -0
  77. package/docs/guides/binary/buffer-to-string.md +25 -0
  78. package/docs/guides/binary/buffer-to-typedarray.md +14 -0
  79. package/docs/guides/binary/dataview-to-string.md +15 -0
  80. package/docs/guides/binary/typedarray-to-arraybuffer.md +25 -0
  81. package/docs/guides/binary/typedarray-to-blob.md +16 -0
  82. package/docs/guides/binary/typedarray-to-buffer.md +14 -0
  83. package/docs/guides/binary/typedarray-to-dataview.md +14 -0
  84. package/docs/guides/binary/typedarray-to-readablestream.md +41 -0
  85. package/docs/guides/binary/typedarray-to-string.md +16 -0
  86. package/docs/guides/ecosystem/astro.md +72 -0
  87. package/docs/guides/ecosystem/discordjs.md +77 -0
  88. package/docs/guides/ecosystem/docker.md +140 -0
  89. package/docs/guides/ecosystem/drizzle.md +185 -0
  90. package/docs/guides/ecosystem/edgedb.md +228 -0
  91. package/docs/guides/ecosystem/elysia.md +31 -0
  92. package/docs/guides/ecosystem/express.md +40 -0
  93. package/docs/guides/ecosystem/hono.md +39 -0
  94. package/docs/guides/ecosystem/mongoose.md +87 -0
  95. package/docs/guides/ecosystem/neon-drizzle.md +220 -0
  96. package/docs/guides/ecosystem/neon-serverless-postgres.md +55 -0
  97. package/docs/guides/ecosystem/nextjs.md +38 -0
  98. package/docs/guides/ecosystem/nuxt.md +56 -0
  99. package/docs/guides/ecosystem/pm2.md +57 -0
  100. package/docs/guides/ecosystem/prisma.md +140 -0
  101. package/docs/guides/ecosystem/qwik.md +107 -0
  102. package/docs/guides/ecosystem/react.md +49 -0
  103. package/docs/guides/ecosystem/remix.md +78 -0
  104. package/docs/guides/ecosystem/render.md +79 -0
  105. package/docs/guides/ecosystem/sentry.md +52 -0
  106. package/docs/guides/ecosystem/solidstart.md +58 -0
  107. package/docs/guides/ecosystem/ssr-react.md +51 -0
  108. package/docs/guides/ecosystem/stric.md +55 -0
  109. package/docs/guides/ecosystem/sveltekit.md +125 -0
  110. package/docs/guides/ecosystem/systemd.md +113 -0
  111. package/docs/guides/ecosystem/vite.md +70 -0
  112. package/docs/guides/http/cluster.md +66 -0
  113. package/docs/guides/http/fetch-unix.md +33 -0
  114. package/docs/guides/http/fetch.md +24 -0
  115. package/docs/guides/http/file-uploads.md +94 -0
  116. package/docs/guides/http/hot.md +22 -0
  117. package/docs/guides/http/proxy.md +24 -0
  118. package/docs/guides/http/server.md +46 -0
  119. package/docs/guides/http/simple.md +18 -0
  120. package/docs/guides/http/stream-file.md +48 -0
  121. package/docs/guides/http/stream-iterator.md +47 -0
  122. package/docs/guides/http/stream-node-streams-in-bun.md +20 -0
  123. package/docs/guides/http/tls.md +30 -0
  124. package/docs/guides/install/add-dev.md +26 -0
  125. package/docs/guides/install/add-git.md +36 -0
  126. package/docs/guides/install/add-optional.md +25 -0
  127. package/docs/guides/install/add-peer.md +17 -0
  128. package/docs/guides/install/add-tarball.md +33 -0
  129. package/docs/guides/install/add.md +42 -0
  130. package/docs/guides/install/azure-artifacts.md +73 -0
  131. package/docs/guides/install/cicd.md +41 -0
  132. package/docs/guides/install/custom-registry.md +30 -0
  133. package/docs/guides/install/from-npm-install-to-bun-install.md +214 -0
  134. package/docs/guides/install/git-diff-bun-lockfile.md +38 -0
  135. package/docs/guides/install/jfrog-artifactory.md +28 -0
  136. package/docs/guides/install/npm-alias.md +23 -0
  137. package/docs/guides/install/registry-scope.md +36 -0
  138. package/docs/guides/install/trusted.md +48 -0
  139. package/docs/guides/install/workspaces.md +70 -0
  140. package/docs/guides/install/yarnlock.md +42 -0
  141. package/docs/guides/process/argv.md +57 -0
  142. package/docs/guides/process/ctrl-c.md +16 -0
  143. package/docs/guides/process/ipc.md +66 -0
  144. package/docs/guides/process/nanoseconds.md +13 -0
  145. package/docs/guides/process/os-signals.md +39 -0
  146. package/docs/guides/process/spawn-stderr.md +31 -0
  147. package/docs/guides/process/spawn-stdout.md +26 -0
  148. package/docs/guides/process/spawn.md +41 -0
  149. package/docs/guides/process/stdin.md +54 -0
  150. package/docs/guides/read-file/arraybuffer.md +28 -0
  151. package/docs/guides/read-file/buffer.md +19 -0
  152. package/docs/guides/read-file/exists.md +16 -0
  153. package/docs/guides/read-file/json.md +17 -0
  154. package/docs/guides/read-file/mime.md +20 -0
  155. package/docs/guides/read-file/stream.md +26 -0
  156. package/docs/guides/read-file/string.md +22 -0
  157. package/docs/guides/read-file/uint8array.md +21 -0
  158. package/docs/guides/read-file/watch.md +68 -0
  159. package/docs/guides/runtime/cicd.md +43 -0
  160. package/docs/guides/runtime/define-constant.md +145 -0
  161. package/docs/guides/runtime/import-html.md +15 -0
  162. package/docs/guides/runtime/import-json.md +44 -0
  163. package/docs/guides/runtime/import-toml.md +30 -0
  164. package/docs/guides/runtime/read-env.md +32 -0
  165. package/docs/guides/runtime/set-env.md +37 -0
  166. package/docs/guides/runtime/shell.md +40 -0
  167. package/docs/guides/runtime/timezone.md +35 -0
  168. package/docs/guides/runtime/tsconfig-paths.md +29 -0
  169. package/docs/guides/runtime/typescript.md +47 -0
  170. package/docs/guides/runtime/vscode-debugger.md +47 -0
  171. package/docs/guides/runtime/web-debugger.md +82 -0
  172. package/docs/guides/streams/node-readable-to-arraybuffer.md +11 -0
  173. package/docs/guides/streams/node-readable-to-blob.md +11 -0
  174. package/docs/guides/streams/node-readable-to-json.md +12 -0
  175. package/docs/guides/streams/node-readable-to-string.md +12 -0
  176. package/docs/guides/streams/node-readable-to-uint8array.md +11 -0
  177. package/docs/guides/streams/to-array.md +14 -0
  178. package/docs/guides/streams/to-arraybuffer.md +14 -0
  179. package/docs/guides/streams/to-blob.md +14 -0
  180. package/docs/guides/streams/to-buffer.md +15 -0
  181. package/docs/guides/streams/to-json.md +14 -0
  182. package/docs/guides/streams/to-string.md +14 -0
  183. package/docs/guides/streams/to-typedarray.md +22 -0
  184. package/docs/guides/test/bail.md +22 -0
  185. package/docs/guides/test/coverage-threshold.md +60 -0
  186. package/docs/guides/test/coverage.md +44 -0
  187. package/docs/guides/test/happy-dom.md +68 -0
  188. package/docs/guides/test/migrate-from-jest.md +110 -0
  189. package/docs/guides/test/mock-clock.md +48 -0
  190. package/docs/guides/test/mock-functions.md +68 -0
  191. package/docs/guides/test/rerun-each.md +14 -0
  192. package/docs/guides/test/run-tests.md +111 -0
  193. package/docs/guides/test/skip-tests.md +39 -0
  194. package/docs/guides/test/snapshot.md +99 -0
  195. package/docs/guides/test/spy-on.md +46 -0
  196. package/docs/guides/test/testing-library.md +87 -0
  197. package/docs/guides/test/timeout.md +15 -0
  198. package/docs/guides/test/todo-tests.md +67 -0
  199. package/docs/guides/test/update-snapshots.md +50 -0
  200. package/docs/guides/test/watch-mode.md +19 -0
  201. package/docs/guides/util/base64.md +15 -0
  202. package/docs/guides/util/deep-equals.md +39 -0
  203. package/docs/guides/util/deflate.md +18 -0
  204. package/docs/guides/util/detect-bun.md +23 -0
  205. package/docs/guides/util/entrypoint.md +17 -0
  206. package/docs/guides/util/escape-html.md +22 -0
  207. package/docs/guides/util/file-url-to-path.md +14 -0
  208. package/docs/guides/util/gzip.md +18 -0
  209. package/docs/guides/util/hash-a-password.md +54 -0
  210. package/docs/guides/util/import-meta-dir.md +13 -0
  211. package/docs/guides/util/import-meta-file.md +13 -0
  212. package/docs/guides/util/import-meta-path.md +13 -0
  213. package/docs/guides/util/main.md +32 -0
  214. package/docs/guides/util/path-to-file-url.md +14 -0
  215. package/docs/guides/util/sleep.md +22 -0
  216. package/docs/guides/util/version.md +21 -0
  217. package/docs/guides/util/which-path-to-executable-bin.md +15 -0
  218. package/docs/guides/websocket/compression.md +31 -0
  219. package/docs/guides/websocket/context.md +72 -0
  220. package/docs/guides/websocket/pubsub.md +38 -0
  221. package/docs/guides/websocket/simple.md +33 -0
  222. package/docs/guides/write-file/append.md +52 -0
  223. package/docs/guides/write-file/basic.md +44 -0
  224. package/docs/guides/write-file/blob.md +28 -0
  225. package/docs/guides/write-file/cat.md +17 -0
  226. package/docs/guides/write-file/file-cp.md +16 -0
  227. package/docs/guides/write-file/filesink.md +52 -0
  228. package/docs/guides/write-file/response.md +17 -0
  229. package/docs/guides/write-file/stdout.md +21 -0
  230. package/docs/guides/write-file/stream.md +17 -0
  231. package/docs/guides/write-file/unlink.md +23 -0
  232. package/docs/index.md +77 -0
  233. package/docs/install/cache.md +57 -0
  234. package/docs/install/index.md +202 -0
  235. package/docs/install/lifecycle.md +46 -0
  236. package/docs/install/lockfile.md +90 -0
  237. package/docs/install/npmrc.md +75 -0
  238. package/docs/install/overrides.md +73 -0
  239. package/docs/install/patch.md +57 -0
  240. package/docs/install/registries.md +30 -0
  241. package/docs/install/workspaces.md +70 -0
  242. package/docs/installation.md +289 -0
  243. package/docs/project/benchmarking.md +203 -0
  244. package/docs/project/building-windows.md +162 -0
  245. package/docs/project/internals/build-process-for-ci.md +75 -0
  246. package/docs/project/roadmap.md +87 -0
  247. package/docs/quickstart.md +144 -0
  248. package/docs/runtime/autoimport.md +94 -0
  249. package/docs/runtime/bun-apis.md +129 -0
  250. package/docs/runtime/bunfig.md +532 -0
  251. package/docs/runtime/debugger.md +325 -0
  252. package/docs/runtime/env.md +214 -0
  253. package/docs/runtime/hot.md +139 -0
  254. package/docs/runtime/index.md +309 -0
  255. package/docs/runtime/jsx.md +326 -0
  256. package/docs/runtime/loaders.md +127 -0
  257. package/docs/runtime/modules.md +298 -0
  258. package/docs/runtime/nodejs-apis.md +456 -0
  259. package/docs/runtime/plugins.md +605 -0
  260. package/docs/runtime/shell.md +537 -0
  261. package/docs/runtime/typescript.md +60 -0
  262. package/docs/runtime/web-apis.md +128 -0
  263. package/docs/test/coverage.md +91 -0
  264. package/docs/test/dom.md +75 -0
  265. package/docs/test/hot.md +15 -0
  266. package/docs/test/lifecycle.md +81 -0
  267. package/docs/test/mocks.md +236 -0
  268. package/docs/test/snapshots.md +15 -0
  269. package/docs/test/time.md +106 -0
  270. package/docs/test/writing.md +547 -0
  271. package/docs/typescript.md +51 -0
  272. package/package.json +5 -4
@@ -0,0 +1,140 @@
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 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
+ }
44
+
45
+ datasource db {
46
+ provider = "sqlite"
47
+ url = env("DATABASE_URL")
48
+ }
49
+
50
+ + model User {
51
+ + id Int @id @default(autoincrement())
52
+ + email String @unique
53
+ + name String?
54
+ + }
55
+ ```
56
+
57
+ ---
58
+
59
+ Then generate and run initial migration.
60
+
61
+ This will generate a `.sql` migration file in `prisma/migrations`, create a new SQLite instance, and execute the migration against the new instance.
62
+
63
+ ```bash
64
+ $ bunx prisma migrate dev --name init
65
+ Environment variables loaded from .env
66
+ Prisma schema loaded from prisma/schema.prisma
67
+ Datasource "db": SQLite database "dev.db" at "file:./dev.db"
68
+
69
+ SQLite database dev.db created at file:./dev.db
70
+
71
+ Applying migration `20230928182242_init`
72
+
73
+ The following migration(s) have been created and applied from new schema changes:
74
+
75
+ migrations/
76
+ └─ 20230928182242_init/
77
+ └─ migration.sql
78
+
79
+ Your database is now in sync with your schema.
80
+
81
+ ✔ Generated Prisma Client (v5.3.1) to ./node_modules/@prisma/client in 41ms
82
+ ```
83
+
84
+ ---
85
+
86
+ 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.
87
+
88
+ ```sh
89
+ $ bunx prisma generate
90
+ ```
91
+
92
+ ---
93
+
94
+ We can import the generated client from `@prisma/client`.
95
+
96
+ ```ts#src/index.ts
97
+ import {PrismaClient} from "@prisma/client";
98
+ ```
99
+
100
+ ---
101
+
102
+ Let's write a simple script to create a new user, then count the number of users in the database.
103
+
104
+ ```ts#index.ts
105
+ import { PrismaClient } from "@prisma/client";
106
+
107
+ const prisma = new PrismaClient();
108
+
109
+ // create a new user
110
+ await prisma.user.create({
111
+ data: {
112
+ name: "John Dough",
113
+ email: `john-${Math.random()}@example.com`,
114
+ },
115
+ });
116
+
117
+ // count the number of users
118
+ const count = await prisma.user.count();
119
+ console.log(`There are ${count} users in the database.`);
120
+ ```
121
+
122
+ ---
123
+
124
+ Let's run this script with `bun run`. Each time we run it, a new user is created.
125
+
126
+ ```bash
127
+ $ bun run index.ts
128
+ Created john-0.12802932895402364@example.com
129
+ There are 1 users in the database.
130
+ $ bun run index.ts
131
+ Created john-0.8671308799782803@example.com
132
+ There are 2 users in the database.
133
+ $ bun run index.ts
134
+ Created john-0.4465968383115295@example.com
135
+ There are 3 users in the database.
136
+ ```
137
+
138
+ ---
139
+
140
+ 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.
@@ -0,0 +1,107 @@
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.
@@ -0,0 +1,49 @@
1
+ ---
2
+ name: Use React and JSX
3
+ ---
4
+
5
+ React just works with Bun. Bun supports `.jsx` and `.tsx` files out of the box.
6
+
7
+ Remember that JSX is just a special syntax for including HTML-like syntax in JavaScript files. React uses JSX syntax, as do alternatives like [Preact](https://preactjs.com/) and [Solid](https://www.solidjs.com/). Bun's internal transpiler converts JSX syntax into vanilla JavaScript before execution.
8
+
9
+ ---
10
+
11
+ Bun _assumes_ you're using React (unless you [configure it otherwise](https://bun.sh/docs/runtime/bunfig#jsx)) so a line like this:
12
+
13
+ ```
14
+ const element = <h1>Hello, world!</h1>;
15
+ ```
16
+
17
+ ---
18
+
19
+ is internally converted into something like this:
20
+
21
+ ```ts
22
+ // jsxDEV
23
+ import { jsx } from "react/jsx-dev-runtime";
24
+
25
+ const element = jsx("h1", { children: "Hello, world!" });
26
+ ```
27
+
28
+ ---
29
+
30
+ This code requires `react` to run, so make sure you've installed React.
31
+
32
+ ```bash
33
+ $ bun install react
34
+ ```
35
+
36
+ ---
37
+
38
+ Bun implements special logging for JSX components to make debugging easier.
39
+
40
+ ```bash
41
+ $ bun run log-my-component.tsx
42
+ <Component message="Hello world!" />
43
+ ```
44
+
45
+ ---
46
+
47
+ As far as "official support" for React goes, that's it. React is a library like any other, and Bun can run that library. Bun is not a framework, so you should use a framework like [Vite](https://vitejs.dev/) to build an app with server-side rendering and hot reloading in the browser.
48
+
49
+ Refer to [Runtime > JSX](https://bun.sh/docs/runtime/jsx) for complete documentation on configuring JSX.
@@ -0,0 +1,78 @@
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.
@@ -0,0 +1,79 @@
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
+ ```bash
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
+ ```bash
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
+ ```bash
56
+ git add app.ts bun.lockb 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.js` |
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.
@@ -0,0 +1,52 @@
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
+ ```bash
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).
@@ -0,0 +1,58 @@
1
+ ---
2
+ name: Build an app with SolidStart and Bun
3
+ ---
4
+
5
+ {% callout %}
6
+ SolidStart currently 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 SolidStart app with `create-solid`.
12
+
13
+ ```sh
14
+ $ bun create solid my-app
15
+ create-solid version 0.2.31
16
+
17
+ Welcome to the SolidStart setup wizard!
18
+
19
+ There are definitely bugs and some feature might not work yet.
20
+ If you encounter an issue, have a look at
21
+ https://github.com/solidjs/solid-start/issues and open a new one,
22
+ if it is not already tracked.
23
+
24
+ ✔ Which template do you want to use? › todomvc
25
+ ✔ Server Side Rendering? … yes
26
+ ✔ Use TypeScript? … yes
27
+ cloned solidjs/solid-start#main to /path/to/my-app/.solid-start
28
+ ✔ Copied project files
29
+ ```
30
+
31
+ ---
32
+
33
+ As instructed by the `create-solid` CLI, let's install our dependencies.
34
+
35
+ ```sh
36
+ $ cd my-app
37
+ $ bun install
38
+ ```
39
+
40
+ ---
41
+
42
+ Then run the development server.
43
+
44
+ ```sh
45
+ $ bun run dev
46
+ # or, equivalently
47
+ $ bunx solid-start dev
48
+ ```
49
+
50
+ ---
51
+
52
+ Open [localhost:3000](http://localhost:3000). Any changes you make to `src/routes/index.tsx` will be hot-reloaded automatically.
53
+
54
+ {% image src="https://github.com/oven-sh/bun/assets/3084745/1e8043c4-49d1-498c-9add-c1eaab6c7167" alt="SolidStart demo app" /%}
55
+
56
+ ---
57
+
58
+ Refer to the [SolidStart website](https://start.solidjs.com/getting-started/what-is-solidstart) for complete framework documentation.
@@ -0,0 +1,51 @@
1
+ ---
2
+ name: Server-side render (SSR) a React component
3
+ ---
4
+
5
+ To get started, install the canary version of `react` & `react-dom`:
6
+
7
+ ```sh
8
+ # Any package manager can be used
9
+ $ bun add react@canary react-dom@canary
10
+ ```
11
+
12
+ ---
13
+
14
+ To render a React component to an HTML stream server-side (SSR):
15
+
16
+ ```tsx
17
+ import { renderToReadableStream } from "react-dom/server";
18
+
19
+ function Component(props: { message: string }) {
20
+ return (
21
+ <body>
22
+ <h1>{props.message}</h1>
23
+ </body>
24
+ );
25
+ }
26
+
27
+ const stream = await renderToReadableStream(
28
+ <Component message="Hello from server!" />,
29
+ );
30
+ ```
31
+
32
+ ---
33
+
34
+ Combining this with `Bun.serve()`, we get a simple SSR HTTP server:
35
+
36
+ ```tsx
37
+ Bun.serve({
38
+ async fetch() {
39
+ const stream = await renderToReadableStream(
40
+ <Component message="Hello from server!" />,
41
+ );
42
+ return new Response(stream, {
43
+ headers: { "Content-Type": "text/html" },
44
+ });
45
+ },
46
+ });
47
+ ```
48
+
49
+ ---
50
+
51
+ React `19` and later includes an [SSR optimization](https://github.com/facebook/react/pull/25597) that takes advantage of Bun's "direct" `ReadableStream` implementation. If you run into an error like `export named 'renderToReadableStream' not found`, please make sure to install the canary version of `react` & `react-dom`, or import from `react-dom/server.browser` instead of `react-dom/server`. See [facebook/react#28941](https://github.com/facebook/react/issues/28941) for more information.
@@ -0,0 +1,55 @@
1
+ ---
2
+ name: Build an HTTP server using StricJS and Bun
3
+ ---
4
+
5
+ [StricJS](https://github.com/bunsvr) is a Bun framework for building high-performance web applications and APIs.
6
+
7
+ - **Fast** — Stric is one of the fastest Bun frameworks. See [benchmark](https://github.com/bunsvr/benchmark) for more details.
8
+ - **Minimal** — The basic components like `@stricjs/router` and `@stricjs/utils` are under 50kB and require no external dependencies.
9
+ - **Extensible** — Stric includes with a plugin system, dependency injection, and optional optimizations for handling requests.
10
+
11
+ ---
12
+
13
+ Use `bun init` to create an empty project.
14
+
15
+ ```bash
16
+ $ mkdir myapp
17
+ $ cd myapp
18
+ $ bun init
19
+ $ bun add @stricjs/router @stricjs/utils
20
+ ```
21
+
22
+ ---
23
+
24
+ To implement a simple HTTP server with StricJS:
25
+
26
+ ```ts#index.ts
27
+ import { Router } from '@stricjs/router';
28
+
29
+ export default new Router()
30
+ .get('/', () => new Response('Hi'));
31
+ ```
32
+
33
+ ---
34
+
35
+ To serve static files from `/public`:
36
+
37
+ ```ts#index.ts
38
+ import { dir } from '@stricjs/utils';
39
+
40
+ export default new Router()
41
+ .get('/', () => new Response('Hi'))
42
+ .get('/*', dir('./public'));
43
+ ```
44
+
45
+ ---
46
+
47
+ Run the file in watch mode to start the development server.
48
+
49
+ ```bash
50
+ $ bun --watch run index.ts
51
+ ```
52
+
53
+ ---
54
+
55
+ For more info, see Stric's [documentation](https://stricjs.netlify.app).