Static site
import { PagesBuildPreset, Render } from "~/components";
:::note
Use this guide when you specifically want to deploy a Next.js static export to Cloudflare Pages. For Next.js on Workers, Cloudflare recommends vinext, which also supports static exports.
:::
Next.js is an open-source React framework for creating websites and applications. In this guide, you will create a static Next.js application and deploy it using Cloudflare Pages.
This guide will instruct you how to deploy a static site Next.js project with static exports.
Select your Next.js project
If you already have a Next.js project that you wish to deploy, ensure that it is configured for static exports, change to its directory, and proceed to the next step. Otherwise, use create-next-app to create a new Next.js project.
npx create-next-app --example with-static-export my-app
After creating your project, a new my-app directory will be generated using the official with-static-export example as a template. Change to this directory to continue.
cd my-app
Create a GitHub repository
Create a new GitHub repository by visiting repo.new. After creating a new repository, prepare and push your local application to GitHub by running the following commands in your terminal:
git remote add origin https://github.com/<GH_USERNAME>/<REPOSITORY_NAME>.git
git branch -M main
git push -u origin main
Deploy your application to Cloudflare Pages
<Render file="deploy-to-pages-steps-with-preset" product="pages" params={{ name: "Next.js (Static HTML Export)" }} />
After configuring your site, you can begin your first deploy. Cloudflare Pages will install next, your project dependencies, and build your site before deploying it.
Preview your site
After deploying your site, you will receive a unique subdomain for your project on *.pages.dev.
Every time you commit new code to your Next.js site, Cloudflare Pages will automatically rebuild your project and deploy it. You will also get access to preview deployments on new pull requests, so you can preview how changes look to your site before deploying them to production.
For the complete guide to deploying your first site to Cloudflare Pages, refer to the Get started guide.
谢谢你的反馈!