How to deploy your Next.js site from GitHub to Cloudflare or Vercel, step by step

Connect your repository once and every change goes live by itself. Here’s which host to pick, the exact settings, your domain, and how to roll back.

Londynn Metten

· 8 min read

You’ll end up with

Your site live on your own domain, redeploying itself on every change

Time
About 45 minutes
Cost
Free, or $20 a month
Level
Beginner

The short answer

To deploy a Next.js site from GitHub, sign in to Vercel or Cloudflare with your GitHub account, import your site’s repository, and let it build. Vercel detects Next.js and needs no settings. Cloudflare works best for a simple marketing site exported as static files: add output: "export" to your Next.js config, then pick the Next.js (Static HTML Export) preset. After that, every change merged into your main branch goes live on its own, every branch gets a preview link, and you can roll back to any earlier version in one click.

01

Should you use Vercel or Cloudflare?

Both are good. Both publish from GitHub automatically. The difference is mostly price and how much of Next.js your site uses.

VercelCloudflare
Setup for Next.jsNothing to configureTwo lines in your config for a static site
Price for a business site$20 a month on ProFree plan covers a typical small site
Free planHobby, personal and non-commercial onlyYes, commercial use allowed
Server features (forms handled on your own server, logins, live data)All supportedStatic export: no. Full Next.js: possible, more setup
Preview link for every branchYesYes
One-click rollbackYesYes
Plans and prices as of November 2026, from each host’s pricing pages.

Our rule of thumb: a marketing site with pages, images and a form service goes on Cloudflare as a static site. A site with logins or live data goes on Vercel.

Vercel’s free plan is the trap here. It’s for personal projects, and a business site counts as commercial, so budget for Pro or pick Cloudflare.

02

How do you deploy to Vercel?

  1. 01Go to vercel.com and sign up with your GitHub account. Choose the Pro plan if this is a business site.
  2. 02Click Add New, then Project.
  3. 03Vercel asks to install its GitHub app. Choose “Only select repositories” and pick your site’s repository. It doesn’t need the rest.
  4. 04Click Import next to your repository. Vercel detects Next.js and fills in every setting.
  5. 05Click Deploy. In a minute or two you get a live address ending in .vercel.app.

That’s it. From now on, merging into main deploys the live site, and every pull request gets its own preview link posted right on GitHub.

03

How do you deploy to Cloudflare?

First, tell Next.js to build plain files. Open next.config.mjs (or next.config.ts) in your repository and add two settings. Commit it to main, using the steps from editing your own Next.js site.

/** @type {import('next').NextConfig} */
const nextConfig = {
  output: "export",              // build the site as plain files in /out
  images: { unoptimized: true }, // serve images as they are
}

export default nextConfig
If your config already has other settings, keep them and add these two lines inside the same braces.
  1. 01Sign up at dash.cloudflare.com. The free plan is fine.
  2. 02Go to Workers & Pages, click Create, and choose the Pages option to import an existing Git repository.
  3. 03Connect GitHub and give Cloudflare access to only your site’s repository.
  4. 04Pick the repository. For the framework preset, choose “Next.js (Static HTML Export)”. It fills in the build command (npx next build) and the output folder (out).
  5. 05Click Save and Deploy. A few minutes later you have a live address ending in .pages.dev.
Set up builds and deployments

Production branch

main

Framework preset1

Next.js (Static HTML Export)

Build command2

npx next build

Build output directory3

out
Save and Deploy

Simplified drawing · labels may differ

  1. 1Pick the static Next.js preset. It fills in the next two for you.
  2. 2Builds your site into plain files.
  3. 3Where those files land. Matches output: “export” in your config.
The three settings that matter on Cloudflare, all filled in by the preset.

If the build fails and the error mentions output: export, a page on your site needs a server. Either move that feature to a service, or deploy on Vercel, or follow Cloudflare’s full Next.js guide.

Cloudflare moves fast and its menus get renamed. If a label here doesn’t match your screen, look for the move it describes: import a GitHub repository, choose the static Next.js preset, deploy.

04

How do you connect your own domain?

  1. 01In your project, open the domains section (Settings, then Domains on Vercel; Custom domains on Cloudflare) and add your domain, both yoursite.com and www.yoursite.com.
  2. 02The host shows you one or two records to add. Log in where your domain is registered, open its DNS settings, and add exactly what it shows.
  3. 03If your domain already uses Cloudflare for DNS, Cloudflare adds the records for you.
  4. 04Pick one address as the real one (we use www) and let the host redirect the other to it.
  5. 05Wait. Usually minutes, sometimes a few hours. The host shows a green check when it’s done and turns on HTTPS by itself.

Don’t touch your MX records. Those run your email. You’re only adding web records.

DNS settings, where your domain is registered

  • A / CNAME@@ · your new hostAdd what the host shows
  • CNAMEwwwwww · your new hostAdd what the host shows
  • MX@@ · your email providerLeave alone
  • TXT@@ · email + verificationLeave alone
Add the web records your host shows you. Leave the email records exactly as they are.

Once the domain works, make sure your site tells Google to index your real domain and not the .vercel.app or .pages.dev address. It’s the most common thing to go wrong right after this step. The check and the fix are in why Google is indexing the wrong domain.

