feat(templates): add with-cloudflare-website template #14864
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Description
What?
Adds a new template
with-cloudflare-websitethat combines the full-featured Website template with Cloudflare D1 (SQLite) database and R2 object storage infrastructure.Why?
Currently, Payload offers:
websitetemplate - Full-featured website/blog template with MongoDBwith-cloudflare-d1template - Basic Cloudflare D1/R2 setup with minimal collectionsUsers who want to deploy a production-ready website on Cloudflare's edge network had to manually merge these two templates. This new template provides an out-of-the-box solution for deploying the complete website template on Cloudflare Workers.
Use cases:
How?
Created a new template based on website with the following modifications:
Database & Storage:
@payloadcms/db-d1-sqlite(Cloudflare D1)@payloadcms/storage-r2plugin for media storageCloudflare Configuration:
wrangler.jsoncwith D1 and R2 bindingsopen-next.config.tsfor OpenNext/Cloudflare integrationnext.config.jstonext.config.tsfor better TypeScript supportPayload Config Changes:
Media Collection:
cropandfocalPointfeatures (sharp not available on Workers)Dynamic Rendering:
export const dynamic = 'force-dynamic'to all pages/layoutsgenerateStaticParamsfrom pages (static generation not supported without env vars at build time)Scripts:
deploy- Full deployment (database + app)deploy:database- Apply migrations to remote D1deploy:app- Build and deploy to Cloudflare Workersmigrate:create/migrate:fresh- Migration utilitiespreview- Local preview with Cloudflare bindingsDocumentation:
templates/with-cloudflare-website/
├── wrangler.jsonc # Cloudflare Workers config
├── cloudflare-env.d.ts # TypeScript bindings
├── open-next.config.ts # OpenNext config
├── next.config.ts # Next.js config
├── src/
│ ├── payload.config.ts # D1 + R2 adapters
│ ├── collections/
│ │ └── Media.ts # Disabled sharp features
│ └── migrations/
│ ├── index.ts
│ └── 20251208_*.ts # Initial migration
└── ... # All website template files
Collections Included
All collections from the website template:
Dependencies
@payloadcms/db-d1-sqlite- D1 database adapter@payloadcms/storage-r2- R2 storage pluginwrangler- Cloudflare CLITesting