mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
Docs: Minor fixes and improvements (#25284)
This PR addresses several issues opened for the docs: - Add callout for SQLite caching behavior between prepare() and query() - Fix SQLite types and fix deprecated exec to run - Fix Secrets API example - Update SolidStart guide - Add bun upgrade guide - Prefer `process.versions.bun` over `typeof Bun` for detection - Document complete `bunx` flags - Improve Nitro preset documentation for Nuxt Fixes #23165, #24424, #24294, #25175, #18433, #16804, #22967, #22527, #10560, #14744
This commit is contained in:
@@ -74,6 +74,12 @@ export default defineNuxtConfig({
|
||||
});
|
||||
```
|
||||
|
||||
Alternatively, you can set the preset via environment variable:
|
||||
|
||||
```sh terminal icon="terminal"
|
||||
NITRO_PRESET=bun bun run build
|
||||
```
|
||||
|
||||
<Note>
|
||||
Some packages provide Bun-specific exports that Nitro will not bundle correctly using the default preset. In this
|
||||
case, you need to use Bun preset so that the packages will work correctly in production builds.
|
||||
|
||||
@@ -4,63 +4,59 @@ sidebarTitle: "SolidStart with Bun"
|
||||
mode: center
|
||||
---
|
||||
|
||||
<Warning>
|
||||
SolidStart currently relies on Node.js APIs that Bun does not yet implement. The guide below uses Bun to initialize a
|
||||
project and install dependencies, but it uses Node.js to run the dev server.
|
||||
</Warning>
|
||||
|
||||
---
|
||||
|
||||
Initialize a SolidStart app with `create-solid`.
|
||||
Initialize a SolidStart app with `create-solid`. You can specify the `--solidstart` flag to create a SolidStart project, and `--ts` for TypeScript support. When prompted for a template, select `basic` for a minimal starter app.
|
||||
|
||||
```sh terminal icon="terminal"
|
||||
bun create solid my-app
|
||||
bun create solid my-app --solidstart --ts
|
||||
```
|
||||
|
||||
```txt
|
||||
create-solid version 0.2.31
|
||||
|
||||
Welcome to the SolidStart setup wizard!
|
||||
|
||||
There are definitely bugs and some feature might not work yet.
|
||||
If you encounter an issue, have a look at
|
||||
https://github.com/solidjs/solid-start/issues and open a new one,
|
||||
if it is not already tracked.
|
||||
|
||||
✔ Which template do you want to use? › todomvc
|
||||
✔ Server Side Rendering? … yes
|
||||
✔ Use TypeScript? … yes
|
||||
cloned solidjs/solid-start#main to /path/to/my-app/.solid-start
|
||||
✔ Copied project files
|
||||
┌
|
||||
Create-Solid v0.6.11
|
||||
│
|
||||
◇ Project Name
|
||||
│ my-app
|
||||
│
|
||||
◇ Which template would you like to use?
|
||||
│ basic
|
||||
│
|
||||
◇ Project created 🎉
|
||||
│
|
||||
◇ To get started, run: ─╮
|
||||
│ │
|
||||
│ cd my-app │
|
||||
│ bun install │
|
||||
│ bun dev │
|
||||
│ │
|
||||
├────────────────────────╯
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
As instructed by the `create-solid` CLI, let's install our dependencies.
|
||||
As instructed by the `create-solid` CLI, install the dependencies.
|
||||
|
||||
```sh terminal icon="terminal"
|
||||
cd my-app
|
||||
bun install
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Then run the development server.
|
||||
Then run the development server with `bun dev`.
|
||||
|
||||
```sh terminal icon="terminal"
|
||||
bun run dev
|
||||
# or, equivalently
|
||||
bunx solid-start dev
|
||||
bun dev
|
||||
```
|
||||
|
||||
---
|
||||
```txt
|
||||
$ vinxi dev
|
||||
vinxi v0.5.8
|
||||
vinxi starting dev server
|
||||
|
||||
➜ Local: http://localhost:3000/
|
||||
➜ Network: use --host to expose
|
||||
```
|
||||
|
||||
Open [localhost:3000](http://localhost:3000). Any changes you make to `src/routes/index.tsx` will be hot-reloaded automatically.
|
||||
|
||||
<Frame>
|
||||

|
||||
</Frame>
|
||||
|
||||
---
|
||||
|
||||
Refer to the [SolidStart website](https://start.solidjs.com/getting-started/what-is-solidstart) for complete framework documentation.
|
||||
Refer to the [SolidStart website](https://docs.solidjs.com/solid-start) for complete framework documentation.
|
||||
|
||||
@@ -4,22 +4,25 @@ sidebarTitle: Detect Bun
|
||||
mode: center
|
||||
---
|
||||
|
||||
The recommended way to conditionally detect when code is being executed with `bun` is to check for the existence of the `Bun` global.
|
||||
|
||||
This is similar to how you'd check for the existence of the `window` variable to detect when code is being executed in a browser.
|
||||
|
||||
```ts
|
||||
if (typeof Bun !== "undefined") {
|
||||
// this code will only run when the file is run with Bun
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
In TypeScript environments, the previous approach will result in a type error unless `@types/bun` is installed. To avoid this, you can check `process.versions` instead.
|
||||
The recommended way to detect when code is being executed with Bun is to check `process.versions.bun`. This works in both JavaScript and TypeScript without requiring any additional type definitions.
|
||||
|
||||
```ts
|
||||
if (process.versions.bun) {
|
||||
// this code will only run when the file is run with Bun
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Alternatively, you can check for the existence of the `Bun` global. This is similar to how you'd check for the existence of the `window` variable to detect when code is being executed in a browser.
|
||||
|
||||
<Note>
|
||||
This approach will result in a type error in TypeScript unless `@types/bun` is installed. You can install it with `bun
|
||||
add -d @types/bun`.
|
||||
</Note>
|
||||
|
||||
```ts
|
||||
if (typeof Bun !== "undefined") {
|
||||
// this code will only run when the file is run with Bun
|
||||
}
|
||||
```
|
||||
|
||||
93
docs/guides/util/upgrade.mdx
Normal file
93
docs/guides/util/upgrade.mdx
Normal file
@@ -0,0 +1,93 @@
|
||||
---
|
||||
title: Upgrade Bun to the latest version
|
||||
sidebarTitle: Upgrade Bun
|
||||
mode: center
|
||||
---
|
||||
|
||||
Bun can upgrade itself using the built-in `bun upgrade` command. This is the fastest way to get the latest features and bug fixes.
|
||||
|
||||
```bash terminal icon="terminal"
|
||||
bun upgrade
|
||||
```
|
||||
|
||||
This downloads and installs the latest stable version of Bun, replacing the currently installed version.
|
||||
|
||||
<Note>To see the current version of Bun, run `bun --version`.</Note>
|
||||
|
||||
---
|
||||
|
||||
## Verify the upgrade
|
||||
|
||||
After upgrading, verify the new version:
|
||||
|
||||
```bash terminal icon="terminal"
|
||||
bun --version
|
||||
# Output: 1.x.y
|
||||
|
||||
# See the exact commit of the Bun binary
|
||||
bun --revision
|
||||
# Output: 1.x.y+abc123def
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Upgrade to canary builds
|
||||
|
||||
Canary builds are automatically released on every commit to the `main` branch. These are untested but useful for trying new features or verifying bug fixes before they're released.
|
||||
|
||||
```bash terminal icon="terminal"
|
||||
bun upgrade --canary
|
||||
```
|
||||
|
||||
<Warning>Canary builds are not recommended for production use. They may contain bugs or breaking changes.</Warning>
|
||||
|
||||
---
|
||||
|
||||
## Switch back to stable
|
||||
|
||||
If you're on a canary build and want to return to the latest stable release:
|
||||
|
||||
```bash terminal icon="terminal"
|
||||
bun upgrade --stable
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Install a specific version
|
||||
|
||||
To install a specific version of Bun, use the install script with a version tag:
|
||||
|
||||
<Tabs>
|
||||
<Tab title="macOS & Linux">
|
||||
```bash terminal icon="terminal"
|
||||
curl -fsSL https://bun.sh/install | bash -s "bun-v1.3.3"
|
||||
```
|
||||
</Tab>
|
||||
<Tab title="Windows">
|
||||
```powershell PowerShell icon="windows"
|
||||
iex "& {$(irm https://bun.sh/install.ps1)} -Version 1.3.3"
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
---
|
||||
|
||||
## Package manager users
|
||||
|
||||
If you installed Bun via a package manager, use that package manager to upgrade instead of `bun upgrade` to avoid conflicts.
|
||||
|
||||
<Tip>
|
||||
**Homebrew users** <br />
|
||||
To avoid conflicts with Homebrew, use `brew upgrade bun` instead.
|
||||
|
||||
**Scoop users** <br />
|
||||
To avoid conflicts with Scoop, use `scoop update bun` instead.
|
||||
|
||||
</Tip>
|
||||
|
||||
---
|
||||
|
||||
## See also
|
||||
|
||||
- [Installation](/installation) — Install Bun for the first time
|
||||
- [Update packages](/pm/cli/update) — Update dependencies to latest versions
|
||||
Reference in New Issue
Block a user