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

# 在 Render 上部署 Bun 应用

[Render](https://render.com/) 是一个用于构建、部署和扩展应用程序的云平台。

它提供来自 GitHub 的自动部署、全球 CDN、私有网络、自动 HTTPS 设置以及托管的 PostgreSQL 和 Redis。

Render 原生支持 Bun。你可以将 Bun 应用部署为 Web 服务、后台 Worker、定时任务等。

***

作为示例，本指南将一个 Express HTTP 服务器部署到 Render。

<Steps>
  <Step title="第 1 步">
    创建一个名为 `myapp` 的新 GitHub 仓库。在本地克隆它。

    ```sh theme={null}
    git clone git@github.com:my-github-username/myapp.git
    cd myapp
    ```
  </Step>

  <Step title="第 2 步">
    添加 Express 库。

    ```sh theme={null}
    bun add express
    ```
  </Step>

  <Step title="第 3 步">
    使用 Express 定义一个服务器：

    ```ts app.ts icon="https://mintcdn.com/span-inc/82N53aP7NFbaCVSl/icons/typescript.svg?fit=max&auto=format&n=82N53aP7NFbaCVSl&q=85&s=787d39d6a7d96d7f9540dc74344eba23" theme={null}
    import express from "express";

    const app = express();
    const port = process.env.PORT || 3001;

    app.get("/", (req, res) => {
    	res.send("Hello World!");
    });

    app.listen(port, () => {
    	console.log(`Listening on port ${port}...`);
    });
    ```
  </Step>

  <Step title="第 4 步">
    提交更改并推送到 GitHub。

    ```sh terminal icon="terminal" theme={null}
    git add app.ts bun.lock package.json
    git commit -m "Create simple Express app"
    git push origin main
    ```
  </Step>

  <Step title="第 5 步">
    在你的 [Render 仪表盘](https://dashboard.render.com/) 中，点击 `New` > `Web Service` 并连接你的 `myapp` 仓库。
  </Step>

  <Step title="第 6 步">
    在 Render 界面中，在创建 Web 服务时提供以下值：

    |          |               |
    | -------- | ------------- |
    | **运行时**  | `Node`        |
    | **构建命令** | `bun install` |
    | **启动命令** | `bun app.ts`  |
  </Step>
</Steps>

构建完成后，你的 Web 服务将在其分配的 `onrender.com` URL 上运行。

查看[部署日志](https://docs.render.com/logging#logs-for-an-individual-deploy-or-job)以了解详情。更多关于部署的信息，请参见 [Render 的文档](https://docs.render.com/deploys)。
