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.
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.
| Vercel | Cloudflare | |
|---|---|---|
| Setup for Next.js | Nothing to configure | Two lines in your config for a static site |
| Price for a business site | $20 a month on Pro | Free plan covers a typical small site |
| Free plan | Hobby, personal and non-commercial only | Yes, commercial use allowed |
| Server features (forms handled on your own server, logins, live data) | All supported | Static export: no. Full Next.js: possible, more setup |
| Preview link for every branch | Yes | Yes |
| One-click rollback | Yes | Yes |
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.
How do you deploy to Vercel?
- 01Go to vercel.com and sign up with your GitHub account. Choose the Pro plan if this is a business site.
- 02Click Add New, then Project.
- 03Vercel asks to install its GitHub app. Choose “Only select repositories” and pick your site’s repository. It doesn’t need the rest.
- 04Click Import next to your repository. Vercel detects Next.js and fills in every setting.
- 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.
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- 01Sign up at dash.cloudflare.com. The free plan is fine.
- 02Go to Workers & Pages, click Create, and choose the Pages option to import an existing Git repository.
- 03Connect GitHub and give Cloudflare access to only your site’s repository.
- 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).
- 05Click Save and Deploy. A few minutes later you have a live address ending in .pages.dev.
Production branch
Framework preset1
Build command2
Build output directory3
Simplified drawing · labels may differ
- 1Pick the static Next.js preset. It fills in the next two for you.
- 2Builds your site into plain files.
- 3Where those files land. Matches output: “export” in your config.
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.
How do you connect your own domain?
- 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.
- 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.
- 03If your domain already uses Cloudflare for DNS, Cloudflare adds the records for you.
- 04Pick one address as the real one (we use www) and let the host redirect the other to it.
- 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
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.
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 301Your old sitemap is the list to work from. Part one, how to leave WordPress, covers saving it before you switch.
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.
- 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.
What should you check after the first deploy?
- 01Open every page on your phone and on a computer, on the real domain.
- 02Send a test message through every form and confirm it arrives.
- 03Visit three or four old WordPress addresses and confirm they redirect.
- 04View the page source and check the canonical link uses your real domain.
- 05Add your sitemap (yoursite.com/sitemap.xml) in Google Search Console.
- 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.
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
Your site is live and publishes itself. Last part: letting an AI assistant make the edits for you.
Read part 5