Skip to content

Cloudflare Pages Setup

Step-by-step guide for deploying a new site.


Create a new repo on GitHub and push the project:

Terminal window
git init
git add .
git commit -m "feat: initial build"
git remote add origin https://github.com/<org>/<repo>.git
git push -u origin main

  1. Log in to dash.cloudflare.com
  2. Go to Workers & Pages -> Create application -> Pages -> Connect to Git
  3. Authorise GitHub if not already done
  4. Select the repo -> click Begin setup

Setting Value
Production branch main
Build command npm run build
Build output directory dist
Root directory (leave empty)

Click Save and Deploy.


After the first deploy:

  1. Go to the Pages project -> Custom domains
  2. Click Set up a custom domain
  3. Enter domain.com -> confirm
  4. Repeat for www.domain.com

Cloudflare auto-creates the CNAME records for both when you add them through the Pages dashboard - no manual DNS editing needed (as long as the domain’s DNS is already on Cloudflare).


Go to the Pages project -> Settings -> Environment variables -> Production.

For sites with Cashfree payments:

Variable Value
CASHFREE_APP_ID From Cashfree dashboard
CASHFREE_SECRET_KEY From Cashfree dashboard
CASHFREE_ENV production

Click Save. Trigger a new deploy after setting variables.


  • Visit https://domain.com - should load
  • Visit https://www.domain.com - should redirect to https://domain.com
  • Visit https://domain.com/robots.txt - should show sitemap URL
  • Visit https://domain.com/sitemap-index.xml - should list pages

Every push to main triggers a new build automatically. No manual action needed after the initial setup.


Every pull request gets a temporary preview URL (<hash>.pages.dev). Useful for reviewing changes before merging.