05

How do you bring your old WordPress URLs with you?

Every page address from your old site needs to land somewhere real. On Vercel, a full Next.js site can list redirects in its config. On a static Cloudflare site, add a plain text file named _redirects inside the public folder, one line per old address.

/about-us/                  /about        301
/our-services/              /services     301
/2024/05/spring-hours/      /blog/hours   301
/contact-us/                /contact      301
public/_redirects on Cloudflare. Old address, new address, 301 for “moved for good”. Old addresses that differ only by a ?query, like ?page_id=12, can’t be matched in this file; set those up as a Redirect Rule in your Cloudflare dashboard instead.

Your old sitemap is the list to work from. Part one, how to leave WordPress, covers saving it before you switch.

06

What happens every time you change something now?

1 · Check it on a preview

Your draft

The change, on a branch.

Preview link

Its own address, posted on GitHub.

You check it

On a phone and a computer.

2 · Publish it

Publish

Merge the draft into the live site (“main”).

Host updates

Usually 1 to 3 minutes.

Live on your domain

Everyone sees the change.

Build fails?Nothing changes. The last good version stays live, and you can roll back any time.
Drafts get a preview. Publishing updates the live site. If something breaks, the live site stays as it was.
  • Merge into main and the host rebuilds the live site, usually in one to three minutes.
  • Open a pull request and the host builds a preview of just that branch, at its own address, and posts the link on GitHub.
  • If a build fails, the live site doesn’t change. The last good version stays up.
  • To roll back, open your project’s list of deployments, pick the last good one, and promote or roll back to it. One click on either host.
07

What should you check after the first deploy?

  1. 01Open every page on your phone and on a computer, on the real domain.
  2. 02Send a test message through every form and confirm it arrives.
  3. 03Visit three or four old WordPress addresses and confirm they redirect.
  4. 04View the page source and check the canonical link uses your real domain.
  5. 05Add your sitemap (yoursite.com/sitemap.xml) in Google Search Console.
  6. 06Write down where your domain, DNS, host and GitHub logins live.

Then, the fun part. Part five: editing your site with Claude, ChatGPT or Grok, with prompts you can copy.

08

Where the simple setup stops

A static export has no server. That rules out API routes, server actions, middleware, and anything that changes per visitor on the server. Forms still work through a form service, and anything interactive in the browser still works. Logins and live data don’t, without more setup.

Next.js redirects listed in the config also don’t run in a static export. Use the _redirects file instead.

And hosting plans change. The free tiers here are generous today, but check the current terms once a year, especially Vercel’s rule on commercial use.

Common questions

Is Cloudflare or Vercel cheaper for a Next.js site?
For a small business marketing site, Cloudflare is usually cheaper because its free plan allows commercial use and static file requests don’t count against your limits. Vercel’s free Hobby plan is for non-commercial use, so a business site needs Pro, which is $20 a month as of November 2026.
Can I switch hosts later?
Yes. Your site lives on GitHub, not on the host. Connect the same repository to the other host, check the new preview, then move your domain’s records. Nothing about the code is tied to one host, except a few settings you can change back.
How long does it take for my domain to work?
Usually a few minutes to a couple of hours after you add the records. In rare cases it can take up to 48 hours while the old records expire around the world. The host’s dashboard shows when it’s confirmed.
What does output: "export" actually do?
It tells Next.js to build every page as a plain HTML file in a folder called out, instead of running a server. Plain files are fast, cheap to host, and have nothing to hack, which is why Cloudflare can host them for free.
Will my site go down while it redeploys?
No. The host builds the new version alongside the old one and switches over only when the build succeeds. If it fails, the old version stays live.

Keep going

More you can build yourself

Up next · Part 5

How to edit your website with Claude, ChatGPT or Grok, with prompts you can copy

10 minutes an editBeginner

Playbook · Part 3

How to edit your own Next.js website without breaking it

15 minutes a changeBeginner

Playbook · Part 2

What are Git and GitHub, and why does your website need them?

About 30 minutesBeginner

Build it yourself

How to ship a one-page website with Claude, v0, and GitHub in 90 minutes

About 90 minutesBeginner

Build it yourself

How to write one prompt that gets a usable answer on the first try

About 10 minutesBeginner

Build it yourself

How to get on Google Maps, then actually get reviews

About 1 hourBeginner

Build it yourself

How to build a brand kit you can actually reuse

About 2 hoursBeginner

Playbook · Part 1

How to leave WordPress for a site you actually own

1 to 3 daysBeginner

Build it yourself

How to run your AI assistant in the terminal, where it can see your actual files

20 minutes to set upIntermediate

Build it yourself

How to turn a workflow you keep repeating into an AI skill that fires on its own

About 1 hourIntermediate

Fix what broke

How to tell if your contact form is silently dropping leads

About 30 minutesBeginner

Fix what broke

Why scroll animations hide content from some visitors

About 15 minutesAdvanced

Fix what broke

Why Google is indexing the wrong domain for your site

About 20 minutesIntermediate

Your site is live and publishes itself. Last part: letting an AI assistant make the edits for you.

Read part 5