|
| 1 | +# Deploy a Next.js site |
| 2 | + |
| 3 | +Next.js is an open-source React framework for creating websites and apps. In this guide, you'll create a new Next.js application and deploy it using Cloudflare Pages. |
| 4 | + |
| 5 | +## Creating a new project |
| 6 | + |
| 7 | +Create a new project using npx |
| 8 | +```sh |
| 9 | +npx create-next-app |
| 10 | +``` |
| 11 | + |
| 12 | +## Creating a GitHub repository |
| 13 | + |
| 14 | +Create a new GitHub repository by visiting [repo.new](https://repo.new). Once you've created a new repository, you can push your local application to GitHub: |
| 15 | + |
| 16 | +```sh |
| 17 | +$ git remote add origin https://github.com/yourgithubusername/githubrepo |
| 18 | +$ git branch -M main |
| 19 | +$ git push -u origin main |
| 20 | +``` |
| 21 | + |
| 22 | +## Deploying with Cloudflare Pages |
| 23 | + |
| 24 | +You can deploy your site to Cloudflare Pages by going to the dashboard, and creating a new site. Select your new GitHub repository that you created above, and in the configuration section, provide the following information: |
| 25 | + |
| 26 | +<TableLayout> |
| 27 | + |
| 28 | +| Configuration option | Value | |
| 29 | +| -------------------- | --------------------------- | |
| 30 | +| Production branch | `main` | |
| 31 | +| Build command | `next build && next export` | |
| 32 | +| Build directory | `out` | |
| 33 | + |
| 34 | +</TableLayout> |
| 35 | + |
| 36 | +Once you've configured your site, you can begin your first deploy. You should see Cloudflare Pages installing `next`, your project dependencies, and building your site, before deploying it. |
| 37 | + |
| 38 | +<Aside> |
| 39 | + |
| 40 | +For the complete guide to deploying your first site to Cloudflare Pages, check out [our Getting Started guide](/getting-started). |
| 41 | + |
| 42 | +</Aside> |
| 43 | + |
| 44 | +Once you've deployed your site, you'll 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'll also get access to [preview deployments](/platform/preview-deployments) on new pull requests, so you can preview how changes look to your site before deploying them to production. |
| 45 | + |
| 46 | +## Learn more |
| 47 | + |
| 48 | +Congrats, you've deployed your Next.js site on Cloudflare Pages! To learn more about what you can do with the platform, [check out our How-To section](/how-to). |
0 commit comments