> ## Documentation Index
> Fetch the complete documentation index at: https://bun.zhcndoc.com/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 服务、后台工作进程、定时任务等进行部署。

***

As an example, let's deploy an Express HTTP server to Render.

<Steps>
  <Step title="步骤 1">
    创建一个名为 `myapp` 的新的 GitHub 仓库。将其克隆到本地。

    ```sh theme={"theme":{"light":"github-light","dark":"dracula"}}
    git clone git@github.com:my-github-username/myapp.git
    cd myapp
    ```
  </Step>

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

    ```sh theme={"theme":{"light":"github-light","dark":"dracula"}}
    bun add express
    ```
  </Step>

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

    ```ts app.ts icon="https://mintcdn.com/bun-zhcndoc/cnUTwgMuf4cCrwC-/icons/typescript.svg?fit=max&auto=format&n=cnUTwgMuf4cCrwC-&q=85&s=e7767043c9e885c34f2d6c8fe2a95217" theme={"theme":{"light":"github-light","dark":"dracula"}}
    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={"theme":{"light":"github-light","dark":"dracula"}}
    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 服务时填写以下内容：

    |                          |               |
    | ------------------------ | ------------- |
    | **运行环境 (Runtime)**       | `Node`        |
    | **构建命令 (Build Command)** | `bun install` |
    | **启动命令 (Start Command)** | `bun app.ts`  |
  </Step>
</Steps>

就是这样！构建完成后，你的 Web 服务将在分配的 `onrender.com` URL 上线。

你可以查看[部署日志](https://docs.render.com/logging#logs-for-an-individual-deploy-or-job)了解详情。完整的 Render 部署介绍，请参考[Render 文档](https://docs.render.com/deploys)。
