11# Cloudflare Pages Deployment Guide
22
3- This guide covers deploying the COC Website to Cloudflare Pages using ` @cloudflare/next-on-pages ` .
3+ This guide covers deploying the COC Website to Cloudflare Pages using OpenNext Cloudflare adapter .
44
55## Prerequisites
66
@@ -59,17 +59,16 @@ For local testing with Wrangler:
5959
60603 . Run the development server:
6161 ``` bash
62- npx wrangler pages dev -- npm run dev
62+ npx wrangler dev
6363 ```
6464
6565### 5. Deploy to Cloudflare Pages
6666
67- #### Option A: Direct Upload (Recommended for CI/CD )
67+ #### Option A: Direct Upload (Recommended)
6868
6969``` bash
70- npm run build
71- npx @cloudflare/next-on-pages@1
72- npx wrangler pages deploy .vercel/output --project-name=coc-website
70+ npm run build:cf
71+ npx wrangler pages deploy .open-next --project-name=coc-website
7372```
7473
7574#### Option B: GitHub Integration
@@ -78,8 +77,8 @@ npx wrangler pages deploy .vercel/output --project-name=coc-website
78772 . Navigate to ** Pages** → ** Create a project**
79783 . Connect your GitHub repository
80794 . Configure build settings:
81- - ** Build command** : ` npx @cloudflare/next-on-pages@1 `
82- - ** Build output directory** : ` .vercel/output/static `
80+ - ** Build command** : ` npm run build:cf `
81+ - ** Build output directory** : ` .open-next `
8382 - ** Root directory** : ` / `
84835 . Add all secrets in ** Settings** → ** Environment variables** → ** Production** → ** Add variable**
8584
@@ -118,9 +117,9 @@ npx wrangler secret put <SECRET_NAME>
118117
119118### Middleware Issues
120119
121- The middleware uses Supabase for authentication. Ensure:
122- - ` SUPABASE_SERVICE_ROLE_KEY ` is correctly set as a secret
123- - Your Supabase project is accessible from Cloudflare's edge network
120+ The middleware uses NextAuth for authentication. Ensure:
121+ - ` NEXTAUTH_SECRET ` is correctly set as a secret
122+ - Your authentication provider is properly configured
124123
125124### Worker Size Limit Exceeded
126125
@@ -135,7 +134,8 @@ If your build exceeds Cloudflare's worker size limit:
135134```
136135├── .dev.vars.example # Template for local development variables
137136├── wrangler.toml # Cloudflare Pages configuration
138- ├── next.config.mjs # Next.js config (standalone output disabled for Cloudflare)
137+ ├── open-next.config.ts # OpenNext configuration
138+ ├── next.config.mjs # Next.js config
139139└── middleware.ts # Edge middleware for auth protection
140140```
141141
@@ -146,16 +146,26 @@ If your build exceeds Cloudflare's worker size limit:
146146``` toml
147147name = " coc-website"
148148compatibility_flags = [" nodejs_compat" ]
149- compatibility_date = " 2025-01 -01"
149+ compatibility_date = " 2026-02 -01"
150150
151151[build ]
152- command = " npx @cloudflare/next-on-pages@1 "
152+ command = " npm run build && npx @opennextjs/cloudflare build "
153153
154154[vars ]
155155NODE_VERSION = " 22"
156156NEXT_OUTPUT_STANDALONE = " false"
157157```
158158
159+ ### open-next.config.ts
160+
161+ ``` typescript
162+ import { defineCloudflareConfig } from " @opennextjs/cloudflare" ;
163+
164+ export default defineCloudflareConfig ({
165+ // Default configuration for Cloudflare Pages
166+ });
167+ ```
168+
159169### next.config.mjs
160170
161171The ` output: 'standalone' ` setting is disabled for Cloudflare builds. It's only enabled for Docker deployments via the ` NEXT_OUTPUT_STANDALONE ` environment variable.
@@ -174,10 +184,13 @@ npx wrangler tail
174184
175185# Open project in browser
176186npx wrangler pages project open coc-website
187+
188+ # Local development
189+ npx wrangler dev
177190```
178191
179192## Additional Resources
180193
181194- [ Cloudflare Pages Documentation] ( https://developers.cloudflare.com/pages/ )
182- - [ next-on-pages GitHub ] ( https://github.com /cloudflare/next-on-pages )
195+ - [ OpenNext Cloudflare ] ( https://opennext.js.org /cloudflare )
183196- [ Wrangler CLI Docs] ( https://developers.cloudflare.com/workers/wrangler/ )
0 commit comments