> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/oven-sh/bun/llms.txt
> Use this file to discover all available pages before exploring further.

# Next.js with Bun

> Use Bun as the package manager and script runner for a Next.js project for faster installs and development workflows.

[Next.js](https://nextjs.org/) is a React framework for building full-stack web applications with server-side rendering, static site generation, API routes, and more. Bun speeds up package installation and script execution for Next.js projects.

<Note>
  Next.js still uses Node.js as its runtime for SSR and API routes. Bun acts as the package manager and script runner. Use `bun --bun` to run Next.js CLI commands inside Bun's runtime.
</Note>

<Steps>
  <Step title="Create a Next.js app">
    Scaffold a new Next.js project using Bun:

    ```bash theme={null}
    bun create next-app@latest my-bun-app
    ```

    The interactive CLI will ask about TypeScript, ESLint, Tailwind CSS, and the App Router. Bun installs dependencies automatically after scaffolding.
  </Step>

  <Step title="Start the dev server">
    Change into the project directory and start the Next.js dev server with Bun's runtime:

    ```bash theme={null}
    cd my-bun-app
    bun --bun run dev
    ```

    Open [http://localhost:3000](http://localhost:3000) in your browser. Changes to `app/page.tsx` are hot-reloaded automatically.
  </Step>

  <Step title="Update package.json scripts">
    Prefix the Next.js CLI commands with `bun --bun` so that all scripts run inside Bun's runtime:

    ```json package.json theme={null}
    {
      "scripts": {
        "dev": "bun --bun next dev",
        "build": "bun --bun next build",
        "start": "bun --bun next start",
        "lint": "next lint"
      }
    }
    ```

    With this in place, `bun run dev`, `bun run build`, and `bun run start` all use Bun's runtime.
  </Step>
</Steps>

## Common commands

| Task                    | Command                |
| ----------------------- | ---------------------- |
| Install dependencies    | `bun install`          |
| Start dev server        | `bun run dev`          |
| Build for production    | `bun run build`        |
| Start production server | `bun run start`        |
| Run linter              | `bun run lint`         |
| Add a package           | `bun add <package>`    |
| Remove a package        | `bun remove <package>` |

## Performance benefits

Using Bun as the package manager for Next.js projects provides:

* **Faster installs**: `bun install` is significantly faster than `npm install` or `yarn install` due to parallelism and a global package cache.
* **Faster script startup**: Running Next.js CLI commands through Bun reduces the overhead of spawning child processes.
* **Lockfile compatibility**: `bun.lock` is committed to version control like `package-lock.json` or `yarn.lock`.

## Deployment

Next.js on Bun deploys to all major platforms:

<CardGroup cols={3}>
  <Card title="Vercel" href="/guides/vercel">
    Deploy on Vercel
  </Card>

  <Card title="Railway" href="/guides/railway">
    Deploy on Railway
  </Card>

  <Card title="AWS Lambda" href="/guides/aws-lambda">
    Deploy on AWS Lambda
  </Card>
</CardGroup>

***

See the [Next.js documentation](https://nextjs.org/docs) for a complete reference on building and deploying Next.js applications.
