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

# Build an app with Next.js and Bun

[Next.js](https://nextjs.org/) is a React framework for building full-stack web applications. It supports server-side rendering, static site generation, and API routes. Bun installs packages fast and can run Next.js development and production servers.

***

**1. Create a new Next.js app**

Use the interactive CLI to scaffold a new Next.js project and install its dependencies.

```sh terminal icon="terminal" theme={"theme":{"light":"github-light","dark":"dracula"}}
bun create next-app@latest my-bun-app
```

**2. Start the dev server**

Change to the project directory and run the dev server with Bun.

```sh terminal icon="terminal" theme={"theme":{"light":"github-light","dark":"dracula"}}
cd my-bun-app
bun --bun run dev
```

This starts the Next.js dev server with Bun's runtime.

Open [`http://localhost:3000`](http://localhost:3000) in your browser to see the result. Changes you make to `app/page.tsx` are hot-reloaded in the browser.

**3. Update scripts in package.json**

Prefix the Next.js CLI commands in your `package.json` scripts with `bun --bun` so that Bun executes the Next.js CLI for `dev`, `build`, and `start`.

```json package.json icon="file-json" theme={"theme":{"light":"github-light","dark":"dracula"}}
{
  "scripts": {
    "dev": "bun --bun next dev", // [!code ++]
    "build": "bun --bun next build", // [!code ++]
    "start": "bun --bun next start" // [!code ++]
  }
}
```

***

## Hosting

> [card] [Vercel](https://bun.com/docs/guides/deployment/vercel.md)
>
> Deploy on Vercel

> [card] [Railway](https://bun.com/docs/guides/deployment/railway.md)
>
> Deploy on Railway

> [card] [DigitalOcean](https://bun.com/docs/guides/deployment/digital-ocean.md)
>
> Deploy on DigitalOcean

> [card] [AWS Lambda](https://bun.com/docs/guides/deployment/aws-lambda.md)
>
> Deploy on AWS Lambda

> [card] [Google Cloud Run](https://bun.com/docs/guides/deployment/google-cloud-run.md)
>
> Deploy on Google Cloud Run

> [card] [Render](https://bun.com/docs/guides/deployment/render.md)
>
> Deploy on Render

***

## Templates

> [card] [Bun + Next.js Basic Starter](https://github.com/bun-templates/bun-nextjs-basic)
>
> A basic App Router starter with Bun, Next.js, and Tailwind CSS.

> [card] [Todo App with Next.js + Bun](https://github.com/bun-templates/bun-nextjs-todo)
>
> A full-stack todo application built with Bun, Next.js, and PostgreSQL.

***

Refer to the [Next.js documentation](https://nextjs.org/docs) for more on building and deploying Next.js applications.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.