1.5 KiB
1.5 KiB
Deploying to Cloudflare Pages
This Next.js app is configured to run on Cloudflare Pages with full server-side functionality.
Prerequisites
-
Install Wrangler CLI globally: ```bash npm install -g wrangler ```
-
Login to Cloudflare: ```bash wrangler login ```
Local Development
Run the app locally with Cloudflare Workers simulation: ```bash npm run preview ```
Build for Cloudflare
Build the app for Cloudflare Pages: ```bash npm run pages:build ```
This creates a .vercel/output/static directory with your built app.
Deploy to Cloudflare Pages
Option 1: Command Line Deployment
```bash npm run deploy ```
Option 2: Cloudflare Dashboard
- Go to Cloudflare Pages
- Create a new project
- Connect your Git repository
- Set build settings:
- Build command:
npm run pages:build - Build output directory:
.vercel/output/static - Root directory:
/
- Build command:
Environment Variables
Add these environment variables in Cloudflare Pages dashboard:
STRIPE_SECRET_KEYSTRIPE_PUBLISHABLE_KEYNEXT_PUBLIC_STRIPE_PUBLISHABLE_KEYSTRIPE_WEBHOOK_SECRETSENDGRID_API_KEY- For sending notification emails (thank you emails after purchases)
Important Notes
- API routes run as Cloudflare Workers
- Stripe webhooks will need to be updated to your Cloudflare Pages URL
- All server-side features (API routes, dynamic rendering) are fully supported
- The app uses Edge Runtime for optimal performance on Cloudflare's network