Skip to content

部署

¥Deploying

Next.js 可以部署为 Node.js 服务器、Docker 容器、静态导出,或适配在不同平台上运行。

¥Next.js can be deployed as a Node.js server, Docker container, static export, or adapted to run on different platforms.

部署选项功能支持
Node.js 服务器全部
Docker 容器全部
静态导出受限
适配器平台相关

Node.js 服务器

¥Node.js server

Next.js 可以部署到任何支持 Node.js 的提供商。确保你的 package.json 具有 "build""start" 脚本:

¥Next.js can be deployed to any provider that supports Node.js. Ensure your package.json has the "build" and "start" scripts:

然后,运行 npm run build 来构建你的应用,并运行 npm run start 来启动 Node.js 服务器。该服务器支持所有 Next.js 功能。如果需要,你还可以弹出到 定制服务器

¥Then, run npm run build to build your application and npm run start to start the Node.js server. This server supports all Next.js features. If needed, you can also eject to a custom server.

Node.js 部署支持所有 Next.js 功能。了解如何为你的基础架构进行 配置它们

¥Node.js deployments support all Next.js features. Learn how to configure them for your infrastructure.

模板

¥Templates

Docker

Next.js 可以部署到任何支持 Docker 容器的提供商。这包括容器编排器(例如 Kubernetes)或运行 Docker 的云提供商。

¥Next.js can be deployed to any provider that supports Docker containers. This includes container orchestrators like Kubernetes or a cloud provider that runs Docker.

Docker 部署支持所有 Next.js 功能。了解如何为你的基础架构进行 配置它们

¥Docker deployments support all Next.js features. Learn how to configure them for your infrastructure.

模板

¥Templates

静态导出

¥Static export

Next.js 支持以静态站点或 单页应用 (SPA) 模式启动,之后可选择升级以使用需要服务器的功能。

¥Next.js enables starting as a static site or Single-Page Application (SPA), then later optionally upgrading to use features that require a server.

由于 Next.js 支持 静态导出,因此它可以部署和托管在任何能够提供 HTML/CSS/JS 静态资源的 Web 服务器上。这包括 AWS S3、Nginx 或 Apache 等工具。

¥Since Next.js supports static exports, it can be deployed and hosted on any web server that can serve HTML/CSS/JS static assets. This includes tools like AWS S3, Nginx, or Apache.

作为 静态导出 运行不支持需要服务器的 Next.js 功能。了解更多

¥Running as a static export does not support Next.js features that require a server. Learn more.

模板

¥Templates

适配器

¥Adapters

Next.js 可以适应在不同平台上运行,以支持其基础设施功能。

¥Next.js can be adapted to run on different platforms to support their infrastructure capabilities.

有关支持的 Next.js 功能的信息,请参阅每个提供商的文档:

¥Refer to each provider's documentation for information on supported Next.js features:

注意:我们正在开发一个适用于所有平台的 部署适配器 API。完成后,我们将添加有关如何编写你自己的适配器的文档。

¥Note: We are working on a Deployment Adapters API for all platforms to adopt. After completion, we will add documentation on how to write your own adapters.