This project is configured for deployment on Cloudflare Pages, providing a fast, secure, and globally distributed hosting solution.
- Cloudflare Account: Sign up at cloudflare.com
- Wrangler CLI: Install globally
npm install -g wrangler # or bun install -g wrangler - Authentication: Login to Cloudflare
wrangler login
-
Build the project:
bun run pages:build
-
Deploy to Cloudflare Pages:
# Deploy to preview bun run pages:deploy # Deploy to production bun run pages:deploy:production
-
Connect Repository:
- Go to Cloudflare Dashboard → Pages
- Click "Create a project"
- Connect your GitHub/GitLab repository
- Select the
deltaviewrepository
-
Configure Build Settings:
Build command: bun run pages:build Build output directory: dist Root directory: / Environment variables: (none required by default) -
Framework preset: Select "None" or "Static Site"
-
Branch deployment:
- Production branch:
mainormaster - Preview branches: All other branches
- Production branch:
Create .github/workflows/deploy.yml:
name: Deploy to Cloudflare Pages
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install dependencies
run: bun install
- name: Build
run: bun run pages:build
- name: Deploy to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: deltaview
directory: dist
gitHubToken: ${{ secrets.GITHUB_TOKEN }}Required Secrets (add in GitHub repository settings):
CLOUDFLARE_API_TOKEN: Get from Cloudflare Dashboard → My Profile → API TokensCLOUDFLARE_ACCOUNT_ID: Get from Cloudflare Dashboard → Workers & Pages
Main configuration for Cloudflare Workers/Pages. Defines:
- Project name
- Build output directory
- Environment variables
- Custom domains (optional)
HTTP headers for security and caching:
- Security headers (XSS protection, CSP, etc.)
- Cache control for static assets
- Asset immutability for optimal performance
SPA routing configuration:
- Redirects all routes to
index.html - Ensures React Router works correctly
-
Add domain in Cloudflare Dashboard:
- Pages → Your Project → Custom domains
- Add your domain (e.g.,
deltaview.refactorroom.com)
-
Update DNS:
- Add CNAME record pointing to your Pages URL
- Or use Cloudflare's automatic DNS setup
-
Update
wrangler.toml:[env.production] routes = [ { pattern = "yourdomain.com", custom_domain = true } ]
Add environment variables in:
- Dashboard: Cloudflare Dashboard → Pages → Project → Settings → Environment variables
- Local: Create
.dev.varsfile (gitignored)
Example .dev.vars:
NODE_ENV=production
API_URL=https://api.example.com
Test your site locally with Cloudflare's environment:
# Build first
bun run pages:build
# Run local Pages dev server
bun run pages:devThis simulates the Cloudflare Pages environment locally.
- Dashboard: View analytics at Cloudflare Dashboard → Pages → Your Project
- Real-time logs: Use
wrangler pages deployment tail - Web Analytics: Enable in Cloudflare Dashboard for privacy-friendly analytics
Cloudflare Pages keeps all deployments:
- Go to Dashboard → Pages → Your Project → Deployments
- Select any previous deployment
- Click "Rollback to this deployment"
Cloudflare Pages automatically provides:
- ✅ Global CDN with 275+ locations
- ✅ HTTP/3 and QUIC support
- ✅ Automatic HTTPS with certificates
- ✅ DDoS protection
- ✅ Brotli compression
- ✅ Image optimization (with Cloudflare Images)
- Check build command in dashboard matches
bun run pages:build - Ensure
distdirectory is set as build output - Verify all dependencies are in
package.json
- Ensure
public/_redirectsfile exists - Verify SPA fallback is configured:
/* /index.html 200
- Check
public/_headersfor correct cache headers - Verify asset paths are relative or absolute
- Check browser console for CORS errors
| Script | Description |
|---|---|
bun run pages:build |
Build production bundle for Cloudflare Pages |
bun run pages:deploy |
Deploy to preview environment |
bun run pages:deploy:production |
Deploy to production |
bun run pages:dev |
Run local Cloudflare Pages dev server |
For support, visit Cloudflare Community or Discord.