Choorai
Free Hosting

Deploy with Cloudflare Pages

Deploy frontend apps like React, Vue, and Astro for free. Automatic deployment every time you push via GitHub integration.

Why Cloudflare Pages?

  • Free (unlimited requests, unlimited bandwidth)
  • Fast speeds with global CDN
  • Automatic HTTPS
  • Auto-deploy via GitHub integration

1Push Code to GitHub

Your code must be in a GitHub repository to deploy.

Terminal
# Initialize repository (if first time)
git init

# Add files
git add .

# Commit
git commit -m "Initial commit"

# Connect GitHub repository (if first time)
git remote add origin https://github.com/username/my-project.git

# Push
git push -u origin main

Info

If you don't have a GitHub repository, create one at github.com/new.

2Configure Cloudflare Pages

  1. Sign up for Cloudflare (free)
  2. Click Workers & Pages in the dashboard
  3. Select Create applicationPages
  4. Click Connect to Git
  5. Connect your GitHub account and select repository

Build Settings (by framework)

React + Vite

  • Build command: npm run build
  • Build output: dist

Next.js

  • Build command: npx @cloudflare/next-on-pages@1
  • Build output: .vercel/output/static

Astro

  • Build command: npm run build
  • Build output: dist

3SPA Routing Configuration

SPAs using React Router or similar require additional configuration. This prevents 404 errors on page refresh.

public/_redirects
/* /index.html 200

Create this file in the public folder.

What happens without this?

Refreshing on a page like /about will result in a 404. See Fixing SPA 404 Errors for details.

4Environment Variables (if needed)

Set sensitive information like API keys as environment variables.

  1. Cloudflare dashboard → Select project
  2. SettingsEnvironment variables
  3. Add variable (e.g., VITE_API_URL)
  4. Can distinguish between Production/Preview environments

Info

When using Vite, environment variable names must start with VITE_. See Fixing Environment Variable Errors for details.

5Custom Domain (optional)

A default project-name.pages.dev domain is provided. Additional configuration is needed to use your own domain.

  1. Project → Custom domains
  2. Click Set up a custom domain
  3. Enter domain (e.g., myapp.com)
  4. Follow DNS setup instructions

Tip

If you manage your domain with Cloudflare DNS, it connects automatically. For other DNS providers, you'll need to add a CNAME record.

Deployment Checklist

0/5 done

Deployment Complete!

Congratulations!

Your app will now automatically deploy every time you push code to GitHub. Check it at project-name.pages.dev.

Last updated: February 22, 2026 · Version: v0.0.1

Send Feedback

Opens a new issue page with your message.

Open GitHub Issue