Build an app with Nuxt and Bun
Bun supports Nuxt with no extra configuration. Initialize a Nuxt app with the official nuxi CLI.
$ bunx nuxi init my-nuxt-app
✔ Which package manager would you like to use?
bun
◐ Installing dependencies...
bun install v1.3.14 (16b4bf34)
+ @nuxt/devtools@0.8.2
+ nuxt@3.7.0
785 packages installed [2.67s]
✔ Installation completed.
✔ Types generated in .nuxt
✨ Nuxt project has been created with the v3 template. Next steps:
› cd my-nuxt-app
› Start development server with bun run devTo start the dev server, run bun --bun run dev from the project root. This executes the nuxt dev command defined in the "dev" script in package.json.
The nuxt CLI uses Node.js by default; passing the --bun flag forces the dev server to use the Bun runtime instead.
$ cd my-nuxt-app
$ bun --bun run dev
$ nuxt dev
Nuxi 3.6.5
Nuxt 3.6.5 with Nitro 2.5.2
> Local: http://localhost:3000/
> Network: http://192.168.0.21:3000/
> Network: http://[fd8a:d31d:481c:4883:1c64:3d90:9f83:d8a2]:3000/
✔ Nuxt DevTools is enabled v0.8.0 (experimental)
ℹ Vite client warmed up in 547ms
✔ Nitro built in 244 msOnce the dev server starts, open http://localhost:3000 to see the app. It renders Nuxt's built-in NuxtWelcome template component.
To start developing your app, replace <NuxtWelcome /> in app.vue with your own UI.
For production builds, the default preset is compatible with Bun, but the Bun preset generates better optimized builds.
export default defineNuxtConfig({
nitro: {
preset: "bun",
},
});Alternatively, set the preset with an environment variable:
$ NITRO_PRESET=bun bun run buildSome packages provide Bun-specific exports that Nitro does not bundle correctly with the default preset. Use the Bun preset so those packages work in production builds.
After building, start the server:
$ bun run ./.output/server/index.mjsRefer to the Nuxt website for complete documentation.