This guide covers deploying the COC Website to Cloudflare Pages using OpenNext Cloudflare adapter.
- Node.js >= 22.0.0 (check with
node -v) - Cloudflare account
- Wrangler CLI installed (
npm install -g wrangler)
npm installLogin to your Cloudflare account:
npx wrangler loginAll sensitive environment variables must be added as Cloudflare secrets (not in wrangler.toml):
# Google OAuth
npx wrangler secret put GOOGLE_CLIENT_ID
npx wrangler secret put GOOGLE_CLIENT_SECRET
# NextAuth
npx wrangler secret put NEXTAUTH_SECRET
# Supabase
npx wrangler secret put NEXT_PUBLIC_SUPABASE_ANON_KEY
npx wrangler secret put SUPABASE_SERVICE_ROLE_KEY
# JWT
npx wrangler secret put JWT_SECRETYou'll be prompted to enter each value interactively.
For local testing with Wrangler:
-
Copy
.dev.vars.exampleto.dev.vars:cp .dev.vars.example .dev.vars
-
Fill in your values in
.dev.vars -
Run the development server:
npx wrangler dev
npm run build:cf
npx wrangler pages deploy .open-next --project-name=coc-website- Go to Cloudflare Dashboard
- Navigate to Pages → Create a project
- Connect your GitHub repository
- Configure build settings:
- Build command:
npm run build:cf - Build output directory:
.open-next - Root directory:
/
- Build command:
- Add all secrets in Settings → Environment variables → Production → Add variable
For non-secret variables, add them in the Cloudflare Pages dashboard:
- Go to your project settings
- Navigate to Environment variables
- Add:
NEXT_OUTPUT_STANDALONE=falseNODE_VERSION=22
Ensure you're using Node.js >= 22.0.0:
node -v # Should show v22.x.x or higher
nvm use 22 # If using nvmIf you see errors about missing environment variables at runtime:
# List all secrets
npx wrangler secret list
# Re-add any missing secrets
npx wrangler secret put <SECRET_NAME>The middleware uses NextAuth for authentication. Ensure:
NEXTAUTH_SECRETis correctly set as a secret- Your authentication provider is properly configured
If your build exceeds Cloudflare's worker size limit:
- Check for large dependencies in your bundle
- Use dynamic imports for heavy components
- Consider moving server-heavy logic to API routes
├── .dev.vars.example # Template for local development variables
├── wrangler.toml # Cloudflare Pages configuration
├── open-next.config.ts # OpenNext configuration
├── next.config.mjs # Next.js config
└── middleware.ts # Edge middleware for auth protection
name = "coc-website"
compatibility_flags = ["nodejs_compat"]
compatibility_date = "2026-02-01"
[build]
command = "npm run build && npx @opennextjs/cloudflare build"
[vars]
NODE_VERSION = "22"
NEXT_OUTPUT_STANDALONE = "false"import { defineCloudflareConfig } from "@opennextjs/cloudflare";
export default defineCloudflareConfig({
// Default configuration for Cloudflare Pages
});The output: 'standalone' setting is disabled for Cloudflare builds. It's only enabled for Docker deployments via the NEXT_OUTPUT_STANDALONE environment variable.
# Check Wrangler version
wrangler --version
# View deployment logs
npx wrangler pages deployment list
# Tail deployment logs
npx wrangler tail
# Open project in browser
npx wrangler pages project open coc-website
# Local development
npx wrangler dev