From 4450d738fa76b1cccdf02b4376270e5da7027aee Mon Sep 17 00:00:00 2001 From: Michael H Date: Sat, 22 Nov 2025 09:06:19 +1100 Subject: [PATCH] docs: more consistency + minor updates (#24764) Co-authored-by: RiskyMH --- README.md | 8 +- docs/bundler/css.mdx | 2 +- docs/bundler/executables.mdx | 6 +- docs/bundler/fullstack.mdx | 6 +- docs/bundler/hot-reloading.mdx | 4 +- docs/bundler/html-static.mdx | 7 +- docs/bundler/index.mdx | 33 ++++--- docs/bundler/loaders.mdx | 4 +- docs/bundler/macros.mdx | 2 +- docs/docs.json | 2 +- docs/feedback.mdx | 14 +-- docs/guides/binary/arraybuffer-to-array.mdx | 2 +- docs/guides/binary/arraybuffer-to-blob.mdx | 2 +- docs/guides/binary/arraybuffer-to-buffer.mdx | 2 +- docs/guides/binary/arraybuffer-to-string.mdx | 2 +- .../binary/arraybuffer-to-typedarray.mdx | 2 +- docs/guides/binary/blob-to-arraybuffer.mdx | 2 +- docs/guides/binary/blob-to-dataview.mdx | 2 +- docs/guides/binary/blob-to-stream.mdx | 2 +- docs/guides/binary/blob-to-string.mdx | 2 +- docs/guides/binary/blob-to-typedarray.mdx | 2 +- docs/guides/binary/buffer-to-arraybuffer.mdx | 2 +- docs/guides/binary/buffer-to-blob.mdx | 2 +- .../binary/buffer-to-readablestream.mdx | 2 +- docs/guides/binary/buffer-to-string.mdx | 2 +- docs/guides/binary/buffer-to-typedarray.mdx | 2 +- docs/guides/binary/dataview-to-string.mdx | 2 +- .../binary/typedarray-to-arraybuffer.mdx | 2 +- docs/guides/binary/typedarray-to-blob.mdx | 2 +- docs/guides/binary/typedarray-to-buffer.mdx | 2 +- docs/guides/binary/typedarray-to-dataview.mdx | 2 +- .../binary/typedarray-to-readablestream.mdx | 2 +- docs/guides/binary/typedarray-to-string.mdx | 2 +- docs/guides/deployment/vercel.mdx | 2 - docs/guides/ecosystem/discordjs.mdx | 4 +- docs/guides/ecosystem/express.mdx | 4 +- docs/guides/ecosystem/mongoose.mdx | 2 +- docs/guides/ecosystem/neon-drizzle.mdx | 4 +- .../ecosystem/neon-serverless-postgres.mdx | 4 +- docs/guides/ecosystem/prisma-postgres.mdx | 2 +- docs/guides/ecosystem/prisma.mdx | 2 +- docs/guides/ecosystem/qwik.mdx | 8 +- docs/guides/ecosystem/sentry.mdx | 4 +- docs/guides/ecosystem/sveltekit.mdx | 2 +- docs/guides/ecosystem/tanstack-start.mdx | 1 - docs/guides/ecosystem/upstash.mdx | 2 +- docs/guides/ecosystem/vite.mdx | 2 +- docs/guides/html-rewriter/extract-links.mdx | 4 +- .../html-rewriter/extract-social-meta.mdx | 2 +- docs/guides/http/file-uploads.mdx | 2 +- docs/guides/http/hot.mdx | 2 +- docs/guides/http/server.mdx | 2 +- docs/guides/http/simple.mdx | 2 +- docs/guides/http/stream-file.mdx | 6 +- docs/guides/http/tls.mdx | 2 +- docs/guides/install/add-dev.mdx | 2 +- docs/guides/install/add-git.mdx | 2 +- docs/guides/install/add-optional.mdx | 2 +- docs/guides/install/add-peer.mdx | 2 +- docs/guides/install/add-tarball.mdx | 2 +- docs/guides/install/add.mdx | 2 +- docs/guides/install/azure-artifacts.mdx | 6 +- docs/guides/install/custom-registry.mdx | 4 +- docs/guides/install/git-diff-bun-lockfile.mdx | 3 +- docs/guides/install/npm-alias.mdx | 2 +- docs/guides/install/registry-scope.mdx | 6 +- docs/guides/install/trusted.mdx | 2 +- docs/guides/install/workspaces.mdx | 2 +- docs/guides/install/yarnlock.mdx | 7 +- docs/guides/process/ctrl-c.mdx | 2 +- docs/guides/process/ipc.mdx | 4 +- docs/guides/process/nanoseconds.mdx | 2 +- docs/guides/process/os-signals.mdx | 2 +- docs/guides/process/spawn-stderr.mdx | 4 +- docs/guides/process/spawn-stdout.mdx | 4 +- docs/guides/process/spawn.mdx | 4 +- docs/guides/process/stdin.mdx | 2 +- docs/guides/read-file/arraybuffer.mdx | 4 +- docs/guides/read-file/buffer.mdx | 2 +- docs/guides/read-file/exists.mdx | 2 +- docs/guides/read-file/mime.mdx | 2 +- docs/guides/read-file/stream.mdx | 2 +- docs/guides/read-file/uint8array.mdx | 2 +- docs/guides/read-file/watch.mdx | 2 +- docs/guides/runtime/cicd.mdx | 2 +- docs/guides/runtime/delete-directory.mdx | 2 +- docs/guides/runtime/delete-file.mdx | 2 +- docs/guides/runtime/import-json.mdx | 2 +- docs/guides/runtime/import-toml.mdx | 2 +- docs/guides/runtime/import-yaml.mdx | 2 +- docs/guides/runtime/read-env.mdx | 2 +- docs/guides/runtime/set-env.mdx | 4 +- docs/guides/runtime/shell.mdx | 2 +- docs/guides/runtime/tsconfig-paths.mdx | 2 +- docs/guides/runtime/typescript.mdx | 2 +- docs/guides/runtime/vscode-debugger.mdx | 3 +- docs/guides/runtime/web-debugger.mdx | 2 +- docs/guides/streams/to-array.mdx | 2 +- docs/guides/streams/to-arraybuffer.mdx | 2 +- docs/guides/streams/to-blob.mdx | 2 +- docs/guides/streams/to-buffer.mdx | 2 +- docs/guides/streams/to-json.mdx | 2 +- docs/guides/streams/to-string.mdx | 2 +- docs/guides/streams/to-typedarray.mdx | 2 +- docs/guides/test/bail.mdx | 2 +- docs/guides/test/concurrent-test-glob.mdx | 7 +- docs/guides/test/coverage-threshold.mdx | 2 +- docs/guides/test/coverage.mdx | 2 +- docs/guides/test/happy-dom.mdx | 2 +- docs/guides/test/migrate-from-jest.mdx | 10 +- docs/guides/test/mock-clock.mdx | 4 +- docs/guides/test/mock-functions.mdx | 2 +- docs/guides/test/rerun-each.mdx | 2 +- docs/guides/test/run-tests.mdx | 4 +- docs/guides/test/skip-tests.mdx | 2 +- docs/guides/test/snapshot.mdx | 4 +- docs/guides/test/spy-on.mdx | 2 +- docs/guides/test/svelte-test.mdx | 6 +- docs/guides/test/testing-library.mdx | 6 +- docs/guides/test/timeout.mdx | 2 +- docs/guides/test/todo-tests.mdx | 2 +- docs/guides/test/update-snapshots.mdx | 2 +- docs/guides/test/watch-mode.mdx | 2 +- docs/guides/util/base64.mdx | 2 +- docs/guides/util/deep-equals.mdx | 6 +- docs/guides/util/deflate.mdx | 2 +- docs/guides/util/entrypoint.mdx | 4 +- docs/guides/util/escape-html.mdx | 2 +- docs/guides/util/file-url-to-path.mdx | 2 +- docs/guides/util/gzip.mdx | 2 +- docs/guides/util/hash-a-password.mdx | 2 +- docs/guides/util/import-meta-dir.mdx | 4 +- docs/guides/util/import-meta-file.mdx | 4 +- docs/guides/util/import-meta-path.mdx | 4 +- docs/guides/util/javascript-uuid.mdx | 4 +- docs/guides/util/main.mdx | 2 +- docs/guides/util/path-to-file-url.mdx | 2 +- docs/guides/util/sleep.mdx | 2 +- docs/guides/util/version.mdx | 2 +- .../util/which-path-to-executable-bin.mdx | 2 +- docs/guides/websocket/context.mdx | 2 +- docs/guides/websocket/simple.mdx | 2 +- docs/guides/write-file/basic.mdx | 4 +- docs/guides/write-file/blob.mdx | 4 +- docs/guides/write-file/cat.mdx | 4 +- docs/guides/write-file/file-cp.mdx | 4 +- docs/guides/write-file/filesink.mdx | 2 +- docs/guides/write-file/response.mdx | 4 +- docs/guides/write-file/stdout.mdx | 4 +- docs/guides/write-file/stream.mdx | 4 +- docs/guides/write-file/unlink.mdx | 2 +- docs/index.mdx | 2 +- docs/installation.mdx | 2 +- docs/normalize-internal-links.js | 1 - docs/pm/bunx.mdx | 4 +- docs/pm/cli/install.mdx | 2 +- docs/pm/cli/link.mdx | 4 +- docs/pm/cli/outdated.mdx | 6 +- docs/pm/workspaces.mdx | 3 +- docs/project/building-windows.mdx | 2 +- docs/project/license.mdx | 2 +- docs/quickstart.mdx | 4 +- docs/runtime/bunfig.mdx | 28 +++++- docs/runtime/c-compiler.mdx | 4 +- docs/runtime/child-process.mdx | 2 +- docs/runtime/cookies.mdx | 38 ++++---- docs/runtime/debugger.mdx | 2 +- docs/runtime/environment-variables.mdx | 12 +-- docs/runtime/http/routing.mdx | 2 +- docs/runtime/http/server.mdx | 10 +- docs/runtime/http/websockets.mdx | 2 +- docs/runtime/index.mdx | 4 +- docs/runtime/module-resolution.mdx | 4 +- docs/runtime/networking/fetch.mdx | 2 +- docs/runtime/nodejs-compat.mdx | 2 +- docs/runtime/s3.mdx | 6 +- docs/runtime/secrets.mdx | 17 ++-- docs/runtime/sql.mdx | 20 ++-- docs/runtime/sqlite.mdx | 19 +++- docs/runtime/templating/create.mdx | 8 +- docs/runtime/transpiler.mdx | 2 +- docs/runtime/utils.mdx | 4 +- docs/runtime/watch-mode.mdx | 2 +- docs/runtime/workers.mdx | 22 +---- docs/snippets/cli/publish.mdx | 4 +- docs/snippets/guides.jsx | 4 + docs/snippets/product-card.mdx | 32 ------- docs/snippets/product-tiles.mdx | 94 ------------------- docs/test/index.mdx | 2 +- docs/test/snapshots.mdx | 6 +- docs/typescript.mdx | 4 +- packages/bun-release/src/npm/install.ts | 2 +- packages/bun-types/.gitignore | 3 +- packages/bun-types/package.json | 3 +- packages/bun-types/scripts/build.ts | 30 +++++- src/bun.js/bindings/v8/CLAUDE.md | 6 +- src/cli.zig | 2 +- src/cli/install.sh | 2 +- src/cli/upgrade_command.zig | 2 +- src/init/rule.md | 6 +- .../PackageManager/CommandLineArguments.zig | 2 +- src/install/windows-shim/bun_shim_impl.zig | 2 +- .../components/Footer.jsx | 6 +- .../react-spa-no-tailwind/components/Hero.jsx | 2 +- test/cli/create/tailwind.tsx | 2 +- 205 files changed, 429 insertions(+), 504 deletions(-) delete mode 100644 docs/snippets/product-card.mdx delete mode 100644 docs/snippets/product-tiles.mdx diff --git a/README.md b/README.md index 3c845722d1..82c0626611 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ Bun supports Linux (x64 & arm64), macOS (x64 & Apple Silicon) and Windows (x64). curl -fsSL https://bun.com/install | bash # on windows -powershell -c "irm bun.com/install.ps1 | iex" +powershell -c "irm bun.sh/install.ps1 | iex" # with npm npm install -g bun @@ -104,13 +104,13 @@ bun upgrade --canary - [File types (Loaders)](https://bun.com/docs/runtime/loaders) - [TypeScript](https://bun.com/docs/runtime/typescript) - [JSX](https://bun.com/docs/runtime/jsx) - - [Environment variables](https://bun.com/docs/runtime/env) + - [Environment variables](https://bun.com/docs/runtime/environment-variables) - [Bun APIs](https://bun.com/docs/runtime/bun-apis) - [Web APIs](https://bun.com/docs/runtime/web-apis) - - [Node.js compatibility](https://bun.com/docs/runtime/nodejs-apis) + - [Node.js compatibility](https://bun.com/docs/runtime/nodejs-compat) - [Single-file executable](https://bun.com/docs/bundler/executables) - [Plugins](https://bun.com/docs/runtime/plugins) - - [Watch mode / Hot Reloading](https://bun.com/docs/runtime/hot) + - [Watch mode / Hot Reloading](https://bun.com/docs/runtime/watch-mode) - [Module resolution](https://bun.com/docs/runtime/modules) - [Auto-install](https://bun.com/docs/runtime/autoimport) - [bunfig.toml](https://bun.com/docs/runtime/bunfig) diff --git a/docs/bundler/css.mdx b/docs/bundler/css.mdx index 730332f173..7a73280b79 100644 --- a/docs/bundler/css.mdx +++ b/docs/bundler/css.mdx @@ -72,7 +72,7 @@ Bun's CSS bundler automatically converts this nested syntax into traditional fla You can also nest media queries and other at-rules inside selectors, eliminating the need to repeat selector patterns: -```css title="styles.css" icon="file-code" +```scss title="styles.css" icon="file-code" .responsive-element { display: block; diff --git a/docs/bundler/executables.mdx b/docs/bundler/executables.mdx index fefa2769e6..71b3386a4b 100644 --- a/docs/bundler/executables.mdx +++ b/docs/bundler/executables.mdx @@ -118,7 +118,7 @@ These constants are embedded directly into your compiled binary at build time, p For comprehensive examples and advanced patterns, see the [Build-time constants - guide](https://bun.com/guides/runtime/build-time-constants). + guide](/guides/runtime/build-time-constants). --- @@ -288,12 +288,12 @@ console.log(`Server running at http://localhost:${server.port}`);

Hello World

- + ``` -```ts app.js icon="file-code" +```ts app.ts icon="file-code" console.log("Hello from the client!"); ``` diff --git a/docs/bundler/fullstack.mdx b/docs/bundler/fullstack.mdx index 937d41d39f..6b108d9866 100644 --- a/docs/bundler/fullstack.mdx +++ b/docs/bundler/fullstack.mdx @@ -632,7 +632,7 @@ const server = serve({ console.log(`πŸš€ Server running on ${server.url}`); ``` -```html title="public/index.html" +```html title="public/index.html" icon="file-code" @@ -757,7 +757,7 @@ export function App() { } ``` -```css title="src/styles.css" +```css title="src/styles.css" icon="file-code" * { margin: 0; padding: 0; @@ -999,7 +999,7 @@ CMD ["bun", "index.js"] ### Environment Variables -```bash title=".env.production" icon="file-code" +```ini title=".env.production" icon="file-code" NODE_ENV=production PORT=3000 DATABASE_URL=postgresql://user:pass@localhost:5432/myapp diff --git a/docs/bundler/hot-reloading.mdx b/docs/bundler/hot-reloading.mdx index 3e82484220..0204191d50 100644 --- a/docs/bundler/hot-reloading.mdx +++ b/docs/bundler/hot-reloading.mdx @@ -9,7 +9,7 @@ Hot Module Replacement (HMR) allows you to update modules in a running applicati ## `import.meta.hot` API Reference -Bun implements a client-side HMR API modeled after [Vite's `import.meta.hot` API](https://vitejs.dev/guide/api-hmr.html). It can be checked for with `if (import.meta.hot)`, tree-shaking it in production. +Bun implements a client-side HMR API modeled after [Vite's `import.meta.hot` API](https://vite.dev/guide/api-hmr). It can be checked for with `if (import.meta.hot)`, tree-shaking it in production. ```ts title="index.ts" icon="/icons/typescript.svg" if (import.meta.hot) { @@ -144,7 +144,7 @@ Indicates that multiple dependencies' modules can be accepted. This variant acce `import.meta.hot.data` maintains state between module instances during hot replacement, enabling data transfer from previous to new versions. When `import.meta.hot.data` is written into, Bun will also mark this module as capable of self-accepting (equivalent of calling `import.meta.hot.accept()`). -```jsx title="index.ts" icon="/icons/typescript.svg" +```tsx title="index.tsx" icon="/icons/typescript.svg" import { createRoot } from "react-dom/client"; import { App } from "./app"; diff --git a/docs/bundler/html-static.mdx b/docs/bundler/html-static.mdx index 135b7f41ac..5ae8d10653 100644 --- a/docs/bundler/html-static.mdx +++ b/docs/bundler/html-static.mdx @@ -164,7 +164,7 @@ For example: } ``` -```css abc.css +```css abc.css icon="file-code" body { background-color: red; } @@ -174,7 +174,7 @@ body { This outputs: -```css +```css styles.css icon="file-code" body { background-color: red; } @@ -385,7 +385,8 @@ All paths are resolved relative to your HTML file, making it easy to organize yo - Need more configuration options for things like asset handling - Need a way to configure CORS, headers, etc. -If you want to submit a PR, most of the code is [here](https://github.com/oven-sh/bun/blob/main/src/bun.js/api/bun/html-rewriter.ts). You could even copy paste that file into your project and use it as a starting point. +{/* todo: find the correct link to link to as this 404's and there isn't any similar files */} +{/* If you want to submit a PR, most of the code is [here](https://github.com/oven-sh/bun/blob/main/src/bun.js/api/bun/html-rewriter.ts). You could even copy paste that file into your project and use it as a starting point. */} diff --git a/docs/bundler/index.mdx b/docs/bundler/index.mdx index ce0736b746..5a6743318c 100644 --- a/docs/bundler/index.mdx +++ b/docs/bundler/index.mdx @@ -106,7 +106,7 @@ For each file specified in `entrypoints`, Bun will generate a new bundle. This b The contents of `out/index.js` will look something like this: -```ts title="out/index.js" icon="/icons/javascript.svg" +```js title="out/index.js" icon="/icons/javascript.svg" // out/index.js // ... // ~20k lines of code @@ -527,7 +527,7 @@ Injects environment variables into the bundled output by converting `process.env For the input below: -```ts title="input.js" icon="/icons/javascript.svg" +```js title="input.js" icon="/icons/javascript.svg" // input.js console.log(process.env.FOO); console.log(process.env.BAZ); @@ -535,7 +535,7 @@ console.log(process.env.BAZ); The generated bundle will contain the following code: -```ts title="output.js" icon="/icons/javascript.svg" +```js title="output.js" icon="/icons/javascript.svg" // output.js console.log("bar"); console.log("123"); @@ -580,7 +580,7 @@ console.log(process.env.BAZ); The generated bundle will contain the following code: -```ts title="output.js" icon="/icons/javascript.svg" +```js title="output.js" icon="/icons/javascript.svg" console.log(process.env.FOO); console.log("https://acme.com"); console.log(process.env.BAZ); @@ -722,7 +722,7 @@ Normally, bundling `index.tsx` would generate a bundle containing the entire sou The generated bundle will look something like this: -```ts title="out/index.js" icon="/icons/javascript.svg" +```js title="out/index.js" icon="/icons/javascript.svg" import { z } from "zod"; // ... @@ -1026,7 +1026,7 @@ Setting `publicPath` will prefix all file paths with the specified value. The output file would now look something like this. -```ts title="out/index.js" icon="/icons/javascript.svg" +```js title="out/index.js" icon="/icons/javascript.svg" var logo = "https://cdn.example.com/logo-a7305bdef.svg"; ``` @@ -1356,10 +1356,12 @@ interface BuildConfig { * JSX configuration object for controlling JSX transform behavior */ jsx?: { + runtime?: "automatic" | "classic"; + importSource?: string; factory?: string; fragment?: string; - importSource?: string; - runtime?: "automatic" | "classic"; + sideEffects?: boolean; + development?: boolean; }; naming?: | string @@ -1443,13 +1445,20 @@ interface BuildConfig { drop?: string[]; /** - * When set to `true`, the returned promise rejects with an AggregateError when a build failure happens. - * When set to `false`, the `success` property of the returned object will be `false` when a build failure happens. + * - When set to `true`, the returned promise rejects with an AggregateError when a build failure happens. + * - When set to `false`, returns a {@link BuildOutput} with `{success: false}` * - * This defaults to `false` in Bun 1.1 and will change to `true` in Bun 1.2 - * as most usage of `Bun.build` forgets to check for errors. + * @default true */ throw?: boolean; + + /** + * Custom tsconfig.json file path to use for path resolution. + * Equivalent to `--tsconfig-override` in the CLI. + */ + tsconfig?: string; + + outdir?: string; } interface BuildOutput { diff --git a/docs/bundler/loaders.mdx b/docs/bundler/loaders.mdx index bb55a49675..daa612dc7c 100644 --- a/docs/bundler/loaders.mdx +++ b/docs/bundler/loaders.mdx @@ -312,7 +312,7 @@ The `html` loader processes HTML files and bundles any referenced assets. It wil For example, given this HTML file: -```html title="src/index.html" +```html title="src/index.html" icon="file-code" @@ -325,7 +325,7 @@ For example, given this HTML file: It will output a new HTML file with the bundled assets: -```html title="dist/index.html" +```html title="dist/index.html" icon="file-code" diff --git a/docs/bundler/macros.mdx b/docs/bundler/macros.mdx index e4cfffeb37..23dd41c802 100644 --- a/docs/bundler/macros.mdx +++ b/docs/bundler/macros.mdx @@ -87,7 +87,7 @@ macro(); When shipping a library containing a macro to npm or another package registry, use the `"macro"` export condition to provide a special version of your package exclusively for the macro environment. -```json title="package.json" icon="file-code" +```json title="package.json" icon="file-json" { "name": "my-package", "exports": { diff --git a/docs/docs.json b/docs/docs.json index 2ad4eae8a2..4bec7db641 100644 --- a/docs/docs.json +++ b/docs/docs.json @@ -456,7 +456,6 @@ "pages": [ "/guides/test/run-tests", "/guides/test/watch-mode", - "/guides/test/concurrent-test-glob", "/guides/test/migrate-from-jest", "/guides/test/mock-functions", "/guides/test/spy-on", @@ -465,6 +464,7 @@ "/guides/test/update-snapshots", "/guides/test/coverage", "/guides/test/coverage-threshold", + "/guides/test/concurrent-test-glob", "/guides/test/skip-tests", "/guides/test/todo-tests", "/guides/test/timeout", diff --git a/docs/feedback.mdx b/docs/feedback.mdx index 710cb89b7a..fdb2f298b6 100644 --- a/docs/feedback.mdx +++ b/docs/feedback.mdx @@ -4,13 +4,9 @@ description: Share feedback, bug reports, and feature requests mode: center --- -import Feedback from "/snippets/cli/feedback.mdx"; - Whether you've found a bug, have a performance issue, or just want to suggest an improvement, here's how you can open a helpful issue: - - For general questions, please join our [Discord](https://discord.com/invite/CXdq2DP29u). - +For general questions, please join our [Discord](https://bun.com/discord). ## Reporting Issues @@ -56,9 +52,7 @@ Whether you've found a bug, have a performance issue, or just want to suggest an - For MacOS and Linux: copy the output of `uname -mprs` - For Windows: copy the output of this command in the powershell console: - ```powershell - "$([Environment]::OSVersion | ForEach-Object VersionString) $(if ([Environment]::Is64BitOperatingSystem) { "x64" } else { "x86" })" - ``` + `"$([Environment]::OSVersion | ForEach-Object VersionString) $(if ([Environment]::Is64BitOperatingSystem) { "x64" } else { "x86" })"` @@ -79,7 +73,3 @@ echo "please document X" | bun feedback --email you@example.com ``` You can provide feedback as text arguments, file paths, or piped input. - ---- - - diff --git a/docs/guides/binary/arraybuffer-to-array.mdx b/docs/guides/binary/arraybuffer-to-array.mdx index 6141431fae..bce60089f6 100644 --- a/docs/guides/binary/arraybuffer-to-array.mdx +++ b/docs/guides/binary/arraybuffer-to-array.mdx @@ -26,4 +26,4 @@ const regularArr = Array.from(uintArr); --- -See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun. +See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun. diff --git a/docs/guides/binary/arraybuffer-to-blob.mdx b/docs/guides/binary/arraybuffer-to-blob.mdx index d3b4bef160..74c59f3dae 100644 --- a/docs/guides/binary/arraybuffer-to-blob.mdx +++ b/docs/guides/binary/arraybuffer-to-blob.mdx @@ -23,4 +23,4 @@ blob.type; // => "application/octet-stream" --- -See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun. +See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun. diff --git a/docs/guides/binary/arraybuffer-to-buffer.mdx b/docs/guides/binary/arraybuffer-to-buffer.mdx index ba448c7456..b2c6f282a4 100644 --- a/docs/guides/binary/arraybuffer-to-buffer.mdx +++ b/docs/guides/binary/arraybuffer-to-buffer.mdx @@ -24,4 +24,4 @@ const nodeBuffer = Buffer.from(arrBuffer, 0, 16); // view first 16 bytes --- -See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun. +See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun. diff --git a/docs/guides/binary/arraybuffer-to-string.mdx b/docs/guides/binary/arraybuffer-to-string.mdx index 67d8559f93..d488baa515 100644 --- a/docs/guides/binary/arraybuffer-to-string.mdx +++ b/docs/guides/binary/arraybuffer-to-string.mdx @@ -14,4 +14,4 @@ const str = decoder.decode(buf); --- -See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun. +See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun. diff --git a/docs/guides/binary/arraybuffer-to-typedarray.mdx b/docs/guides/binary/arraybuffer-to-typedarray.mdx index 194c26c05b..9293568b5e 100644 --- a/docs/guides/binary/arraybuffer-to-typedarray.mdx +++ b/docs/guides/binary/arraybuffer-to-typedarray.mdx @@ -38,4 +38,4 @@ const arr = new Uint8Array(buffer, 0, 16); // view first 16 bytes --- -See [Docs > API > Utils](https://bun.com/docs/api/utils) for more useful utilities. +See [Docs > API > Utils](/runtime/utils) for more useful utilities. diff --git a/docs/guides/binary/blob-to-arraybuffer.mdx b/docs/guides/binary/blob-to-arraybuffer.mdx index 6edfa274c1..d4e5edfaba 100644 --- a/docs/guides/binary/blob-to-arraybuffer.mdx +++ b/docs/guides/binary/blob-to-arraybuffer.mdx @@ -13,4 +13,4 @@ const buf = await blob.arrayBuffer(); --- -See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun. +See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun. diff --git a/docs/guides/binary/blob-to-dataview.mdx b/docs/guides/binary/blob-to-dataview.mdx index 9b9a77d281..0db0ff26c4 100644 --- a/docs/guides/binary/blob-to-dataview.mdx +++ b/docs/guides/binary/blob-to-dataview.mdx @@ -13,4 +13,4 @@ const arr = new DataView(await blob.arrayBuffer()); --- -See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun. +See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun. diff --git a/docs/guides/binary/blob-to-stream.mdx b/docs/guides/binary/blob-to-stream.mdx index bd433d7fb2..1a746b83b8 100644 --- a/docs/guides/binary/blob-to-stream.mdx +++ b/docs/guides/binary/blob-to-stream.mdx @@ -13,4 +13,4 @@ const stream = await blob.stream(); --- -See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun. +See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun. diff --git a/docs/guides/binary/blob-to-string.mdx b/docs/guides/binary/blob-to-string.mdx index af1bb71bc3..39e1898e41 100644 --- a/docs/guides/binary/blob-to-string.mdx +++ b/docs/guides/binary/blob-to-string.mdx @@ -14,4 +14,4 @@ const str = await blob.text(); --- -See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun. +See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun. diff --git a/docs/guides/binary/blob-to-typedarray.mdx b/docs/guides/binary/blob-to-typedarray.mdx index 80bfb2f4c4..8453e7cb9e 100644 --- a/docs/guides/binary/blob-to-typedarray.mdx +++ b/docs/guides/binary/blob-to-typedarray.mdx @@ -13,4 +13,4 @@ const arr = new Uint8Array(await blob.arrayBuffer()); --- -See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun. +See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun. diff --git a/docs/guides/binary/buffer-to-arraybuffer.mdx b/docs/guides/binary/buffer-to-arraybuffer.mdx index 57c5c13608..549e88f8e8 100644 --- a/docs/guides/binary/buffer-to-arraybuffer.mdx +++ b/docs/guides/binary/buffer-to-arraybuffer.mdx @@ -13,4 +13,4 @@ const arrBuf = nodeBuf.buffer; --- -See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun. +See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun. diff --git a/docs/guides/binary/buffer-to-blob.mdx b/docs/guides/binary/buffer-to-blob.mdx index 325bb457f7..f108221118 100644 --- a/docs/guides/binary/buffer-to-blob.mdx +++ b/docs/guides/binary/buffer-to-blob.mdx @@ -13,4 +13,4 @@ const blob = new Blob([buf]); --- -See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun. +See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun. diff --git a/docs/guides/binary/buffer-to-readablestream.mdx b/docs/guides/binary/buffer-to-readablestream.mdx index 6456dd9792..5765fcf965 100644 --- a/docs/guides/binary/buffer-to-readablestream.mdx +++ b/docs/guides/binary/buffer-to-readablestream.mdx @@ -40,4 +40,4 @@ const stream = blob.stream(1024); --- -See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun. +See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun. diff --git a/docs/guides/binary/buffer-to-string.mdx b/docs/guides/binary/buffer-to-string.mdx index cf761d54a4..32ba943f7e 100644 --- a/docs/guides/binary/buffer-to-string.mdx +++ b/docs/guides/binary/buffer-to-string.mdx @@ -24,4 +24,4 @@ const str = buf.toString("utf8", 0, 5); --- -See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun. +See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun. diff --git a/docs/guides/binary/buffer-to-typedarray.mdx b/docs/guides/binary/buffer-to-typedarray.mdx index 6a9678c2cb..2d34841092 100644 --- a/docs/guides/binary/buffer-to-typedarray.mdx +++ b/docs/guides/binary/buffer-to-typedarray.mdx @@ -13,4 +13,4 @@ buf instanceof Uint8Array; // => true --- -See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun. +See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun. diff --git a/docs/guides/binary/dataview-to-string.mdx b/docs/guides/binary/dataview-to-string.mdx index a1147cf2d6..db2c60051c 100644 --- a/docs/guides/binary/dataview-to-string.mdx +++ b/docs/guides/binary/dataview-to-string.mdx @@ -14,4 +14,4 @@ const str = decoder.decode(dv); --- -See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun. +See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun. diff --git a/docs/guides/binary/typedarray-to-arraybuffer.mdx b/docs/guides/binary/typedarray-to-arraybuffer.mdx index a746d2007f..1be382e5b5 100644 --- a/docs/guides/binary/typedarray-to-arraybuffer.mdx +++ b/docs/guides/binary/typedarray-to-arraybuffer.mdx @@ -24,4 +24,4 @@ arr.byteLength; // => 32 --- -See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun. +See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun. diff --git a/docs/guides/binary/typedarray-to-blob.mdx b/docs/guides/binary/typedarray-to-blob.mdx index 5ac00a6779..afa9c33b1c 100644 --- a/docs/guides/binary/typedarray-to-blob.mdx +++ b/docs/guides/binary/typedarray-to-blob.mdx @@ -15,4 +15,4 @@ console.log(await blob.text()); --- -See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun. +See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun. diff --git a/docs/guides/binary/typedarray-to-buffer.mdx b/docs/guides/binary/typedarray-to-buffer.mdx index daa782a159..e9bdd2054e 100644 --- a/docs/guides/binary/typedarray-to-buffer.mdx +++ b/docs/guides/binary/typedarray-to-buffer.mdx @@ -13,4 +13,4 @@ const buf = Buffer.from(arr); --- -See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun. +See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun. diff --git a/docs/guides/binary/typedarray-to-dataview.mdx b/docs/guides/binary/typedarray-to-dataview.mdx index 3a7603e74b..5822d7ef19 100644 --- a/docs/guides/binary/typedarray-to-dataview.mdx +++ b/docs/guides/binary/typedarray-to-dataview.mdx @@ -13,4 +13,4 @@ const dv = new DataView(arr.buffer, arr.byteOffset, arr.byteLength); --- -See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun. +See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun. diff --git a/docs/guides/binary/typedarray-to-readablestream.mdx b/docs/guides/binary/typedarray-to-readablestream.mdx index dec46b02d9..4871ab1b52 100644 --- a/docs/guides/binary/typedarray-to-readablestream.mdx +++ b/docs/guides/binary/typedarray-to-readablestream.mdx @@ -40,4 +40,4 @@ const stream = blob.stream(1024); --- -See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun. +See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun. diff --git a/docs/guides/binary/typedarray-to-string.mdx b/docs/guides/binary/typedarray-to-string.mdx index 5e6e5726a0..86ab4c4b50 100644 --- a/docs/guides/binary/typedarray-to-string.mdx +++ b/docs/guides/binary/typedarray-to-string.mdx @@ -15,4 +15,4 @@ const str = decoder.decode(arr); --- -See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun. +See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun. diff --git a/docs/guides/deployment/vercel.mdx b/docs/guides/deployment/vercel.mdx index ff4ea58202..8fd052b6ff 100644 --- a/docs/guides/deployment/vercel.mdx +++ b/docs/guides/deployment/vercel.mdx @@ -4,8 +4,6 @@ sidebarTitle: Deploy on Vercel mode: center --- -import { ProductCard } from "/snippets/product-card.mdx"; - [Vercel](https://vercel.com/) is a cloud platform that lets you build, deploy, and scale your apps. diff --git a/docs/guides/ecosystem/discordjs.mdx b/docs/guides/ecosystem/discordjs.mdx index 7ab36e2727..9e5869fa18 100644 --- a/docs/guides/ecosystem/discordjs.mdx +++ b/docs/guides/ecosystem/discordjs.mdx @@ -22,7 +22,7 @@ bun add discord.js --- -Before we go further, we need to go to the [Discord developer portal](https://discord.com/developers/applications), login/signup, create a new _Application_, then create a new _Bot_ within that application. Follow the [official guide](https://discordjs.guide/preparations/setting-up-a-bot-application.html#creating-your-bot) for step-by-step instructions. +Before we go further, we need to go to the [Discord developer portal](https://discord.com/developers/applications), login/signup, create a new _Application_, then create a new _Bot_ within that application. Follow the [official guide](https://discordjs.guide/legacy/preparations/app-setup#creating-your-bot) for step-by-step instructions. --- @@ -30,7 +30,7 @@ Once complete, you'll be presented with your bot's _private key_. Let's add this This is an example token that has already been invalidated. -```txt .env.local icon="settings" +```ini .env.local icon="settings" DISCORD_TOKEN=NzkyNzE1NDU0MTk2MDg4ODQy.X-hvzA.Ovy4MCQywSkoMRRclStW4xAYK7I ``` diff --git a/docs/guides/ecosystem/express.mdx b/docs/guides/ecosystem/express.mdx index e61fe1fbf3..0257f030d6 100644 --- a/docs/guides/ecosystem/express.mdx +++ b/docs/guides/ecosystem/express.mdx @@ -7,8 +7,8 @@ mode: center Express and other major Node.js HTTP libraries should work out of the box. Bun implements the [`node:http`](https://nodejs.org/api/http.html) and [`node:https`](https://nodejs.org/api/https.html) modules that these libraries rely on. - Refer to the [Runtime > Node.js APIs](https://bun.com/docs/runtime/nodejs-apis#node-http) page for more detailed - compatibility information. + Refer to the [Runtime > Node.js APIs](/runtime/nodejs-compat#node-http) page for more detailed compatibility + information. ```sh terminal icon="terminal" diff --git a/docs/guides/ecosystem/mongoose.mdx b/docs/guides/ecosystem/mongoose.mdx index 3555838789..01d3d2fb83 100644 --- a/docs/guides/ecosystem/mongoose.mdx +++ b/docs/guides/ecosystem/mongoose.mdx @@ -89,4 +89,4 @@ Moo! --- -This is a simple introduction to using Mongoose with TypeScript and Bun. As you build your application, refer to the official [MongoDB](https://docs.mongodb.com/) and [Mongoose](https://mongoosejs.com/docs/) sites for complete documentation. +This is a simple introduction to using Mongoose with TypeScript and Bun. As you build your application, refer to the official [MongoDB](https://www.mongodb.com/docs) and [Mongoose](https://mongoosejs.com/docs/) sites for complete documentation. diff --git a/docs/guides/ecosystem/neon-drizzle.mdx b/docs/guides/ecosystem/neon-drizzle.mdx index 5cef85e7f6..f33f7d3b94 100644 --- a/docs/guides/ecosystem/neon-drizzle.mdx +++ b/docs/guides/ecosystem/neon-drizzle.mdx @@ -20,7 +20,7 @@ bun add -D drizzle-kit Create a `.env.local` file and add your [Neon Postgres connection string](https://neon.tech/docs/connect/connect-from-any-app) to it. -```txt .env.local icon="settings" +```ini .env.local icon="settings" DATABASE_URL=postgresql://usertitle:password@ep-adj-noun-guid.us-east-1.aws.neon.tech/neondb?sslmode=require ``` @@ -33,7 +33,7 @@ import { neon } from "@neondatabase/serverless"; import { drizzle } from "drizzle-orm/neon-http"; // Bun automatically loads the DATABASE_URL from .env.local -// Refer to: https://bun.com/docs/runtime/env for more information +// Refer to: https://bun.com/docs/runtime/environment-variables for more information const sql = neon(process.env.DATABASE_URL!); export const db = drizzle(sql); diff --git a/docs/guides/ecosystem/neon-serverless-postgres.mdx b/docs/guides/ecosystem/neon-serverless-postgres.mdx index 84cd4d870e..a081f37f6d 100644 --- a/docs/guides/ecosystem/neon-serverless-postgres.mdx +++ b/docs/guides/ecosystem/neon-serverless-postgres.mdx @@ -21,7 +21,7 @@ bun add @neondatabase/serverless Create a `.env.local` file and add your [Neon Postgres connection string](https://neon.tech/docs/connect/connect-from-any-app) to it. -```sh .env.local icon="settings" +```ini .env.local icon="settings" DATABASE_URL=postgresql://usertitle:password@ep-adj-noun-guid.us-east-1.aws.neon.tech/neondb?sslmode=require ``` @@ -33,7 +33,7 @@ Paste the following code into your project's `index.ts` file. import { neon } from "@neondatabase/serverless"; // Bun automatically loads the DATABASE_URL from .env.local -// Refer to: https://bun.com/docs/runtime/env for more information +// Refer to: https://bun.com/docs/runtime/environment-variables for more information const sql = neon(process.env.DATABASE_URL); const rows = await sql`SELECT version()`; diff --git a/docs/guides/ecosystem/prisma-postgres.mdx b/docs/guides/ecosystem/prisma-postgres.mdx index d8bc15ca45..fb0133e30f 100644 --- a/docs/guides/ecosystem/prisma-postgres.mdx +++ b/docs/guides/ecosystem/prisma-postgres.mdx @@ -62,7 +62,7 @@ mode: center Set up your Postgres database URL in the `.env` file. - ```env .env icon="settings" + ```ini .env icon="settings" DATABASE_URL="postgresql://username:password@localhost:5432/mydb?schema=public" ``` diff --git a/docs/guides/ecosystem/prisma.mdx b/docs/guides/ecosystem/prisma.mdx index a762159423..f586b654a4 100644 --- a/docs/guides/ecosystem/prisma.mdx +++ b/docs/guides/ecosystem/prisma.mdx @@ -161,4 +161,4 @@ mode: center --- -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. +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/orm/prisma-client) as you continue to develop your application. diff --git a/docs/guides/ecosystem/qwik.mdx b/docs/guides/ecosystem/qwik.mdx index 3a5f38695c..1c3cdd8192 100644 --- a/docs/guides/ecosystem/qwik.mdx +++ b/docs/guides/ecosystem/qwik.mdx @@ -65,14 +65,14 @@ bun create qwik β”‚ bun qwik add β”‚ β”‚ β”‚ β”‚ Relevant docs: β”‚ -β”‚ https://qwik.builder.io/docs/getting-started/ β”‚ +β”‚ https://qwik.dev/docs/getting-started/ β”‚ β”‚ β”‚ β”‚ Questions? Start the conversation at: β”‚ -β”‚ https://qwik.builder.io/chat β”‚ +β”‚ https://qwik.dev/chat β”‚ β”‚ https://twitter.com/QwikDev β”‚ β”‚ β”‚ β”‚ Presentations, Podcasts and Videos: β”‚ -β”‚ https://qwik.builder.io/media/ β”‚ +β”‚ https://qwik.dev/media/ β”‚ β”‚ β”‚ β”‚ Next steps: β”‚ β”‚ cd my-app β”‚ @@ -111,4 +111,4 @@ Open [http://localhost:5173](http://localhost:5173) with your browser to see the --- -Refer to the [Qwik docs](https://qwik.builder.io/docs/getting-started/) for complete documentation. +Refer to the [Qwik docs](https://qwik.dev/docs/getting-started/) for complete documentation. diff --git a/docs/guides/ecosystem/sentry.mdx b/docs/guides/ecosystem/sentry.mdx index a7bc1353cd..8f515b9d75 100644 --- a/docs/guides/ecosystem/sentry.mdx +++ b/docs/guides/ecosystem/sentry.mdx @@ -20,7 +20,7 @@ bun add @sentry/bun 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. -```js sentry.ts icon="/icons/typescript.svg" +```ts sentry.ts icon="/icons/typescript.svg" import * as Sentry from "@sentry/bun"; // Ensure to call this before importing any other modules! @@ -37,7 +37,7 @@ Sentry.init({ You can verify that Sentry is working by capturing a test error: -```js sentry.ts icon="/icons/typescript.svg" +```ts sentry.ts icon="/icons/typescript.svg" setTimeout(() => { try { foo(); diff --git a/docs/guides/ecosystem/sveltekit.mdx b/docs/guides/ecosystem/sveltekit.mdx index 9b0d892d38..f886e335ab 100644 --- a/docs/guides/ecosystem/sveltekit.mdx +++ b/docs/guides/ecosystem/sveltekit.mdx @@ -88,7 +88,7 @@ To build for production, you'll need to add the right SvelteKit adapter. Current Now, make the following changes to your `svelte.config.js`. -```ts svelte.config.js icon="file-code" +```js svelte.config.js icon="file-code" import adapter from "@sveltejs/adapter-auto"; // [!code --] import adapter from "svelte-adapter-bun"; // [!code ++] import { vitePreprocess } from "@sveltejs/vite-plugin-svelte"; diff --git a/docs/guides/ecosystem/tanstack-start.mdx b/docs/guides/ecosystem/tanstack-start.mdx index 2071671a36..a84a385627 100644 --- a/docs/guides/ecosystem/tanstack-start.mdx +++ b/docs/guides/ecosystem/tanstack-start.mdx @@ -98,7 +98,6 @@ To host your TanStack Start app, you can use [Nitro](https://nitro.build/) or a } ``` - You do **not** need the custom `start` script when deploying to Vercel. diff --git a/docs/guides/ecosystem/upstash.mdx b/docs/guides/ecosystem/upstash.mdx index d28680b0a9..d7e8f1301e 100644 --- a/docs/guides/ecosystem/upstash.mdx +++ b/docs/guides/ecosystem/upstash.mdx @@ -34,7 +34,7 @@ mode: center Set the `REDIS_URL` environment variable in your `.env` file using the Redis endpoint (not the REST URL): - ```env .env icon="settings" + ```ini .env icon="settings" REDIS_URL=rediss://********@********.upstash.io:6379 ``` diff --git a/docs/guides/ecosystem/vite.mdx b/docs/guides/ecosystem/vite.mdx index 64f3c89f3d..938432b2de 100644 --- a/docs/guides/ecosystem/vite.mdx +++ b/docs/guides/ecosystem/vite.mdx @@ -74,4 +74,4 @@ bunx --bun vite build --- -This is a stripped down guide to get you started with Vite + Bun. For more information, see the [Vite documentation](https://vitejs.dev/guide/). +This is a stripped down guide to get you started with Vite + Bun. For more information, see the [Vite documentation](https://vite.dev/guide/). diff --git a/docs/guides/html-rewriter/extract-links.mdx b/docs/guides/html-rewriter/extract-links.mdx index d019c3e5a4..eabeff55ed 100644 --- a/docs/guides/html-rewriter/extract-links.mdx +++ b/docs/guides/html-rewriter/extract-links.mdx @@ -6,7 +6,7 @@ mode: center ## Extract links from a webpage -Bun's [HTMLRewriter](https://bun.com/docs/api/html-rewriter) API can be used to efficiently extract links from HTML content. It works by chaining together CSS selectors to match the elements, text, and attributes you want to process. This is a simple example of how to extract links from a webpage. You can pass `.transform` a `Response`, `Blob`, or `string`. +Bun's [HTMLRewriter](/runtime/html-rewriter) API can be used to efficiently extract links from HTML content. It works by chaining together CSS selectors to match the elements, text, and attributes you want to process. This is a simple example of how to extract links from a webpage. You can pass `.transform` a `Response`, `Blob`, or `string`. ```ts extract-links.ts icon="/icons/typescript.svg" async function extractLinks(url: string) { @@ -68,4 +68,4 @@ const websiteLinks = await extractLinksFromURL("https://example.com"); --- -See [Docs > API > HTMLRewriter](https://bun.com/docs/api/html-rewriter) for complete documentation on HTML transformation with Bun. +See [Docs > API > HTMLRewriter](/runtime/html-rewriter) for complete documentation on HTML transformation with Bun. diff --git a/docs/guides/html-rewriter/extract-social-meta.mdx b/docs/guides/html-rewriter/extract-social-meta.mdx index 455c75739d..c4d35ed2c6 100644 --- a/docs/guides/html-rewriter/extract-social-meta.mdx +++ b/docs/guides/html-rewriter/extract-social-meta.mdx @@ -6,7 +6,7 @@ mode: center ## Extract social share images and Open Graph tags -Bun's [HTMLRewriter](https://bun.com/docs/api/html-rewriter) API can be used to efficiently extract social share images and Open Graph metadata from HTML content. This is particularly useful for building link preview features, social media cards, or web scrapers. We can use HTMLRewriter to match CSS selectors to HTML elements, text, and attributes we want to process. +Bun's [HTMLRewriter](/runtime/html-rewriter) API can be used to efficiently extract social share images and Open Graph metadata from HTML content. This is particularly useful for building link preview features, social media cards, or web scrapers. We can use HTMLRewriter to match CSS selectors to HTML elements, text, and attributes we want to process. ```ts extract-social-meta.ts icon="/icons/typescript.svg" interface SocialMetadata { diff --git a/docs/guides/http/file-uploads.mdx b/docs/guides/http/file-uploads.mdx index 787487039f..1741914a79 100644 --- a/docs/guides/http/file-uploads.mdx +++ b/docs/guides/http/file-uploads.mdx @@ -63,7 +63,7 @@ Our form will send a `POST` request to the `/action` endpoint with the form data First we use the [`.formData()`](https://developer.mozilla.org/en-US/docs/Web/API/Request/formData) method on the incoming `Request` to asynchronously parse its contents to a `FormData` instance. Then we can use the [`.get()`](https://developer.mozilla.org/en-US/docs/Web/API/FormData/get) method to extract the value of the `name` and `profilePicture` fields. Here `name` corresponds to a `string` and `profilePicture` is a `Blob`. -Finally, we write the `Blob` to disk using [`Bun.write()`](https://bun.com/docs/api/file-io#writing-files-bun-write). +Finally, we write the `Blob` to disk using [`Bun.write()`](/runtime/file-io#writing-files-bun-write). {/* prettier-ignore */} ```ts index.ts icon="/icons/typescript.svg" diff --git a/docs/guides/http/hot.mdx b/docs/guides/http/hot.mdx index ecc6e04627..fac3d5dcdf 100644 --- a/docs/guides/http/hot.mdx +++ b/docs/guides/http/hot.mdx @@ -4,7 +4,7 @@ sidebarTitle: Hot reload an HTTP server mode: center --- -Bun supports the [`--hot`](https://bun.com/docs/runtime/hot#hot-mode) flag to run a file with hot reloading enabled. When any module or file changes, Bun re-runs the file. +Bun supports the [`--hot`](/runtime/watch-mode#hot-mode) flag to run a file with hot reloading enabled. When any module or file changes, Bun re-runs the file. ```sh terminal icon="terminal" bun --hot run index.ts diff --git a/docs/guides/http/server.mdx b/docs/guides/http/server.mdx index ec75f1635e..efbd1a54fe 100644 --- a/docs/guides/http/server.mdx +++ b/docs/guides/http/server.mdx @@ -6,7 +6,7 @@ mode: center This starts an HTTP server listening on port `3000`. It demonstrates basic routing with a number of common responses and also handles POST data from standard forms or as JSON. -See [`Bun.serve`](https://bun.com/docs/api/http) for details. +See [`Bun.serve`](/runtime/http/server) for details. ```ts server.ts icon="/icons/typescript.svg" const server = Bun.serve({ diff --git a/docs/guides/http/simple.mdx b/docs/guides/http/simple.mdx index 91e862465c..a8e6479c2c 100644 --- a/docs/guides/http/simple.mdx +++ b/docs/guides/http/simple.mdx @@ -6,7 +6,7 @@ mode: center This starts an HTTP server listening on port `3000`. It responds to all requests with a `Response` with status `200` and body `"Welcome to Bun!"`. -See [`Bun.serve`](https://bun.com/docs/api/http) for details. +See [`Bun.serve`](/runtime/http/server) for details. ```ts server.ts icon="/icons/typescript.svg" const server = Bun.serve({ diff --git a/docs/guides/http/stream-file.mdx b/docs/guides/http/stream-file.mdx index b5a31639a2..08cee886a6 100644 --- a/docs/guides/http/stream-file.mdx +++ b/docs/guides/http/stream-file.mdx @@ -4,7 +4,7 @@ sidebarTitle: Stream file response mode: center --- -This snippet reads a file from disk using [`Bun.file()`](https://bun.com/docs/api/file-io#reading-files-bun-file). This returns a `BunFile` instance, which can be passed directly into the `new Response` constructor. +This snippet reads a file from disk using [`Bun.file()`](/runtime/file-io#reading-files-bun-file). This returns a `BunFile` instance, which can be passed directly into the `new Response` constructor. ```ts server.ts icon="/icons/typescript.svg" const path = "/path/to/file.txt"; @@ -32,7 +32,7 @@ new Response(Bun.file("./img.png")).headers.get("Content-Type"); --- -Putting it all together with [`Bun.serve()`](https://bun.com/docs/api/http#bun-serve). +Putting it all together with [`Bun.serve()`](/runtime/http/server). ```ts server.ts icon="/icons/typescript.svg" // static file server @@ -47,4 +47,4 @@ Bun.serve({ --- -See [Docs > API > File I/O](https://bun.com/docs/api/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`. +See [Docs > API > File I/O](/runtime/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`. diff --git a/docs/guides/http/tls.mdx b/docs/guides/http/tls.mdx index 14bb44c447..e0ffbc3b15 100644 --- a/docs/guides/http/tls.mdx +++ b/docs/guides/http/tls.mdx @@ -4,7 +4,7 @@ sidebarTitle: Configure TLS mode: center --- -Set the `tls` key to configure TLS. Both `key` and `cert` are required. The `key` should be the contents of your private key; `cert` should be the contents of your issued certificate. Use [`Bun.file()`](https://bun.com/docs/api/file-io#reading-files-bun-file) to read the contents. +Set the `tls` key to configure TLS. Both `key` and `cert` are required. The `key` should be the contents of your private key; `cert` should be the contents of your issued certificate. Use [`Bun.file()`](/runtime/file-io#reading-files-bun-file) to read the contents. ```ts server.ts icon="/icons/typescript.svg" const server = Bun.serve({ diff --git a/docs/guides/install/add-dev.mdx b/docs/guides/install/add-dev.mdx index 7e0a501f91..c9bf2f8e78 100644 --- a/docs/guides/install/add-dev.mdx +++ b/docs/guides/install/add-dev.mdx @@ -25,4 +25,4 @@ This will add the package to `devDependencies` in `package.json`. --- -See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager. +See [Docs > Package manager](/pm/cli/install) for complete documentation of Bun's package manager. diff --git a/docs/guides/install/add-git.mdx b/docs/guides/install/add-git.mdx index 7f8f3c8d81..882e67aba8 100644 --- a/docs/guides/install/add-git.mdx +++ b/docs/guides/install/add-git.mdx @@ -37,4 +37,4 @@ bun add github:colinhacks/zod --- -See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager. +See [Docs > Package manager](/pm/cli/install) for complete documentation of Bun's package manager. diff --git a/docs/guides/install/add-optional.mdx b/docs/guides/install/add-optional.mdx index 568ebeba4e..d1a4fd8214 100644 --- a/docs/guides/install/add-optional.mdx +++ b/docs/guides/install/add-optional.mdx @@ -24,4 +24,4 @@ This will add the package to `optionalDependencies` in `package.json`. --- -See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager. +See [Docs > Package manager](/pm/cli/install) for complete documentation of Bun's package manager. diff --git a/docs/guides/install/add-peer.mdx b/docs/guides/install/add-peer.mdx index e50980a74f..d2e55f517f 100644 --- a/docs/guides/install/add-peer.mdx +++ b/docs/guides/install/add-peer.mdx @@ -42,4 +42,4 @@ Running `bun install` will install peer dependencies by default, unless marked o --- -See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager. +See [Docs > Package manager](/pm/cli/install) for complete documentation of Bun's package manager. diff --git a/docs/guides/install/add-tarball.mdx b/docs/guides/install/add-tarball.mdx index 36abdd66b0..1165b404e1 100644 --- a/docs/guides/install/add-tarball.mdx +++ b/docs/guides/install/add-tarball.mdx @@ -32,4 +32,4 @@ import { z } from "zod"; --- -See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager. +See [Docs > Package manager](/pm/cli/install) for complete documentation of Bun's package manager. diff --git a/docs/guides/install/add.mdx b/docs/guides/install/add.mdx index bb69bd2753..f9d2a81201 100644 --- a/docs/guides/install/add.mdx +++ b/docs/guides/install/add.mdx @@ -41,4 +41,4 @@ bun add zod@next --- -See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager. +See [Docs > Package manager](/pm/cli/install) for complete documentation of Bun's package manager. diff --git a/docs/guides/install/azure-artifacts.mdx b/docs/guides/install/azure-artifacts.mdx index 9ec522f0c1..2e4d703dbb 100644 --- a/docs/guides/install/azure-artifacts.mdx +++ b/docs/guides/install/azure-artifacts.mdx @@ -31,9 +31,9 @@ password = "$NPM_PASSWORD" --- -Then assign your Azure Personal Access Token to the `NPM_PASSWORD` environment variable. Bun [automatically reads](https://bun.com/docs/runtime/env) `.env` files, so create a file called `.env` in your project root. There is no need to base-64 encode this token! Bun will do this for you. +Then assign your Azure Personal Access Token to the `NPM_PASSWORD` environment variable. Bun [automatically reads](/runtime/environment-variables) `.env` files, so create a file called `.env` in your project root. There is no need to base-64 encode this token! Bun will do this for you. -```txt .env icon="settings" +```ini .env icon="settings" NPM_PASSWORD= ``` @@ -43,7 +43,7 @@ NPM_PASSWORD= --- -To configure Azure Artifacts without `bunfig.toml`, you can set the `NPM_CONFIG_REGISTRY` environment variable. The URL should include `:username` and `:_password` as query parameters. Replace `` and `` with the apprropriate values. +To configure Azure Artifacts without `bunfig.toml`, you can set the `NPM_CONFIG_REGISTRY` environment variable. The URL should include `:username` and `:_password` as query parameters. Replace `` and `` with the appropriate values. ```bash terminal icon="terminal" NPM_CONFIG_REGISTRY=https://pkgs.dev.azure.com/my-azure-artifacts-user/_packaging/my-azure-artifacts-user/npm/registry/:username=:_password= diff --git a/docs/guides/install/custom-registry.mdx b/docs/guides/install/custom-registry.mdx index ce5cd1426b..c5d2e56e7f 100644 --- a/docs/guides/install/custom-registry.mdx +++ b/docs/guides/install/custom-registry.mdx @@ -20,7 +20,7 @@ registry = "https://usertitle:password@registry.npmjs.org" --- -Your `bunfig.toml` can reference environment variables. Bun automatically loads environment variables from `.env.local`, `.env.[NODE_ENV]`, and `.env`. See [Docs > Environment variables](https://bun.com/docs/runtime/env) for more information. +Your `bunfig.toml` can reference environment variables. Bun automatically loads environment variables from `.env.local`, `.env.[NODE_ENV]`, and `.env`. See [Docs > Environment variables](/runtime/environment-variables) for more information. ```toml bunfig.toml icon="settings" [install] @@ -29,4 +29,4 @@ registry = { url = "https://registry.npmjs.org", token = "$npm_token" } --- -See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager. +See [Docs > Package manager](/pm/cli/install) for complete documentation of Bun's package manager. diff --git a/docs/guides/install/git-diff-bun-lockfile.mdx b/docs/guides/install/git-diff-bun-lockfile.mdx index b92fe38035..016aa9705f 100644 --- a/docs/guides/install/git-diff-bun-lockfile.mdx +++ b/docs/guides/install/git-diff-bun-lockfile.mdx @@ -6,7 +6,8 @@ mode: center Bun v1.1.39 introduced `bun.lock`, a JSONC formatted lockfile. `bun.lock` is human-readable and git-diffable without - configuration, at no cost to performance. [**Learn more.**](https://bun.com/docs/install/lockfile#text-based-lockfile) + configuration, at no cost to performance. In 1.2.0+ it is the default format used for new projects. [**Learn + more.**](/pm/lockfile#text-based-lockfile) --- diff --git a/docs/guides/install/npm-alias.mdx b/docs/guides/install/npm-alias.mdx index e6201aeb4c..6639db6396 100644 --- a/docs/guides/install/npm-alias.mdx +++ b/docs/guides/install/npm-alias.mdx @@ -22,4 +22,4 @@ z.string(); --- -See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager. +See [Docs > Package manager](/pm/cli/install) for complete documentation of Bun's package manager. diff --git a/docs/guides/install/registry-scope.mdx b/docs/guides/install/registry-scope.mdx index 1c9496a0d6..337ca6fd9c 100644 --- a/docs/guides/install/registry-scope.mdx +++ b/docs/guides/install/registry-scope.mdx @@ -4,7 +4,7 @@ sidebarTitle: Configure a scoped registry mode: center --- -Private registries can be configured using either [`.npmrc`](https://bun.com/docs/install/npmrc) or [`bunfig.toml`](https://bun.com/docs/runtime/bunfig#install-registry). While both are supported, we recommend using **bunfig.toml** for enhanced flexibility and Bun-specific options. +Private registries can be configured using either [`.npmrc`](/pm/npmrc) or [`bunfig.toml`](/runtime/bunfig#install-registry). While both are supported, we recommend using **bunfig.toml** for enhanced flexibility and Bun-specific options. To configure a registry for a particular npm scope: @@ -28,7 +28,7 @@ To configure a registry for a particular npm scope: --- -Your `bunfig.toml` can reference environment variables. Bun automatically loads environment variables from `.env.local`, `.env.[NODE_ENV]`, and `.env`. See [Docs > Environment variables](https://bun.com/docs/runtime/env) for more information. +Your `bunfig.toml` can reference environment variables. Bun automatically loads environment variables from `.env.local`, `.env.[NODE_ENV]`, and `.env`. See [Docs > Environment variables](/runtime/environment-variables) for more information. ```toml bunfig.toml icon="settings" [install.scopes] @@ -37,4 +37,4 @@ Your `bunfig.toml` can reference environment variables. Bun automatically loads --- -See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager. +See [Docs > Package manager](/pm/cli/install) for complete documentation of Bun's package manager. diff --git a/docs/guides/install/trusted.mdx b/docs/guides/install/trusted.mdx index 49efb33e5f..7660315003 100644 --- a/docs/guides/install/trusted.mdx +++ b/docs/guides/install/trusted.mdx @@ -47,4 +47,4 @@ bun install --- -See [Docs > Package manager > Trusted dependencies](https://bun.com/docs/install/lifecycle) for complete documentation of trusted dependencies. +See [Docs > Package manager > Trusted dependencies](/pm/lifecycle) for complete documentation of trusted dependencies. diff --git a/docs/guides/install/workspaces.mdx b/docs/guides/install/workspaces.mdx index 6e789d2eb1..7653ee9fa3 100644 --- a/docs/guides/install/workspaces.mdx +++ b/docs/guides/install/workspaces.mdx @@ -67,4 +67,4 @@ bun add zod --- -See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager. +See [Docs > Package manager](/pm/cli/install) for complete documentation of Bun's package manager. diff --git a/docs/guides/install/yarnlock.mdx b/docs/guides/install/yarnlock.mdx index 534033bc1e..c40539ee8d 100644 --- a/docs/guides/install/yarnlock.mdx +++ b/docs/guides/install/yarnlock.mdx @@ -6,12 +6,13 @@ mode: center Bun v1.1.39 introduced `bun.lock`, a JSONC formatted lockfile. `bun.lock` is human-readable and git-diffable without - configuration, at no cost to performance. [**Learn more.**](https://bun.com/docs/install/lockfile#text-based-lockfile) + configuration, at no cost to performance. In 1.2.0+ it is the default format used for new projects. [**Learn + more.**](/pm/lockfile#text-based-lockfile) --- -Use the `--yarn` flag to generate a Yarn-compatible `yarn.lock` file (in addition to `bun.lock`). +Use the `--yarn` flag to generate a Yarn-compatible `yarn.lock` file (in addition to `bun.lock{b}`). ```sh terminal icon="terminal" bun install --yarn @@ -47,4 +48,4 @@ abab@^2.0.6: --- -See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager. +See [Docs > Package manager](/pm/cli/install) for complete documentation of Bun's package manager. diff --git a/docs/guides/process/ctrl-c.mdx b/docs/guides/process/ctrl-c.mdx index cffee3085f..1d000e7a55 100644 --- a/docs/guides/process/ctrl-c.mdx +++ b/docs/guides/process/ctrl-c.mdx @@ -15,4 +15,4 @@ process.on("SIGINT", () => { --- -See [Docs > API > Utils](https://bun.com/docs/api/utils) for more useful utilities. +See [Docs > API > Utils](/runtime/utils) for more useful utilities. diff --git a/docs/guides/process/ipc.mdx b/docs/guides/process/ipc.mdx index 1df59fcb04..6a9b15de41 100644 --- a/docs/guides/process/ipc.mdx +++ b/docs/guides/process/ipc.mdx @@ -4,7 +4,7 @@ sidebarTitle: Spawn a child process and communicate using IPC mode: center --- -Use [`Bun.spawn()`](https://bun.com/docs/api/spawn) to spawn a child process. When spawning a second `bun` process, you can open a direct inter-process communication (IPC) channel between the two processes. +Use [`Bun.spawn()`](/runtime/child-process) to spawn a child process. When spawning a second `bun` process, you can open a direct inter-process communication (IPC) channel between the two processes. This API is only compatible with other `bun` processes. Use `process.execPath` to get a path to the currently running @@ -66,4 +66,4 @@ process.send({ message: "Hello from child as object" }); --- -See [Docs > API > Child processes](https://bun.com/docs/api/spawn) for complete documentation. +See [Docs > API > Child processes](/runtime/child-process) for complete documentation. diff --git a/docs/guides/process/nanoseconds.mdx b/docs/guides/process/nanoseconds.mdx index 8f974a84fb..74a677b487 100644 --- a/docs/guides/process/nanoseconds.mdx +++ b/docs/guides/process/nanoseconds.mdx @@ -12,4 +12,4 @@ Bun.nanoseconds(); --- -See [Docs > API > Utils](https://bun.com/docs/api/utils) for more useful utilities. +See [Docs > API > Utils](/runtime/utils) for more useful utilities. diff --git a/docs/guides/process/os-signals.mdx b/docs/guides/process/os-signals.mdx index eff7d3f0ab..b124911ac3 100644 --- a/docs/guides/process/os-signals.mdx +++ b/docs/guides/process/os-signals.mdx @@ -38,4 +38,4 @@ process.on("exit", code => { --- -See [Docs > API > Utils](https://bun.com/docs/api/utils) for more useful utilities. +See [Docs > API > Utils](/runtime/utils) for more useful utilities. diff --git a/docs/guides/process/spawn-stderr.mdx b/docs/guides/process/spawn-stderr.mdx index cadfdf0f13..73155ecbfc 100644 --- a/docs/guides/process/spawn-stderr.mdx +++ b/docs/guides/process/spawn-stderr.mdx @@ -4,7 +4,7 @@ sidebarTitle: Read stderr mode: center --- -When using [`Bun.spawn()`](https://bun.com/docs/api/spawn), the child process inherits the `stderr` of the spawning process. If instead you'd prefer to read and handle `stderr`, set the `stderr` option to `"pipe"`. +When using [`Bun.spawn()`](/runtime/child-process), the child process inherits the `stderr` of the spawning process. If instead you'd prefer to read and handle `stderr`, set the `stderr` option to `"pipe"`. ```ts const proc = Bun.spawn(["echo", "hello"], { @@ -31,4 +31,4 @@ if (errors) { --- -See [Docs > API > Child processes](https://bun.com/docs/api/spawn) for complete documentation. +See [Docs > API > Child processes](/runtime/child-process) for complete documentation. diff --git a/docs/guides/process/spawn-stdout.mdx b/docs/guides/process/spawn-stdout.mdx index ab64f2a2cf..0b84fe89fc 100644 --- a/docs/guides/process/spawn-stdout.mdx +++ b/docs/guides/process/spawn-stdout.mdx @@ -4,7 +4,7 @@ sidebarTitle: Read stdout mode: center --- -When using [`Bun.spawn()`](https://bun.com/docs/api/spawn), the `stdout` of the child process can be consumed as a `ReadableStream` via `proc.stdout`. +When using [`Bun.spawn()`](/runtime/child-process), the `stdout` of the child process can be consumed as a `ReadableStream` via `proc.stdout`. ```ts const proc = Bun.spawn(["echo", "hello"]); @@ -25,4 +25,4 @@ const proc = Bun.spawn(["echo", "hello"], { --- -See [Docs > API > Child processes](https://bun.com/docs/api/spawn) for complete documentation. +See [Docs > API > Child processes](/runtime/child-process) for complete documentation. diff --git a/docs/guides/process/spawn.mdx b/docs/guides/process/spawn.mdx index a03ac5eaea..9a217d19ed 100644 --- a/docs/guides/process/spawn.mdx +++ b/docs/guides/process/spawn.mdx @@ -4,7 +4,7 @@ sidebarTitle: Spawn child process mode: center --- -Use [`Bun.spawn()`](https://bun.com/docs/api/spawn) to spawn a child process. +Use [`Bun.spawn()`](/runtime/child-process) to spawn a child process. ```ts const proc = Bun.spawn(["echo", "hello"]); @@ -40,4 +40,4 @@ output; // => "hello\n" --- -See [Docs > API > Child processes](https://bun.com/docs/api/spawn) for complete documentation. +See [Docs > API > Child processes](/runtime/child-process) for complete documentation. diff --git a/docs/guides/process/stdin.mdx b/docs/guides/process/stdin.mdx index b9fb18f614..d0e132fb9d 100644 --- a/docs/guides/process/stdin.mdx +++ b/docs/guides/process/stdin.mdx @@ -59,4 +59,4 @@ Chunk: hello --- -See [Docs > API > Utils](https://bun.com/docs/api/utils) for more useful utilities. +See [Docs > API > Utils](/runtime/utils) for more useful utilities. diff --git a/docs/guides/read-file/arraybuffer.mdx b/docs/guides/read-file/arraybuffer.mdx index 563ca71d1d..ca37d89524 100644 --- a/docs/guides/read-file/arraybuffer.mdx +++ b/docs/guides/read-file/arraybuffer.mdx @@ -15,7 +15,7 @@ const buffer = await file.arrayBuffer(); --- -The binary content in the `ArrayBuffer` can then be read as a typed array, such as `Int8Array`. For `Uint8Array`, use [`.bytes()`](./uint8array). +The binary content in the `ArrayBuffer` can then be read as a typed array, such as `Int8Array`. For `Uint8Array`, use [`.bytes()`](/guides/read-file/uint8array). ```ts index.ts icon="/icons/typescript.svg" const buffer = await file.arrayBuffer(); @@ -27,4 +27,4 @@ bytes.length; --- -Refer to the [Typed arrays](https://bun.com/docs/api/binary-data#typedarray) docs for more information on working with typed arrays in Bun. +Refer to the [Typed arrays](/runtime/binary-data#typedarray) docs for more information on working with typed arrays in Bun. diff --git a/docs/guides/read-file/buffer.mdx b/docs/guides/read-file/buffer.mdx index 5b24eda0a4..f1f8aad4d4 100644 --- a/docs/guides/read-file/buffer.mdx +++ b/docs/guides/read-file/buffer.mdx @@ -18,4 +18,4 @@ const buffer = Buffer.from(arrbuf); --- -Refer to [Binary data > Buffer](https://bun.com/docs/api/binary-data#buffer) for more information on working with `Buffer` and other binary data formats in Bun. +Refer to [Binary data > Buffer](/runtime/binary-data#buffer) for more information on working with `Buffer` and other binary data formats in Bun. diff --git a/docs/guides/read-file/exists.mdx b/docs/guides/read-file/exists.mdx index 320e659252..787668ff03 100644 --- a/docs/guides/read-file/exists.mdx +++ b/docs/guides/read-file/exists.mdx @@ -15,4 +15,4 @@ await file.exists(); // boolean; --- -Refer to [API > File I/O](https://bun.com/docs/api/file-io) for more information on working with `BunFile`. +Refer to [API > File I/O](/runtime/file-io) for more information on working with `BunFile`. diff --git a/docs/guides/read-file/mime.mdx b/docs/guides/read-file/mime.mdx index c3a369a013..1349d9bbf4 100644 --- a/docs/guides/read-file/mime.mdx +++ b/docs/guides/read-file/mime.mdx @@ -19,4 +19,4 @@ file.type; // image/png --- -Refer to [API > File I/O](https://bun.com/docs/api/file-io) for more information on working with `BunFile`. +Refer to [API > File I/O](/runtime/file-io) for more information on working with `BunFile`. diff --git a/docs/guides/read-file/stream.mdx b/docs/guides/read-file/stream.mdx index 2724ad2f6a..a2542c22a6 100644 --- a/docs/guides/read-file/stream.mdx +++ b/docs/guides/read-file/stream.mdx @@ -25,4 +25,4 @@ for await (const chunk of stream) { --- -Refer to the [Streams](https://bun.com/docs/api/streams) documentation for more information on working with streams in Bun. +Refer to the [Streams](/runtime/streams) documentation for more information on working with streams in Bun. diff --git a/docs/guides/read-file/uint8array.mdx b/docs/guides/read-file/uint8array.mdx index 53c902e682..939aa277f5 100644 --- a/docs/guides/read-file/uint8array.mdx +++ b/docs/guides/read-file/uint8array.mdx @@ -20,4 +20,4 @@ byteArray.length; // length of byteArray --- -Refer to [API > Binary data > Typed arrays](https://bun.com/docs/api/binary-data#typedarray) for more information on working with `Uint8Array` and other binary data formats in Bun. +Refer to [API > Binary data > Typed arrays](/runtime/binary-data#typedarray) for more information on working with `Uint8Array` and other binary data formats in Bun. diff --git a/docs/guides/read-file/watch.mdx b/docs/guides/read-file/watch.mdx index dde7a8c2a1..ef41129bab 100644 --- a/docs/guides/read-file/watch.mdx +++ b/docs/guides/read-file/watch.mdx @@ -63,4 +63,4 @@ process.on("SIGINT", () => { --- -Refer to [API > Binary data > Typed arrays](https://bun.com/docs/api/binary-data#typedarray) for more information on working with `Uint8Array` and other binary data formats in Bun. +Refer to [API > Binary data > Typed arrays](/runtime/binary-data#typedarray) for more information on working with `Uint8Array` and other binary data formats in Bun. diff --git a/docs/guides/runtime/cicd.mdx b/docs/guides/runtime/cicd.mdx index a4aae4f126..1fc0786640 100644 --- a/docs/guides/runtime/cicd.mdx +++ b/docs/guides/runtime/cicd.mdx @@ -37,7 +37,7 @@ jobs: # ... - uses: oven-sh/setup-bun@v2 with: # [!code ++] - bun-version: 1.2.0 # or "latest", "canary", # [!code ++] + bun-version: 1.3.2 # or "latest", "canary", # [!code ++] ``` --- diff --git a/docs/guides/runtime/delete-directory.mdx b/docs/guides/runtime/delete-directory.mdx index bcc8055051..460bf8c3ed 100644 --- a/docs/guides/runtime/delete-directory.mdx +++ b/docs/guides/runtime/delete-directory.mdx @@ -36,4 +36,4 @@ try { --- -See [Docs > API > FileSystem](https://bun.com/docs/api/file-io) for more filesystem operations. +See [Docs > API > FileSystem](/runtime/file-io) for more filesystem operations. diff --git a/docs/guides/runtime/delete-file.mdx b/docs/guides/runtime/delete-file.mdx index e8e24390e5..a3aabea4fc 100644 --- a/docs/guides/runtime/delete-file.mdx +++ b/docs/guides/runtime/delete-file.mdx @@ -18,4 +18,4 @@ const exists = await file.exists(); --- -See [Docs > API > FileSystem](https://bun.com/docs/api/file-io) for more filesystem operations. +See [Docs > API > FileSystem](/runtime/file-io) for more filesystem operations. diff --git a/docs/guides/runtime/import-json.mdx b/docs/guides/runtime/import-json.mdx index 1ed290a601..3ebdb20612 100644 --- a/docs/guides/runtime/import-json.mdx +++ b/docs/guides/runtime/import-json.mdx @@ -43,4 +43,4 @@ data.author.name; // => "John Dough" --- -See [Docs > Runtime > TypeScript](https://bun.com/docs/runtime/typescript) for more information on using TypeScript with Bun. +See [Docs > Runtime > TypeScript](/runtime/typescript) for more information on using TypeScript with Bun. diff --git a/docs/guides/runtime/import-toml.mdx b/docs/guides/runtime/import-toml.mdx index 991e12e049..3976b7e226 100644 --- a/docs/guides/runtime/import-toml.mdx +++ b/docs/guides/runtime/import-toml.mdx @@ -29,4 +29,4 @@ data.author.name; // => "John Dough" --- -See [Docs > Runtime > TypeScript](https://bun.com/docs/runtime/typescript) for more information on using TypeScript with Bun. +See [Docs > Runtime > TypeScript](/runtime/typescript) for more information on using TypeScript with Bun. diff --git a/docs/guides/runtime/import-yaml.mdx b/docs/guides/runtime/import-yaml.mdx index e4ff38155b..c9e7a036ad 100644 --- a/docs/guides/runtime/import-yaml.mdx +++ b/docs/guides/runtime/import-yaml.mdx @@ -101,4 +101,4 @@ export = contents; --- -See [Docs > API > YAML](https://bun.com/docs/api/yaml) for complete documentation on YAML support in Bun. +See [Docs > API > YAML](/runtime/yaml) for complete documentation on YAML support in Bun. diff --git a/docs/guides/runtime/read-env.mdx b/docs/guides/runtime/read-env.mdx index 7e3294e246..0f8c828292 100644 --- a/docs/guides/runtime/read-env.mdx +++ b/docs/guides/runtime/read-env.mdx @@ -34,4 +34,4 @@ FOOBAR=aaaaaa --- -See [Docs > Runtime > Environment variables](https://bun.com/docs/runtime/env) for more information on using environment variables with Bun. +See [Docs > Runtime > Environment variables](/runtime/environment-variables) for more information on using environment variables with Bun. diff --git a/docs/guides/runtime/set-env.mdx b/docs/guides/runtime/set-env.mdx index 27ed10b32c..a374875227 100644 --- a/docs/guides/runtime/set-env.mdx +++ b/docs/guides/runtime/set-env.mdx @@ -21,7 +21,7 @@ Bun reads the following files automatically (listed in order of increasing prece - `.env.production`, `.env.development`, `.env.test` (depending on value of `NODE_ENV`) - `.env.local` (not loaded when `NODE_ENV=test`) -```txt .env icon="settings" +```ini .env icon="settings" FOO=hello BAR=world ``` @@ -48,4 +48,4 @@ $env:FOO="helloworld"; bun run dev --- -See [Docs > Runtime > Environment variables](https://bun.com/docs/runtime/env) for more information on using environment variables with Bun. +See [Docs > Runtime > Environment variables](/runtime/environment-variables) for more information on using environment variables with Bun. diff --git a/docs/guides/runtime/shell.mdx b/docs/guides/runtime/shell.mdx index b845a625a5..723aa3fa8e 100644 --- a/docs/guides/runtime/shell.mdx +++ b/docs/guides/runtime/shell.mdx @@ -39,4 +39,4 @@ for await (const line of $`ls -l`.lines()) { --- -See [Docs > API > Shell](https://bun.com/docs/runtime/shell) for complete documentation. +See [Docs > API > Shell](/runtime/shell) for complete documentation. diff --git a/docs/guides/runtime/tsconfig-paths.mdx b/docs/guides/runtime/tsconfig-paths.mdx index 6c102d483b..5381084c19 100644 --- a/docs/guides/runtime/tsconfig-paths.mdx +++ b/docs/guides/runtime/tsconfig-paths.mdx @@ -28,4 +28,4 @@ import { Button } from "@components/Button"; // imports from "./src/components/B --- -See [Docs > Runtime > TypeScript](https://bun.com/docs/runtime/typescript) for more information on using TypeScript with Bun. +See [Docs > Runtime > TypeScript](/runtime/typescript) for more information on using TypeScript with Bun. diff --git a/docs/guides/runtime/typescript.mdx b/docs/guides/runtime/typescript.mdx index 25a52df0c6..811e6b1d9a 100644 --- a/docs/guides/runtime/typescript.mdx +++ b/docs/guides/runtime/typescript.mdx @@ -48,4 +48,4 @@ Below is the full set of recommended `compilerOptions` for a Bun project. With t --- -Refer to [Ecosystem > TypeScript](https://bun.com/docs/runtime/typescript) for a complete guide to TypeScript support in Bun. +Refer to [Ecosystem > TypeScript](/runtime/typescript) for a complete guide to TypeScript support in Bun. diff --git a/docs/guides/runtime/vscode-debugger.mdx b/docs/guides/runtime/vscode-debugger.mdx index d254ee4ab9..fae551616b 100644 --- a/docs/guides/runtime/vscode-debugger.mdx +++ b/docs/guides/runtime/vscode-debugger.mdx @@ -5,8 +5,7 @@ mode: center --- - VSCode extension support is currently buggy. We recommend the [Web - Debugger](https://bun.com/guides/runtime/web-debugger) for now. + VSCode extension support is currently buggy. We recommend the [Web Debugger](/guides/runtime/web-debugger) for now. Bun speaks the [WebKit Inspector Protocol](https://github.com/oven-sh/bun/blob/main/packages/bun-inspector-protocol/src/protocol/jsc/index.d.ts) so you can debug your code with an interactive debugger. diff --git a/docs/guides/runtime/web-debugger.mdx b/docs/guides/runtime/web-debugger.mdx index 46cc4d7e63..36a63301bc 100644 --- a/docs/guides/runtime/web-debugger.mdx +++ b/docs/guides/runtime/web-debugger.mdx @@ -4,7 +4,7 @@ sidebarTitle: Web debugger mode: center --- -Bun speaks the [WebKit Inspector Protocol](https://github.com/oven-sh/bun/blob/main/packages/bun-vscode/types/jsc.d.ts). To enable debugging when running code with Bun, use the `--inspect` flag. For demonstration purposes, consider the following simple web server. +Bun speaks the [WebKit Inspector Protocol](https://github.com/oven-sh/bun/blob/main/packages/bun-inspector-protocol/src/protocol/jsc/index.d.ts). To enable debugging when running code with Bun, use the `--inspect` flag. For demonstration purposes, consider the following simple web server. ```ts server.ts icon="/icons/typescript.svg" Bun.serve({ diff --git a/docs/guides/streams/to-array.mdx b/docs/guides/streams/to-array.mdx index 3fc1547231..ff9134696d 100644 --- a/docs/guides/streams/to-array.mdx +++ b/docs/guides/streams/to-array.mdx @@ -13,4 +13,4 @@ const str = await Bun.readableStreamToArray(stream); --- -See [Docs > API > Utils](https://bun.com/docs/api/utils#bun-readablestreamto) for documentation on Bun's other `ReadableStream` conversion functions. +See [Docs > API > Utils](/runtime/utils#bun-readablestreamto) for documentation on Bun's other `ReadableStream` conversion functions. diff --git a/docs/guides/streams/to-arraybuffer.mdx b/docs/guides/streams/to-arraybuffer.mdx index 4e05cb8cee..9b9e0535ec 100644 --- a/docs/guides/streams/to-arraybuffer.mdx +++ b/docs/guides/streams/to-arraybuffer.mdx @@ -13,4 +13,4 @@ const buf = await Bun.readableStreamToArrayBuffer(stream); --- -See [Docs > API > Utils](https://bun.com/docs/api/utils#bun-readablestreamto) for documentation on Bun's other `ReadableStream` conversion functions. +See [Docs > API > Utils](/runtime/utils#bun-readablestreamto) for documentation on Bun's other `ReadableStream` conversion functions. diff --git a/docs/guides/streams/to-blob.mdx b/docs/guides/streams/to-blob.mdx index df604513c6..1585e01c44 100644 --- a/docs/guides/streams/to-blob.mdx +++ b/docs/guides/streams/to-blob.mdx @@ -13,4 +13,4 @@ const blob = await Bun.readableStreamToBlob(stream); --- -See [Docs > API > Utils](https://bun.com/docs/api/utils#bun-readablestreamto) for documentation on Bun's other `ReadableStream` conversion functions. +See [Docs > API > Utils](/runtime/utils#bun-readablestreamto) for documentation on Bun's other `ReadableStream` conversion functions. diff --git a/docs/guides/streams/to-buffer.mdx b/docs/guides/streams/to-buffer.mdx index 2befca63cd..46e98dbaaf 100644 --- a/docs/guides/streams/to-buffer.mdx +++ b/docs/guides/streams/to-buffer.mdx @@ -14,4 +14,4 @@ const nodeBuf = Buffer.from(arrBuf); --- -See [Docs > API > Utils](https://bun.com/docs/api/utils#bun-readablestreamto) for documentation on Bun's other `ReadableStream` conversion functions. +See [Docs > API > Utils](/runtime/utils#bun-readablestreamto) for documentation on Bun's other `ReadableStream` conversion functions. diff --git a/docs/guides/streams/to-json.mdx b/docs/guides/streams/to-json.mdx index 567decf586..5e93fc37df 100644 --- a/docs/guides/streams/to-json.mdx +++ b/docs/guides/streams/to-json.mdx @@ -13,4 +13,4 @@ const json = await stream.json(); --- -See [Docs > API > Utils](https://bun.com/docs/api/utils#bun-readablestreamto) for documentation on Bun's other `ReadableStream` conversion functions. +See [Docs > API > Utils](/runtime/utils#bun-readablestreamto) for documentation on Bun's other `ReadableStream` conversion functions. diff --git a/docs/guides/streams/to-string.mdx b/docs/guides/streams/to-string.mdx index c07f8a3991..81f26efe1c 100644 --- a/docs/guides/streams/to-string.mdx +++ b/docs/guides/streams/to-string.mdx @@ -13,4 +13,4 @@ const str = await Bun.readableStreamToText(stream); --- -See [Docs > API > Utils](https://bun.com/docs/api/utils#bun-readablestreamto) for documentation on Bun's other `ReadableStream` conversion functions. +See [Docs > API > Utils](/runtime/utils#bun-readablestreamto) for documentation on Bun's other `ReadableStream` conversion functions. diff --git a/docs/guides/streams/to-typedarray.mdx b/docs/guides/streams/to-typedarray.mdx index 4925910af4..4d6dd6adff 100644 --- a/docs/guides/streams/to-typedarray.mdx +++ b/docs/guides/streams/to-typedarray.mdx @@ -21,4 +21,4 @@ const uint8 = await Bun.readableStreamToBytes(stream); --- -See [Docs > API > Utils](https://bun.com/docs/api/utils#bun-readablestreamto) for documentation on Bun's other `ReadableStream` conversion functions. +See [Docs > API > Utils](/runtime/utils#bun-readablestreamto) for documentation on Bun's other `ReadableStream` conversion functions. diff --git a/docs/guides/test/bail.mdx b/docs/guides/test/bail.mdx index c69f8f0fbb..9cd56cacf9 100644 --- a/docs/guides/test/bail.mdx +++ b/docs/guides/test/bail.mdx @@ -21,4 +21,4 @@ bun test --bail=10 --- -See [Docs > Test runner](https://bun.sh/docs/cli/test) for complete documentation of `bun test`. +See [Docs > Test runner](/test) for complete documentation of `bun test`. diff --git a/docs/guides/test/concurrent-test-glob.mdx b/docs/guides/test/concurrent-test-glob.mdx index 8a2d5a2c8e..5f68c50351 100644 --- a/docs/guides/test/concurrent-test-glob.mdx +++ b/docs/guides/test/concurrent-test-glob.mdx @@ -2,6 +2,7 @@ title: Selectively run tests concurrently with glob patterns sidebarTitle: Concurrent test glob mode: center +description: Set a glob pattern to decide which tests from which files run in parallel --- This guide demonstrates how to use the `concurrentTestGlob` option to selectively run tests concurrently based on file naming patterns. @@ -69,12 +70,14 @@ test("fetch user data", async () => { expect(response.ok).toBe(true); }); -test("fetch posts", async () => { +// can also use test.concurrent() for explicitly marking it as concurrent +test.concurrent("fetch posts", async () => { const response = await fetch("/api/posts"); expect(response.ok).toBe(true); }); -test("fetch comments", async () => { +// can also use test.serial() for explicitly marking it as sequential +test.serial("fetch comments", async () => { const response = await fetch("/api/comments"); expect(response.ok).toBe(true); }); diff --git a/docs/guides/test/coverage-threshold.mdx b/docs/guides/test/coverage-threshold.mdx index 560e38756b..5efdc197b4 100644 --- a/docs/guides/test/coverage-threshold.mdx +++ b/docs/guides/test/coverage-threshold.mdx @@ -64,4 +64,4 @@ coverageThreshold = { lines = 0.5, functions = 0.7 } --- -See [Docs > Test runner > Coverage](https://bun.sh/docs/test/coverage) for complete documentation on code coverage reporting in Bun. +See [Docs > Test runner > Coverage](/test/code-coverage) for complete documentation on code coverage reporting in Bun. diff --git a/docs/guides/test/coverage.mdx b/docs/guides/test/coverage.mdx index 7c2315c297..0c18dba670 100644 --- a/docs/guides/test/coverage.mdx +++ b/docs/guides/test/coverage.mdx @@ -46,4 +46,4 @@ coverage = true # always enable coverage --- -Refer to [Docs > Test runner > Coverage](https://bun.sh/docs/test/coverage) for complete documentation on code coverage reporting in Bun. +Refer to [Docs > Test runner > Coverage](/test/code-coverage) for complete documentation on code coverage reporting in Bun. diff --git a/docs/guides/test/happy-dom.mdx b/docs/guides/test/happy-dom.mdx index 14a40db2f0..88673378a0 100644 --- a/docs/guides/test/happy-dom.mdx +++ b/docs/guides/test/happy-dom.mdx @@ -70,4 +70,4 @@ Ran 1 tests across 1 files. 1 total [125.00ms] --- -Refer to the [Happy DOM repo](https://github.com/capricorn86/happy-dom) and [Docs > Test runner > DOM](https://bun.sh/docs/test/dom) for complete documentation on writing browser tests with Bun. +Refer to the [Happy DOM repo](https://github.com/capricorn86/happy-dom) and [Docs > Test runner > DOM](/test/dom) for complete documentation on writing browser tests with Bun. diff --git a/docs/guides/test/migrate-from-jest.mdx b/docs/guides/test/migrate-from-jest.mdx index af0ebc0daf..fbe3e6dca4 100644 --- a/docs/guides/test/migrate-from-jest.mdx +++ b/docs/guides/test/migrate-from-jest.mdx @@ -62,7 +62,7 @@ describe("my test suite", () => { --- -Bun implements the vast majority of Jest's matchers, but compatibility isn't 100% yet. Refer to the full compatibility table at [Docs > Test runner > Writing tests](https://bun.sh/docs/test/writing#matchers). +Bun implements the vast majority of Jest's matchers, but compatibility isn't 100% yet. Refer to the full compatibility table at [Docs > Test runner > Writing tests](/test/writing-tests#matchers). Some notable missing features: @@ -74,7 +74,7 @@ If you're using `testEnvironment: "jsdom"` to run your tests in a browser-like e At the moment jsdom does not work in Bun due to its internal use of V8 APIs. Track support for it [here](https://github.com/oven-sh/bun/issues/3554). -```toml bunfig.toml +```toml bunfig.toml icon="settings" [test] preload = ["./happy-dom.ts"] ``` @@ -107,11 +107,11 @@ bun test --timeout 10000 Many other flags become irrelevant or obsolete when using `bun test`. -- `transform` β€” Bun supports TypeScript & JSX. Other file types can be configured with [Plugins](https://bun.sh/docs/runtime/plugins). +- `transform` β€” Bun supports TypeScript & JSX. Other file types can be configured with [Plugins](/runtime/plugins). - `extensionsToTreatAsEsm` - `haste` β€” Bun uses it's own internal source maps - `watchman`, `watchPlugins`, `watchPathIgnorePatterns` β€” use `--watch` to run tests in watch mode -- `verbose` β€” set `logLevel: "debug"` in [`bunfig.toml`](https://bun.sh/docs/runtime/bunfig#loglevel) +- `verbose` β€” set `logLevel: "debug"` in [`bunfig.toml`](/runtime/bunfig#loglevel) --- @@ -122,4 +122,4 @@ Settings that aren't mentioned here are not supported or have no equivalent. Ple See also: - [Mark a test as a todo](/guides/test/todo-tests) -- [Docs > Test runner > Writing tests](https://bun.sh/docs/test/writing) +- [Docs > Test runner > Writing tests](/test/writing-tests) diff --git a/docs/guides/test/mock-clock.mdx b/docs/guides/test/mock-clock.mdx index fd862254fa..21ec7e2776 100644 --- a/docs/guides/test/mock-clock.mdx +++ b/docs/guides/test/mock-clock.mdx @@ -22,7 +22,7 @@ test("party like it's 1999", () => { --- -The `setSystemTime` function is commonly used on conjunction with [Lifecycle Hooks](https://bun.sh/docs/test/lifecycle) to configure a testing environment with a deterministic "fake clock". +The `setSystemTime` function is commonly used on conjunction with [Lifecycle Hooks](/test/lifecycle) to configure a testing environment with a deterministic "fake clock". ```ts import { test, expect, beforeAll, setSystemTime } from "bun:test"; @@ -47,4 +47,4 @@ setSystemTime(); // reset to actual time --- -See [Docs > Test Runner > Date and time](https://bun.sh/docs/test/time) for complete documentation on mocking with the Bun test runner. +See [Docs > Test Runner > Date and time](/test/dates-times) for complete documentation on mocking with the Bun test runner. diff --git a/docs/guides/test/mock-functions.mdx b/docs/guides/test/mock-functions.mdx index 93b14c953e..8abd9602c2 100644 --- a/docs/guides/test/mock-functions.mdx +++ b/docs/guides/test/mock-functions.mdx @@ -67,4 +67,4 @@ test("random", async () => { --- -See [Docs > Test Runner > Mocks](https://bun.sh/docs/test/mocks) for complete documentation on mocking with the Bun test runner. +See [Docs > Test Runner > Mocks](/test/mocks) for complete documentation on mocking with the Bun test runner. diff --git a/docs/guides/test/rerun-each.mdx b/docs/guides/test/rerun-each.mdx index 12046aebbd..964d976508 100644 --- a/docs/guides/test/rerun-each.mdx +++ b/docs/guides/test/rerun-each.mdx @@ -13,4 +13,4 @@ bun test --rerun-each 10 --- -See [Docs > Test runner](https://bun.sh/docs/cli/test) for complete documentation of `bun test`. +See [Docs > Test runner](/test) for complete documentation of `bun test`. diff --git a/docs/guides/test/run-tests.mdx b/docs/guides/test/run-tests.mdx index 54638b950e..fd0b9759b1 100644 --- a/docs/guides/test/run-tests.mdx +++ b/docs/guides/test/run-tests.mdx @@ -4,7 +4,7 @@ sidebarTitle: Run tests mode: center --- -Bun has a built-in [test runner](https://bun.sh/docs/cli/test) with a Jest-like `expect` API. +Bun has a built-in [test runner](/test) with a Jest-like `expect` API. --- @@ -113,4 +113,4 @@ Ran 6 tests across 3 files. [59.00ms] --- -See [Docs > Test Runner](https://bun.sh/docs/cli/test) for complete documentation on the test runner. +See [Docs > Test Runner](/test) for complete documentation on the test runner. diff --git a/docs/guides/test/skip-tests.mdx b/docs/guides/test/skip-tests.mdx index 135e516efb..11a2565668 100644 --- a/docs/guides/test/skip-tests.mdx +++ b/docs/guides/test/skip-tests.mdx @@ -40,4 +40,4 @@ Ran 3 tests across 1 files. [74.00ms] See also: - [Mark a test as a todo](/guides/test/todo-tests) -- [Docs > Test runner > Writing tests](https://bun.sh/docs/test/writing) +- [Docs > Test runner > Writing tests](/test/writing-tests) diff --git a/docs/guides/test/snapshot.mdx b/docs/guides/test/snapshot.mdx index df16c0f73d..1be74fcbbf 100644 --- a/docs/guides/test/snapshot.mdx +++ b/docs/guides/test/snapshot.mdx @@ -49,7 +49,7 @@ test The `snap.test.ts.snap` file is a JavaScript file that exports a serialized version of the value passed into `expect()`. The `{foo: "bar"}` object has been serialized to JSON. ```js snap.test.ts.snap icon="file-code" -// Bun Snapshot v1, https://bun.sh/docs/test/snapshots +// Bun Snapshot v1, https://bun.com/docs/test/snapshots exports[`snapshot 1`] = ` { @@ -99,4 +99,4 @@ Ran 1 tests across 1 files. [102.00ms] --- -See [Docs > Test Runner > Snapshots](https://bun.sh/docs/test/snapshots) for complete documentation on snapshots with the Bun test runner. +See [Docs > Test Runner > Snapshots](/test/snapshots) for complete documentation on snapshots with the Bun test runner. diff --git a/docs/guides/test/spy-on.mdx b/docs/guides/test/spy-on.mdx index 74519c08c5..4685ddf047 100644 --- a/docs/guides/test/spy-on.mdx +++ b/docs/guides/test/spy-on.mdx @@ -46,4 +46,4 @@ test("turtles", () => { // [!code ++] --- -See [Docs > Test Runner > Mocks](https://bun.sh/docs/test/mocks) for complete documentation on mocking with the Bun test runner. +See [Docs > Test Runner > Mocks](/test/mocks) for complete documentation on mocking with the Bun test runner. diff --git a/docs/guides/test/svelte-test.mdx b/docs/guides/test/svelte-test.mdx index 54e555ae76..6f57573f0e 100644 --- a/docs/guides/test/svelte-test.mdx +++ b/docs/guides/test/svelte-test.mdx @@ -14,7 +14,7 @@ bun add @testing-library/svelte svelte@4 @happy-dom/global-registrator Then, save this plugin in your project. -```ts svelte-loader.js icon="/icons/typescript.svg" +```ts svelte-loader.ts icon="/icons/typescript.svg" import { plugin } from "bun"; import { compile } from "svelte/compiler"; import { readFileSync } from "fs"; @@ -61,10 +61,10 @@ Add this to `bunfig.toml` to tell Bun to preload the plugin, so it loads before ```toml bunfig.toml icon="settings" [test] # Tell Bun to load this plugin before your tests run -preload = ["./svelte-loader.js"] +preload = ["./svelte-loader.ts"] # This also works: -# test.preload = ["./svelte-loader.js"] +# test.preload = ["./svelte-loader.ts"] ``` --- diff --git a/docs/guides/test/testing-library.mdx b/docs/guides/test/testing-library.mdx index 36e5b61540..7e4ed0a440 100644 --- a/docs/guides/test/testing-library.mdx +++ b/docs/guides/test/testing-library.mdx @@ -8,7 +8,7 @@ You can use [Testing Library](https://testing-library.com/) with Bun's test runn --- -As a prerequisite to using Testing Library you will need to install [Happy Dom](https://github.com/capricorn86/happy-dom). ([see Bun's Happy DOM guide for more information](https://bun.sh/guides/test/happy-dom)). +As a prerequisite to using Testing Library you will need to install [Happy Dom](https://github.com/capricorn86/happy-dom). ([see Bun's Happy DOM guide for more information](/guides/test/happy-dom)). ```sh terminal icon="terminal" bun add -D @happy-dom/global-registrator @@ -24,7 +24,7 @@ bun add -D @testing-library/react @testing-library/dom @testing-library/jest-dom --- -Next you will need to create a preload script for Happy DOM and for Testing Library. For more details about the Happy DOM setup script see [Bun's Happy DOM guide](https://bun.sh/guides/test/happy-dom). +Next you will need to create a preload script for Happy DOM and for Testing Library. For more details about the Happy DOM setup script see [Bun's Happy DOM guide](/guides/test/happy-dom). ```ts happydom.ts icon="/icons/typescript.svg" import { GlobalRegistrator } from "@happy-dom/global-registrator"; @@ -90,4 +90,4 @@ test("Can use Testing Library", () => { --- -Refer to the [Testing Library docs](https://testing-library.com/), [Happy DOM repo](https://github.com/capricorn86/happy-dom) and [Docs > Test runner > DOM](https://bun.sh/docs/test/dom) for complete documentation on writing browser tests with Bun. +Refer to the [Testing Library docs](https://testing-library.com/), [Happy DOM repo](https://github.com/capricorn86/happy-dom) and [Docs > Test runner > DOM](/test/dom) for complete documentation on writing browser tests with Bun. diff --git a/docs/guides/test/timeout.mdx b/docs/guides/test/timeout.mdx index 182fbea339..9d333ac2c4 100644 --- a/docs/guides/test/timeout.mdx +++ b/docs/guides/test/timeout.mdx @@ -14,4 +14,4 @@ bun test --timeout 3000 # 3 seconds --- -See [Docs > Test runner](https://bun.sh/docs/cli/test) for complete documentation of `bun test`. +See [Docs > Test runner](/test) for complete documentation of `bun test`. diff --git a/docs/guides/test/todo-tests.mdx b/docs/guides/test/todo-tests.mdx index a349b088a1..e1ff067044 100644 --- a/docs/guides/test/todo-tests.mdx +++ b/docs/guides/test/todo-tests.mdx @@ -71,4 +71,4 @@ $ echo $? See also: - [Skip a test](/guides/test/skip-tests) -- [Docs > Test runner > Writing tests](https://bun.sh/docs/test/writing) +- [Docs > Test runner > Writing tests](/test/writing-tests) diff --git a/docs/guides/test/update-snapshots.mdx b/docs/guides/test/update-snapshots.mdx index 4cdd5f3c2f..f0069dbe33 100644 --- a/docs/guides/test/update-snapshots.mdx +++ b/docs/guides/test/update-snapshots.mdx @@ -46,4 +46,4 @@ Ran 1 tests across 1 files. [102.00ms] --- -See [Docs > Test Runner > Snapshots](https://bun.sh/docs/test/snapshots) for complete documentation on snapshots with the Bun test runner. +See [Docs > Test Runner > Snapshots](/test/snapshots) for complete documentation on snapshots with the Bun test runner. diff --git a/docs/guides/test/watch-mode.mdx b/docs/guides/test/watch-mode.mdx index dd24911c7a..8b3f7b9556 100644 --- a/docs/guides/test/watch-mode.mdx +++ b/docs/guides/test/watch-mode.mdx @@ -21,4 +21,4 @@ This will restart the running Bun process whenever a file change is detected. It --- -See [Docs > Test Runner](https://bun.sh/docs/cli/test) for complete documentation on the test runner. +See [Docs > Test Runner](/test) for complete documentation on the test runner. diff --git a/docs/guides/util/base64.mdx b/docs/guides/util/base64.mdx index 11ae957d4d..350ee72c4c 100644 --- a/docs/guides/util/base64.mdx +++ b/docs/guides/util/base64.mdx @@ -14,4 +14,4 @@ const decoded = atob(encoded); // => "hello world" --- -See [Docs > Web APIs](https://bun.com/docs/runtime/web-apis) for a complete breakdown of the Web APIs implemented in Bun. +See [Docs > Web APIs](/runtime/web-apis) for a complete breakdown of the Web APIs implemented in Bun. diff --git a/docs/guides/util/deep-equals.mdx b/docs/guides/util/deep-equals.mdx index f5f15fae28..c3ef2d626c 100644 --- a/docs/guides/util/deep-equals.mdx +++ b/docs/guides/util/deep-equals.mdx @@ -4,7 +4,7 @@ sidebarTitle: Deep equality mode: center --- -Check if two objects are deeply equal. This is used internally by `expect().toEqual()` in Bun's [test runner](https://bun.com/docs/test/writing). +Check if two objects are deeply equal. This is used internally by `expect().toEqual()` in Bun's [test runner](/test/writing-tests). ```ts index.ts icon="/icons/typescript.svg" const a = { a: 1, b: 2, c: { d: 3 } }; @@ -15,7 +15,7 @@ Bun.deepEquals(a, b); // true --- -Pass `true` as a third argument to enable strict mode. This is used internally by `expect().toStrictEqual()` in Bun's [test runner](https://bun.com/docs/test/writing). +Pass `true` as a third argument to enable strict mode. This is used internally by `expect().toStrictEqual()` in Bun's [test runner](/test/writing-tests). The following examples would return `true` in non-strict mode but `false` in strict mode. @@ -38,4 +38,4 @@ Bun.deepEquals(new Foo(), { a: 1 }, true); // false --- -See [Docs > API > Utils](https://bun.com/docs/api/utils) for more useful utilities. +See [Docs > API > Utils](/runtime/utils) for more useful utilities. diff --git a/docs/guides/util/deflate.mdx b/docs/guides/util/deflate.mdx index 6c525db2ef..90f367bb4e 100644 --- a/docs/guides/util/deflate.mdx +++ b/docs/guides/util/deflate.mdx @@ -17,4 +17,4 @@ const decompressed = Bun.inflateSync(compressed); --- -See [Docs > API > Utils](https://bun.com/docs/api/utils) for more useful utilities. +See [Docs > API > Utils](/runtime/utils) for more useful utilities. diff --git a/docs/guides/util/entrypoint.mdx b/docs/guides/util/entrypoint.mdx index a7105a00d0..e495ecc683 100644 --- a/docs/guides/util/entrypoint.mdx +++ b/docs/guides/util/entrypoint.mdx @@ -4,7 +4,7 @@ sidebarTitle: Check entrypoint mode: center --- -Bun provides a handful of module-specific utilities on the [`import.meta`](https://bun.com/docs/api/import-meta) object. Use `import.meta.main` to check if the current file is the entrypoint of the current process. +Bun provides a handful of module-specific utilities on the [`import.meta`](/runtime/module-resolution#import-meta) object. Use `import.meta.main` to check if the current file is the entrypoint of the current process. ```ts index.ts icon="/icons/typescript.svg" if (import.meta.main) { @@ -16,4 +16,4 @@ if (import.meta.main) { --- -See [Docs > API > import.meta](https://bun.com/docs/api/import-meta) for complete documentation. +See [Docs > API > import.meta](/runtime/module-resolution#import-meta) for complete documentation. diff --git a/docs/guides/util/escape-html.mdx b/docs/guides/util/escape-html.mdx index ca2fec3cfa..fc08af9a63 100644 --- a/docs/guides/util/escape-html.mdx +++ b/docs/guides/util/escape-html.mdx @@ -21,4 +21,4 @@ Bun.escapeHTML(""); --- -See [Docs > API > Utils](https://bun.com/docs/api/utils) for more useful utilities. +See [Docs > API > Utils](/runtime/utils) for more useful utilities. diff --git a/docs/guides/util/file-url-to-path.mdx b/docs/guides/util/file-url-to-path.mdx index 1ff86fc31b..3990f3befb 100644 --- a/docs/guides/util/file-url-to-path.mdx +++ b/docs/guides/util/file-url-to-path.mdx @@ -13,4 +13,4 @@ Bun.fileURLToPath("file:///path/to/file.txt"); --- -See [Docs > API > Utils](https://bun.com/docs/api/utils) for more useful utilities. +See [Docs > API > Utils](/runtime/utils) for more useful utilities. diff --git a/docs/guides/util/gzip.mdx b/docs/guides/util/gzip.mdx index 84b9d97067..0a3763f9ed 100644 --- a/docs/guides/util/gzip.mdx +++ b/docs/guides/util/gzip.mdx @@ -17,4 +17,4 @@ const decompressed = Bun.gunzipSync(compressed); --- -See [Docs > API > Utils](https://bun.com/docs/api/utils) for more useful utilities. +See [Docs > API > Utils](/runtime/utils) for more useful utilities. diff --git a/docs/guides/util/hash-a-password.mdx b/docs/guides/util/hash-a-password.mdx index d45d6da6e2..ef01dde286 100644 --- a/docs/guides/util/hash-a-password.mdx +++ b/docs/guides/util/hash-a-password.mdx @@ -53,4 +53,4 @@ const isMatch = await Bun.password.verify(password, hash); --- -See [Docs > API > Hashing](https://bun.com/docs/api/hashing#bun-password) for complete documentation. +See [Docs > API > Hashing](/runtime/hashing#bun-password) for complete documentation. diff --git a/docs/guides/util/import-meta-dir.mdx b/docs/guides/util/import-meta-dir.mdx index 2890273034..8a2355cd89 100644 --- a/docs/guides/util/import-meta-dir.mdx +++ b/docs/guides/util/import-meta-dir.mdx @@ -4,7 +4,7 @@ sidebarTitle: import.meta.dir mode: center --- -Bun provides a handful of module-specific utilities on the [`import.meta`](https://bun.com/docs/api/import-meta) object. +Bun provides a handful of module-specific utilities on the [`import.meta`](/runtime/module-resolution#import-meta) object. ```ts /a/b/c.ts icon="/icons/typescript.svg" import.meta.dir; // => "/a/b" @@ -12,4 +12,4 @@ import.meta.dir; // => "/a/b" --- -See [Docs > API > import.meta](https://bun.com/docs/api/import-meta) for complete documentation. +See [Docs > API > import.meta](/runtime/module-resolution#import-meta) for complete documentation. diff --git a/docs/guides/util/import-meta-file.mdx b/docs/guides/util/import-meta-file.mdx index cf16226b35..01edbafa66 100644 --- a/docs/guides/util/import-meta-file.mdx +++ b/docs/guides/util/import-meta-file.mdx @@ -4,7 +4,7 @@ sidebarTitle: import.meta.file mode: center --- -Bun provides a handful of module-specific utilities on the [`import.meta`](https://bun.com/docs/api/import-meta) object. Use `import.meta.file` to retrieve the name of the current file. +Bun provides a handful of module-specific utilities on the [`import.meta`](/runtime/module-resolution#import-meta) object. Use `import.meta.file` to retrieve the name of the current file. ```ts /a/b/c.ts icon="/icons/typescript.svg" import.meta.file; // => "c.ts" @@ -12,4 +12,4 @@ import.meta.file; // => "c.ts" --- -See [Docs > API > import.meta](https://bun.com/docs/api/import-meta) for complete documentation. +See [Docs > API > import.meta](/runtime/module-resolution#import-meta) for complete documentation. diff --git a/docs/guides/util/import-meta-path.mdx b/docs/guides/util/import-meta-path.mdx index 3e1f20aec8..80e92bfd1f 100644 --- a/docs/guides/util/import-meta-path.mdx +++ b/docs/guides/util/import-meta-path.mdx @@ -4,7 +4,7 @@ sidebarTitle: import.meta.path mode: center --- -Bun provides a handful of module-specific utilities on the [`import.meta`](https://bun.com/docs/api/import-meta) object. Use `import.meta.path` to retrieve the absolute path of the current file. +Bun provides a handful of module-specific utilities on the [`import.meta`](/runtime/module-resolution#import-meta) object. Use `import.meta.path` to retrieve the absolute path of the current file. ```ts /a/b/c.ts icon="/icons/typescript.svg" import.meta.path; // => "/a/b/c.ts" @@ -12,4 +12,4 @@ import.meta.path; // => "/a/b/c.ts" --- -See [Docs > API > import.meta](https://bun.com/docs/api/import-meta) for complete documentation. +See [Docs > API > import.meta](/runtime/module-resolution#import-meta) for complete documentation. diff --git a/docs/guides/util/javascript-uuid.mdx b/docs/guides/util/javascript-uuid.mdx index 1d9a0ea0f6..1c0d4bfa6b 100644 --- a/docs/guides/util/javascript-uuid.mdx +++ b/docs/guides/util/javascript-uuid.mdx @@ -8,7 +8,7 @@ Use `crypto.randomUUID()` to generate a UUID v4. This API works in Bun, Node.js, ```ts crypto.randomUUID(); -// => "123e4567-e89b-12d3-a456-426614174000" +// => "123e4567-e89b-42d3-a456-426614174000" ``` --- @@ -22,4 +22,4 @@ Bun.randomUUIDv7(); --- -See [Docs > API > Utils](https://bun.com/docs/api/utils) for more useful utilities. +See [Docs > API > Utils](/runtime/utils) for more useful utilities. diff --git a/docs/guides/util/main.mdx b/docs/guides/util/main.mdx index f308c64a7c..ea41dbf2d1 100644 --- a/docs/guides/util/main.mdx +++ b/docs/guides/util/main.mdx @@ -40,4 +40,4 @@ bun run foo.ts --- -See [Docs > API > Utils](https://bun.com/docs/api/utils) for more useful utilities. +See [Docs > API > Utils](/runtime/utils) for more useful utilities. diff --git a/docs/guides/util/path-to-file-url.mdx b/docs/guides/util/path-to-file-url.mdx index aac29788df..65ffe7b201 100644 --- a/docs/guides/util/path-to-file-url.mdx +++ b/docs/guides/util/path-to-file-url.mdx @@ -13,4 +13,4 @@ Bun.pathToFileURL("/path/to/file.txt"); --- -See [Docs > API > Utils](https://bun.com/docs/api/utils) for more useful utilities. +See [Docs > API > Utils](/runtime/utils) for more useful utilities. diff --git a/docs/guides/util/sleep.mdx b/docs/guides/util/sleep.mdx index 30daedc805..738738c213 100644 --- a/docs/guides/util/sleep.mdx +++ b/docs/guides/util/sleep.mdx @@ -21,4 +21,4 @@ await new Promise(resolve => setTimeout(resolve, ms)); --- -See [Docs > API > Utils](https://bun.com/docs/api/utils) for more useful utilities. +See [Docs > API > Utils](/runtime/utils) for more useful utilities. diff --git a/docs/guides/util/version.mdx b/docs/guides/util/version.mdx index 73b3942744..5fa039b08a 100644 --- a/docs/guides/util/version.mdx +++ b/docs/guides/util/version.mdx @@ -20,4 +20,4 @@ Bun.revision; // => "49231b2cb9aa48497ab966fc0bb6b742dacc4994" --- -See [Docs > API > Utils](https://bun.com/docs/api/utils) for more useful utilities. +See [Docs > API > Utils](/runtime/utils) for more useful utilities. diff --git a/docs/guides/util/which-path-to-executable-bin.mdx b/docs/guides/util/which-path-to-executable-bin.mdx index fe9cda53a6..e524561089 100644 --- a/docs/guides/util/which-path-to-executable-bin.mdx +++ b/docs/guides/util/which-path-to-executable-bin.mdx @@ -14,4 +14,4 @@ Bun.which("bun"); // => "/home/user/.bun/bin/bun" --- -See [Docs > API > Utils](https://bun.com/docs/api/utils#bun-which) for complete documentation. +See [Docs > API > Utils](/runtime/utils#bun-which) for complete documentation. diff --git a/docs/guides/websocket/context.mdx b/docs/guides/websocket/context.mdx index 85c8ecc05b..3104ec9a12 100644 --- a/docs/guides/websocket/context.mdx +++ b/docs/guides/websocket/context.mdx @@ -6,7 +6,7 @@ mode: center When building a WebSocket server, it's typically necessary to store some identifying information or context associated with each connected client. -With [Bun.serve()](https://bun.com/docs/api/websockets contextual-data), this "contextual data" is set when the connection is initially upgraded by passing a `data` parameter in the `server.upgrade()` call. +With [Bun.serve()](/runtime/http/websockets#contextual-data), this "contextual data" is set when the connection is initially upgraded by passing a `data` parameter in the `server.upgrade()` call. ```ts server.ts icon="/icons/typescript.svg" Bun.serve({ diff --git a/docs/guides/websocket/simple.mdx b/docs/guides/websocket/simple.mdx index 4450b0e418..6239d13365 100644 --- a/docs/guides/websocket/simple.mdx +++ b/docs/guides/websocket/simple.mdx @@ -4,7 +4,7 @@ sidebarTitle: Simple server mode: center --- -Start a simple WebSocket server using [`Bun.serve`](https://bun.com/docs/api/http). +Start a simple WebSocket server using [`Bun.serve`](/runtime/http/server). Inside `fetch`, we attempt to upgrade incoming `ws:` or `wss:` requests to WebSocket connections. diff --git a/docs/guides/write-file/basic.mdx b/docs/guides/write-file/basic.mdx index 4edd4207a2..6f3eec5287 100644 --- a/docs/guides/write-file/basic.mdx +++ b/docs/guides/write-file/basic.mdx @@ -6,7 +6,7 @@ mode: center This code snippet writes a string to disk at a particular _absolute path_. -It uses the fast [`Bun.write()`](https://bun.com/docs/api/file-io#writing-files-bun-write) API to efficiently write data to disk. The first argument is a _destination_; the second is the _data_ to write. +It uses the fast [`Bun.write()`](/runtime/file-io#writing-files-bun-write) API to efficiently write data to disk. The first argument is a _destination_; the second is the _data_ to write. ```ts const path = "/path/to/file.txt"; @@ -43,4 +43,4 @@ const bytes = await Bun.write(path, "Lorem ipsum"); --- -See [Docs > API > File I/O](https://bun.com/docs/api/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`. +See [Docs > API > File I/O](/runtime/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`. diff --git a/docs/guides/write-file/blob.mdx b/docs/guides/write-file/blob.mdx index ccaaaefc78..78810b740d 100644 --- a/docs/guides/write-file/blob.mdx +++ b/docs/guides/write-file/blob.mdx @@ -6,7 +6,7 @@ mode: center This code snippet writes a `Blob` to disk at a particular path. -It uses the fast [`Bun.write()`](https://bun.com/docs/api/file-io#writing-files-bun-write) API to efficiently write data to disk. The first argument is a _destination_, like an absolute path or `BunFile` instance. The second argument is the _data_ to write. +It uses the fast [`Bun.write()`](/runtime/file-io#writing-files-bun-write) API to efficiently write data to disk. The first argument is a _destination_, like an absolute path or `BunFile` instance. The second argument is the _data_ to write. ```ts const path = "/path/to/file.txt"; @@ -27,4 +27,4 @@ await Bun.write(path, data); --- -See [Docs > API > File I/O](https://bun.com/docs/api/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`. +See [Docs > API > File I/O](/runtime/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`. diff --git a/docs/guides/write-file/cat.mdx b/docs/guides/write-file/cat.mdx index 44b5d91cf0..92ca362e04 100644 --- a/docs/guides/write-file/cat.mdx +++ b/docs/guides/write-file/cat.mdx @@ -4,7 +4,7 @@ sidebarTitle: Write file to stdout mode: center --- -Bun exposes `stdout` as a `BunFile` with the `Bun.stdout` property. This can be used as a destination for [`Bun.write()`](https://bun.com/docs/api/file-io#writing-files-bun-write). +Bun exposes `stdout` as a `BunFile` with the `Bun.stdout` property. This can be used as a destination for [`Bun.write()`](/runtime/file-io#writing-files-bun-write). This code writes a file to `stdout` similar to the `cat` command in Unix. @@ -16,4 +16,4 @@ await Bun.write(Bun.stdout, file); --- -See [Docs > API > File I/O](https://bun.com/docs/api/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`. +See [Docs > API > File I/O](/runtime/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`. diff --git a/docs/guides/write-file/file-cp.mdx b/docs/guides/write-file/file-cp.mdx index d43d5f7225..d8eb08d67c 100644 --- a/docs/guides/write-file/file-cp.mdx +++ b/docs/guides/write-file/file-cp.mdx @@ -6,7 +6,7 @@ mode: center This code snippet copies a file to another location on disk. -It uses the fast [`Bun.write()`](https://bun.com/docs/api/file-io#writing-files-bun-write) API to efficiently write data to disk. The first argument is a _destination_, like an absolute path or `BunFile` instance. The second argument is the _data_ to write. +It uses the fast [`Bun.write()`](/runtime/file-io#writing-files-bun-write) API to efficiently write data to disk. The first argument is a _destination_, like an absolute path or `BunFile` instance. The second argument is the _data_ to write. ```ts const file = Bun.file("/path/to/original.txt"); @@ -15,4 +15,4 @@ await Bun.write("/path/to/copy.txt", file); --- -See [Docs > API > File I/O](https://bun.com/docs/api/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`. +See [Docs > API > File I/O](/runtime/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`. diff --git a/docs/guides/write-file/filesink.mdx b/docs/guides/write-file/filesink.mdx index 5414ed933f..68333e5445 100644 --- a/docs/guides/write-file/filesink.mdx +++ b/docs/guides/write-file/filesink.mdx @@ -51,4 +51,4 @@ writer.end(); --- -Full documentation: [FileSink](https://bun.com/docs/api/file-io#incremental-writing-with-filesink). +Full documentation: [FileSink](/runtime/file-io#incremental-writing-with-filesink). diff --git a/docs/guides/write-file/response.mdx b/docs/guides/write-file/response.mdx index 2f0721623a..20e04ff69c 100644 --- a/docs/guides/write-file/response.mdx +++ b/docs/guides/write-file/response.mdx @@ -6,7 +6,7 @@ mode: center This code snippet writes a `Response` to disk at a particular path. Bun will consume the `Response` body according to its `Content-Type` header. -It uses the fast [`Bun.write()`](https://bun.com/docs/api/file-io#writing-files-bun-write) API to efficiently write data to disk. The first argument is a _destination_, like an absolute path or `BunFile` instance. The second argument is the _data_ to write. +It uses the fast [`Bun.write()`](/runtime/file-io#writing-files-bun-write) API to efficiently write data to disk. The first argument is a _destination_, like an absolute path or `BunFile` instance. The second argument is the _data_ to write. ```ts const result = await fetch("https://bun.com"); @@ -16,4 +16,4 @@ await Bun.write(path, result); --- -See [Docs > API > File I/O](https://bun.com/docs/api/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`. +See [Docs > API > File I/O](/runtime/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`. diff --git a/docs/guides/write-file/stdout.mdx b/docs/guides/write-file/stdout.mdx index 1e980c0947..3c1d9fd681 100644 --- a/docs/guides/write-file/stdout.mdx +++ b/docs/guides/write-file/stdout.mdx @@ -12,7 +12,7 @@ console.log("Lorem ipsum"); --- -For more advanced use cases, Bun exposes `stdout` as a `BunFile` via the `Bun.stdout` property. This can be used as a destination for [`Bun.write()`](https://bun.com/docs/api/file-io#writing-files-bun-write). +For more advanced use cases, Bun exposes `stdout` as a `BunFile` via the `Bun.stdout` property. This can be used as a destination for [`Bun.write()`](/runtime/file-io#writing-files-bun-write). ```ts await Bun.write(Bun.stdout, "Lorem ipsum"); @@ -20,4 +20,4 @@ await Bun.write(Bun.stdout, "Lorem ipsum"); --- -See [Docs > API > File I/O](https://bun.com/docs/api/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`. +See [Docs > API > File I/O](/runtime/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`. diff --git a/docs/guides/write-file/stream.mdx b/docs/guides/write-file/stream.mdx index 739c60c320..1c13bd5c48 100644 --- a/docs/guides/write-file/stream.mdx +++ b/docs/guides/write-file/stream.mdx @@ -4,7 +4,7 @@ sidebarTitle: Write stream mode: center --- -To write a `ReadableStream` to disk, first create a `Response` instance from the stream. This `Response` can then be written to disk using [`Bun.write()`](https://bun.com/docs/api/file-io#writing-files-bun-write). +To write a `ReadableStream` to disk, first create a `Response` instance from the stream. This `Response` can then be written to disk using [`Bun.write()`](/runtime/file-io#writing-files-bun-write). ```ts const stream: ReadableStream = ...; @@ -16,4 +16,4 @@ await Bun.write(path, response); --- -See [Docs > API > File I/O](https://bun.com/docs/api/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`. +See [Docs > API > File I/O](/runtime/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`. diff --git a/docs/guides/write-file/unlink.mdx b/docs/guides/write-file/unlink.mdx index d20cc37287..7835f503d2 100644 --- a/docs/guides/write-file/unlink.mdx +++ b/docs/guides/write-file/unlink.mdx @@ -15,4 +15,4 @@ await file.delete(); --- -See [Docs > API > File I/O](https://bun.com/docs/api/file-io#reading-files-bun-file) for complete documentation of `Bun.file()`. +See [Docs > API > File I/O](/runtime/file-io#reading-files-bun-file) for complete documentation of `Bun.file()`. diff --git a/docs/index.mdx b/docs/index.mdx index f45293b998..471e021af4 100644 --- a/docs/index.mdx +++ b/docs/index.mdx @@ -127,7 +127,7 @@ Bun is designed from the ground-up with today's JavaScript ecosystem in mind. - **Speed**. Bun processes start [4x faster than Node.js](https://twitter.com/jarredsumner/status/1499225725492076544) currently (try it yourself!) - **TypeScript & JSX support**. You can directly execute `.jsx`, `.ts`, and `.tsx` files; Bun's transpiler converts these to vanilla JavaScript before execution. - **ESM & CommonJS compatibility**. The world is moving towards ES modules (ESM), but millions of packages on npm still require CommonJS. Bun recommends ES modules, but supports CommonJS. -- **Web-standard APIs**. Bun implements standard Web APIs like `fetch`, `WebSocket`, and `ReadableStream`. Bun is powered by the JavaScriptCore engine, which is developed by Apple for Safari, so some APIs like [`Headers`](https://developer.mozilla.org/en-US/Web/API/Headers) and [`URL`](https://developer.mozilla.org/en-US/Web/API/URL) directly use [Safari's implementation](https://github.com/oven-sh/bun/blob/HEAD/src/bun.js/bindings/webcore/JSFetchHeaders.cpp). +- **Web-standard APIs**. Bun implements standard Web APIs like `fetch`, `WebSocket`, and `ReadableStream`. Bun is powered by the JavaScriptCore engine, which is developed by Apple for Safari, so some APIs like [`Headers`](https://developer.mozilla.org/en-US/docs/Web/API/Headers) and [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL) directly use [Safari's implementation](https://github.com/oven-sh/bun/blob/HEAD/src/bun.js/bindings/webcore/JSFetchHeaders.cpp). - **Node.js compatibility**. In addition to supporting Node-style module resolution, Bun aims for full compatibility with built-in Node.js globals (`process`, `Buffer`) and modules (`path`, `fs`, `http`, etc.) _This is an ongoing effort that is not complete._ Refer to the [compatibility page](/runtime/nodejs-compat) for the current status. Bun is more than a runtime. The long-term goal is to be a cohesive, infrastructural toolkit for building apps with JavaScript/TypeScript, including a package manager, transpiler, bundler, script runner, test runner, and more. diff --git a/docs/installation.mdx b/docs/installation.mdx index 4f518c3033..0280436eec 100644 --- a/docs/installation.mdx +++ b/docs/installation.mdx @@ -1,6 +1,6 @@ --- title: Installation -description: Install Bun +description: Install Bun with npm, Homebrew, Docker, or the official script. --- ## Overview diff --git a/docs/normalize-internal-links.js b/docs/normalize-internal-links.js index 3fd5d44504..97a1957b4d 100644 --- a/docs/normalize-internal-links.js +++ b/docs/normalize-internal-links.js @@ -15,7 +15,6 @@ if (element.getAttribute("rel") === "noreferrer") { element.removeAttribute("rel"); } - console.log(`Removed target="_blank" from: ${element.textContent || element.innerHTML.substring(0, 50)}`); } }); }); diff --git a/docs/pm/bunx.mdx b/docs/pm/bunx.mdx index d2299cf9df..48dafc0e73 100644 --- a/docs/pm/bunx.mdx +++ b/docs/pm/bunx.mdx @@ -30,7 +30,7 @@ Packages can declare executables in the `"bin"` field of their `package.json`. T These executables are commonly plain JavaScript files marked with a [shebang line]() to indicate which program should be used to execute them. The following file indicates that it should be executed with `node`. -```ts dist/index.js icon="/icons/javascript.svg" +```js dist/index.js icon="/icons/javascript.svg" #!/usr/bin/env node console.log("Hello world!"); @@ -78,6 +78,6 @@ bunx --package @angular/cli ng To force bun to always be used with a script, use a shebang. -```ts dist/index.js icon="/icons/javascript.svg" +```js dist/index.js icon="/icons/javascript.svg" #!/usr/bin/env bun ``` diff --git a/docs/pm/cli/install.mdx b/docs/pm/cli/install.mdx index 65b0c3ce8a..054e364a91 100644 --- a/docs/pm/cli/install.mdx +++ b/docs/pm/cli/install.mdx @@ -135,7 +135,7 @@ For more information on filtering with `bun install`, refer to [Package Manager Bun supports npm's `"overrides"` and Yarn's `"resolutions"` in `package.json`. These are mechanisms for specifying a version range for _metadependencies_β€”the dependencies of your dependencies. Refer to [Package manager > Overrides and resolutions](/pm/overrides) for complete documentation. {/* prettier-ignore */} -```json package.json file="file-json" +```json package.json icon="file-json" { "name": "my-app", "dependencies": { diff --git a/docs/pm/cli/link.mdx b/docs/pm/cli/link.mdx index 860d6be2b4..2591abbf30 100644 --- a/docs/pm/cli/link.mdx +++ b/docs/pm/cli/link.mdx @@ -14,7 +14,7 @@ bun link ``` ```txt -bun link v1.x (7416672e) +bun link v1.3.2 (7416672e) Success! Registered "cool-pkg" To use cool-pkg in a project, run: @@ -53,7 +53,7 @@ bun unlink ``` ```txt -bun unlink v1.x (7416672e) +bun unlink v1.3.2 (7416672e) ``` --- diff --git a/docs/pm/cli/outdated.mdx b/docs/pm/cli/outdated.mdx index da72e0c490..69a70b3998 100644 --- a/docs/pm/cli/outdated.mdx +++ b/docs/pm/cli/outdated.mdx @@ -15,7 +15,7 @@ bun outdated | Package | Current | Update | Latest | | ------------------------------ | ------- | --------- | ---------- | | @sinclair/typebox | 0.34.15 | 0.34.16 | 0.34.16 | -| @types/bun (dev) | 1.2.0 | 1.2.23 | 1.2.23 | +| @types/bun (dev) | 1.3.0 | 1.3.2 | 1.3.2 | | eslint (dev) | 8.57.1 | 8.57.1 | 9.20.0 | | eslint-plugin-security (dev) | 2.1.1 | 2.1.1 | 3.0.1 | | eslint-plugin-sonarjs (dev) | 0.23.0 | 0.23.0 | 3.0.1 | @@ -55,7 +55,7 @@ bun outdated eslint-plugin-security eslint-plugin-sonarjs You can also pass glob patterns to check for outdated packages: ```sh terminal icon="terminal" -bun outdated eslint* +bun outdated 'eslint*' ``` ```txt @@ -75,7 +75,7 @@ bun outdated '@types/*' ```txt | Package | Current | Update | Latest | | ------------------ | ------- | ------ | ------ | -| @types/bun (dev) | 1.2.0 | 1.2.23 | 1.2.23 | +| @types/bun (dev) | 1.3.0 | 1.3.2 | 1.3.2 | ``` Or to exclude all `@types/*` packages: diff --git a/docs/pm/workspaces.mdx b/docs/pm/workspaces.mdx index e524822b89..961037914a 100644 --- a/docs/pm/workspaces.mdx +++ b/docs/pm/workspaces.mdx @@ -43,8 +43,7 @@ In the root `package.json`, the `"workspaces"` key is used to indicate which sub **Glob support** β€” Bun supports full glob syntax in `"workspaces"`, including negative patterns (e.g. - `!**/excluded/**`). See [here](https://bun.com/docs/api/glob#supported-glob-patterns) for a comprehensive list of - supported syntax. + `!**/excluded/**`). See [here](/runtime/glob#supported-glob-patterns) for a comprehensive list of supported syntax. ```json package.json icon="file-json" diff --git a/docs/project/building-windows.mdx b/docs/project/building-windows.mdx index 59cb8f788e..9a4a3ab2d7 100644 --- a/docs/project/building-windows.mdx +++ b/docs/project/building-windows.mdx @@ -22,7 +22,7 @@ By default, running unverified scripts are blocked. Bun v1.1 or later. We use Bun to run it's own code generators. ```ps1 -> irm bun.com/install.ps1 | iex +> irm bun.sh/install.ps1 | iex ``` [Visual Studio](https://visualstudio.microsoft.com) with the "Desktop Development with C++" workload. While installing, make sure to install Git as well, if Git for Windows is not already installed. diff --git a/docs/project/license.mdx b/docs/project/license.mdx index 679ff7be84..fa51203c26 100644 --- a/docs/project/license.mdx +++ b/docs/project/license.mdx @@ -11,7 +11,7 @@ Bun statically links JavaScriptCore (and WebKit) which is LGPL-2 licensed. WebCo > (1) If you statically link against an LGPL'd library, you must also provide your application in an object (not necessarily source) format, so that a user has the opportunity to modify the library and relink the application. -You can find the patched version of WebKit used by Bun here: [https://github.com/oven-sh/webkit](https://github.com/oven-sh/webkit). If you would like to relink Bun with changes: +You can find the patched version of WebKit used by Bun here: https://github.com/oven-sh/webkit. If you would like to relink Bun with changes: - `git submodule update --init --recursive` - `make jsc` diff --git a/docs/quickstart.mdx b/docs/quickstart.mdx index 59939e6887..6781199996 100644 --- a/docs/quickstart.mdx +++ b/docs/quickstart.mdx @@ -92,7 +92,7 @@ Build a minimal HTTP server with `Bun.serve`, run it locally, then evolve it by Then add the following to your `compilerOptions` in `tsconfig.json`: - ```json tsconfig.json icon="file-code" + ```json tsconfig.json icon="file-json" { "compilerOptions": { "lib": ["ESNext"], @@ -220,7 +220,7 @@ Build a minimal HTTP server with `Bun.serve`, run it locally, then evolve it by Bun can also execute `"scripts"` from your `package.json`. Add the following script: {/* prettier-ignore */} -```json package.json icon="file-code" +```json package.json icon="file-json" { "name": "quickstart", "module": "index.ts", diff --git a/docs/runtime/bunfig.mdx b/docs/runtime/bunfig.mdx index a296acb827..669e9a1330 100644 --- a/docs/runtime/bunfig.mdx +++ b/docs/runtime/bunfig.mdx @@ -452,8 +452,8 @@ To configure the directory where Bun installs globally installed binaries and CL Environment variable: `BUN_INSTALL_BIN` ```toml title="bunfig.toml" icon="settings" -# where globally-installed package bins are linked [install] +# where globally-installed package bins are linked globalBinDir = "~/.bun/bin" ``` @@ -585,6 +585,32 @@ editor = "code" # - "emacs" ``` +### `install.security.scanner` + +Configure a security scanner to scan packages for vulnerabilities before installation. + +First, install a security scanner from npm: + +```bash terminal icon="terminal" +bun add -d @acme/bun-security-scanner +``` + +Then configure it in your `bunfig.toml`: + +```toml bunfig.toml icon="settings" +[install.security] +scanner = "@acme/bun-security-scanner" +``` + +When a security scanner is configured: + +- Auto-install is automatically disabled for security +- Packages are scanned before installation +- Installation is cancelled if fatal issues are found +- Security warnings are displayed during installation + +Learn more about [using and writing security scanners](/pm/security-scanner-api). + ### `install.minimumReleaseAge` Configure a minimum age (in seconds) for npm package versions. Package versions published more recently than this threshold will be filtered out during installation. Default is `null` (disabled). diff --git a/docs/runtime/c-compiler.mdx b/docs/runtime/c-compiler.mdx index 14c0e27216..516fc3efbd 100644 --- a/docs/runtime/c-compiler.mdx +++ b/docs/runtime/c-compiler.mdx @@ -13,7 +13,7 @@ See the [introduction blog post](https://bun.com/blog/compile-and-run-c-in-js) f JavaScript: -```ts hello.js icon="file-code" +```ts hello.ts icon="file-code" import { cc } from "bun:ffi"; import source from "./hello.c" with { type: "file" }; @@ -87,7 +87,7 @@ You can also pass a `napi_env` to receive the N-API environment used to call the For example, if you have a string in C, you can return it to JavaScript like this: -```ts hello.js +```ts hello.ts import { cc } from "bun:ffi"; import source from "./hello.c" with { type: "file" }; diff --git a/docs/runtime/child-process.mdx b/docs/runtime/child-process.mdx index 6be68a6f27..8ebdc0b92a 100644 --- a/docs/runtime/child-process.mdx +++ b/docs/runtime/child-process.mdx @@ -289,7 +289,7 @@ childProc.disconnect(); To use IPC between a `bun` process and a Node.js process, set `serialization: "json"` in `Bun.spawn`. This is because Node.js and Bun use different JavaScript engines with different object serialization formats. -```ts bun-node-ipc.js icon="file-code" +```js bun-node-ipc.js icon="file-code" if (typeof Bun !== "undefined") { const prefix = `[bun ${process.versions.bun} πŸ‡]`; const node = Bun.spawn({ diff --git a/docs/runtime/cookies.mdx b/docs/runtime/cookies.mdx index 641dfc7989..0d90bd0420 100644 --- a/docs/runtime/cookies.mdx +++ b/docs/runtime/cookies.mdx @@ -9,7 +9,7 @@ Bun provides native APIs for working with HTTP cookies through `Bun.Cookie` and `Bun.CookieMap` provides a Map-like interface for working with collections of cookies. It implements the `Iterable` interface, allowing you to use it with `for...of` loops and other iteration methods. -```ts filename="cookies.ts" icon="/icons/typescript.svg" +```ts title="cookies.ts" icon="/icons/typescript.svg" // Empty cookie map const cookies = new Bun.CookieMap(); @@ -33,7 +33,7 @@ const cookies3 = new Bun.CookieMap([ In Bun's HTTP server, the `cookies` property on the request object (in `routes`) is an instance of `CookieMap`: -```ts filename="server.ts" icon="/icons/typescript.svg" +```ts title="server.ts" icon="/icons/typescript.svg" const server = Bun.serve({ routes: { "/": req => { @@ -68,7 +68,7 @@ console.log("Server listening at: " + server.url); Retrieves a cookie by name. Returns `null` if the cookie doesn't exist. -```ts filename="get-cookie.ts" icon="/icons/typescript.svg" +```ts title="get-cookie.ts" icon="/icons/typescript.svg" // Get by name const cookie = cookies.get("session"); @@ -81,7 +81,7 @@ if (cookie != null) { Checks if a cookie with the given name exists. -```ts filename="has-cookie.ts" icon="/icons/typescript.svg" +```ts title="has-cookie.ts" icon="/icons/typescript.svg" // Check if cookie exists if (cookies.has("session")) { // Cookie exists @@ -96,7 +96,7 @@ if (cookies.has("session")) { Adds or updates a cookie in the map. Cookies default to `{ path: "/", sameSite: "lax" }`. -```ts filename="set-cookie.ts" icon="/icons/typescript.svg" +```ts title="set-cookie.ts" icon="/icons/typescript.svg" // Set by name and value cookies.set("session", "abc123"); @@ -119,7 +119,7 @@ cookies.set(cookie); Removes a cookie from the map. When applied to a Response, this adds a cookie with an empty string value and an expiry date in the past. A cookie will only delete successfully on the browser if the domain and path is the same as it was when the cookie was created. -```ts filename="delete-cookie.ts" icon="/icons/typescript.svg" +```ts title="delete-cookie.ts" icon="/icons/typescript.svg" // Delete by name using default domain and path. cookies.delete("session"); @@ -135,7 +135,7 @@ cookies.delete({ Converts the cookie map to a serializable format. -```ts filename="cookie-to-json.ts" icon="/icons/typescript.svg" +```ts title="cookie-to-json.ts" icon="/icons/typescript.svg" const json = cookies.toJSON(); ``` @@ -145,7 +145,7 @@ Returns an array of values for Set-Cookie headers that can be used to apply all When using `Bun.serve()`, you don't need to call this method explicitly. Any changes made to the `req.cookies` map are automatically applied to the response headers. This method is primarily useful when working with other HTTP server implementations. -```ts filename="node-server.js" icon="file-code" +```js title="node-server.js" icon="file-code" import { createServer } from "node:http"; import { CookieMap } from "bun"; @@ -172,7 +172,7 @@ server.listen(3000, () => { `CookieMap` provides several methods for iteration: -```ts filename="iterate-cookies.ts" icon="/icons/typescript.svg" +```ts title="iterate-cookies.ts" icon="/icons/typescript.svg" // Iterate over [name, cookie] entries for (const [name, value] of cookies) { console.log(`${name}: ${value}`); @@ -205,7 +205,7 @@ cookies.forEach((value, name) => { Returns the number of cookies in the map. -```ts filename="cookie-size.ts" icon="/icons/typescript.svg" +```ts title="cookie-size.ts" icon="/icons/typescript.svg" console.log(cookies.size); // Number of cookies ``` @@ -213,7 +213,7 @@ console.log(cookies.size); // Number of cookies `Bun.Cookie` represents an HTTP cookie with its name, value, and attributes. -```ts filename="cookie-class.ts" icon="/icons/typescript.svg" +```ts title="cookie-class.ts" icon="/icons/typescript.svg" import { Cookie } from "bun"; // Create a basic cookie @@ -243,7 +243,7 @@ const objCookie = new Bun.Cookie({ ### Constructors -```ts filename="constructors.ts" icon="/icons/typescript.svg" +```ts title="constructors.ts" icon="/icons/typescript.svg" // Basic constructor with name/value new Bun.Cookie(name: string, value: string); @@ -259,7 +259,7 @@ new Bun.Cookie(options: CookieInit); ### Properties -```ts filename="cookie-properties.ts" icon="/icons/typescript.svg" +```ts title="cookie-properties.ts" icon="/icons/typescript.svg" cookie.name; // string - Cookie name cookie.value; // string - Cookie value cookie.domain; // string | null - Domain scope (null if not specified) @@ -278,7 +278,7 @@ cookie.httpOnly; // boolean - Accessible only via HTTP (not JavaScript) Checks if the cookie has expired. -```ts filename="is-expired.ts" icon="/icons/typescript.svg" +```ts title="is-expired.ts" icon="/icons/typescript.svg" // Expired cookie (Date in the past) const expiredCookie = new Bun.Cookie("name", "value", { expires: new Date(Date.now() - 1000), @@ -302,7 +302,7 @@ console.log(sessionCookie.isExpired()); // false Returns a string representation of the cookie suitable for a `Set-Cookie` header. -```ts filename="serialize-cookie.ts" icon="/icons/typescript.svg" +```ts title="serialize-cookie.ts" icon="/icons/typescript.svg" const cookie = new Bun.Cookie("session", "abc123", { domain: "example.com", path: "/admin", @@ -322,7 +322,7 @@ console.log(cookie.toString()); Converts the cookie to a plain object suitable for JSON serialization. -```ts filename="cookie-json.ts" icon="/icons/typescript.svg" +```ts title="cookie-json.ts" icon="/icons/typescript.svg" const cookie = new Bun.Cookie("session", "abc123", { secure: true, httpOnly: true, @@ -349,7 +349,7 @@ const jsonString = JSON.stringify(cookie); Parses a cookie string into a `Cookie` instance. -```ts filename="parse-cookie.ts" icon="/icons/typescript.svg" +```ts title="parse-cookie.ts" icon="/icons/typescript.svg" const cookie = Bun.Cookie.parse("name=value; Path=/; Secure; SameSite=Lax"); console.log(cookie.name); // "name" @@ -363,7 +363,7 @@ console.log(cookie.sameSite); // "lax" Factory method to create a cookie. -```ts filename="cookie-from.ts" icon="/icons/typescript.svg" +```ts title="cookie-from.ts" icon="/icons/typescript.svg" const cookie = Bun.Cookie.from("session", "abc123", { httpOnly: true, secure: true, @@ -373,7 +373,7 @@ const cookie = Bun.Cookie.from("session", "abc123", { ## Types -```ts filename="types.ts" icon="/icons/typescript.svg" +```ts title="types.ts" icon="/icons/typescript.svg" interface CookieInit { name?: string; value?: string; diff --git a/docs/runtime/debugger.mdx b/docs/runtime/debugger.mdx index c718f2632f..add9018b37 100644 --- a/docs/runtime/debugger.mdx +++ b/docs/runtime/debugger.mdx @@ -115,7 +115,7 @@ Here's a cheat sheet explaining the functions of the control flow buttons. ### Visual Studio Code Debugger -Experimental support for debugging Bun scripts is available in Visual Studio Code. To use it, you'll need to install the [Bun VSCode extension](https://bun.com/guides/runtime/vscode-debugger). +Experimental support for debugging Bun scripts is available in Visual Studio Code. To use it, you'll need to install the [Bun VSCode extension](/guides/runtime/vscode-debugger). --- diff --git a/docs/runtime/environment-variables.mdx b/docs/runtime/environment-variables.mdx index 529b5348af..087da9ef56 100644 --- a/docs/runtime/environment-variables.mdx +++ b/docs/runtime/environment-variables.mdx @@ -13,7 +13,7 @@ Bun reads the following files automatically (listed in order of increasing prece - `.env.production`, `.env.development`, `.env.test` (depending on value of `NODE_ENV`) - `.env.local` -```txt .env icon="settings" +```ini .env icon="settings" FOO=hello BAR=world ``` @@ -46,7 +46,7 @@ bun exec 'FOO=helloworld bun run dev' On Windows, `package.json` scripts called with `bun run` will automatically use the **bun shell**, making the following also cross-platform. -```json package.json +```json package.json icon="file-json" "scripts": { "dev": "NODE_ENV=development bun --watch app.ts", }, @@ -95,7 +95,7 @@ Explicitly provided environment files via `--env-file` will still be loaded even Bun supports double quotes, single quotes, and template literal backticks: -```txt .env icon="settings" +```ini .env icon="settings" FOO='hello' FOO="hello" FOO=`hello` @@ -105,7 +105,7 @@ FOO=`hello` Environment variables are automatically _expanded_. This means you can reference previously-defined variables in your environment variables. -```txt .env icon="settings" +```ini .env icon="settings" FOO=world BAR=hello$FOO ``` @@ -116,7 +116,7 @@ process.env.BAR; // => "helloworld" This is useful for constructing connection strings or other compound values. -```txt .env icon="settings" +```ini .env icon="settings" DB_USER=postgres DB_PASSWORD=secret DB_HOST=localhost @@ -126,7 +126,7 @@ DB_URL=postgres://$DB_USER:$DB_PASSWORD@$DB_HOST:$DB_PORT/$DB_NAME This can be disabled by escaping the `$` with a backslash. -```txt .env icon="settings" +```ini .env icon="settings" FOO=world BAR=hello\$FOO ``` diff --git a/docs/runtime/http/routing.mdx b/docs/runtime/http/routing.mdx index 37cb4b3545..418e421866 100644 --- a/docs/runtime/http/routing.mdx +++ b/docs/runtime/http/routing.mdx @@ -102,7 +102,7 @@ Bun.serve({ TypeScript parses route parameters when passed as a string literal, so that your editor will show autocomplete when accessing `request.params`. -```ts title="index.ts" +```ts title="index.ts" icon="/icons/typescript.svg" import type { BunRequest } from "bun"; Bun.serve({ diff --git a/docs/runtime/http/server.mdx b/docs/runtime/http/server.mdx index f230f1e7ea..59083df7f2 100644 --- a/docs/runtime/http/server.mdx +++ b/docs/runtime/http/server.mdx @@ -32,12 +32,8 @@ const server = Bun.serve({ // Redirect from /blog/hello to /blog/hello/world "/blog/hello": Response.redirect("/blog/hello/world"), - // Serve a file by buffering it in memory - "/favicon.ico": new Response(await Bun.file("./favicon.ico").bytes(), { - headers: { - "Content-Type": "image/x-icon", - }, - }), + // Serve a file by lazily loading it into memory + "/favicon.ico": Bun.file("./favicon.ico"), }, // (optional) fallback for unmatched routes: @@ -126,7 +122,7 @@ bun --port=4002 server.ts - `BUN_PORT` environment variable ```sh -bun_PORT=4002 bun server.ts +BUN_PORT=4002 bun server.ts ``` - `PORT` environment variable diff --git a/docs/runtime/http/websockets.mdx b/docs/runtime/http/websockets.mdx index 2b005c488a..657da9f40b 100644 --- a/docs/runtime/http/websockets.mdx +++ b/docs/runtime/http/websockets.mdx @@ -174,7 +174,7 @@ Bun.serve({ To connect to this server from the browser, create a new `WebSocket`. -```ts browser.js icon="file-code" +```js browser.js icon="file-code" const socket = new WebSocket("ws://localhost:3000/chat"); socket.addEventListener("message", event => { diff --git a/docs/runtime/index.mdx b/docs/runtime/index.mdx index 7ffa1d0a9b..9a01aa2e73 100644 --- a/docs/runtime/index.mdx +++ b/docs/runtime/index.mdx @@ -94,7 +94,7 @@ Cleaning... Done. ``` -Bun executes the script command in a subshell. On Linux & macOS, it checks for the following shells in order, using the first one it finds: `bash`, `sh`, `zsh`. On windows, it uses [bun shell](https://bun.com/docs/runtime/shell) to support bash-like syntax and many common commands. +Bun executes the script command in a subshell. On Linux & macOS, it checks for the following shells in order, using the first one it finds: `bash`, `sh`, `zsh`. On Windows, it uses [bun shell](/runtime/shell) to support bash-like syntax and many common commands. ⚑️ The startup time for `npm run` on Linux is roughly 170ms; with Bun it is `6ms`. @@ -153,7 +153,7 @@ bun run --filter 'ba*'