Local Development
Shapeless uses OpenNextJS to support full monolithic deployment to Cloudflare Workers. That means you can develop locally using either the regular Next.js dev server, or emulate the actual Cloudflare environment—all from a single process.
🚀 Standard Dev Mode (Node.js)
Start the app with:
This runs the regular Next.js development server on:
It uses Node.js, so it's fast and has full support for React features like HMR, fast refresh, etc.
Use this when you're building UI and want a quick feedback loop.
🌐 Cloudflare Workers Preview Mode
To test how your app will behave on Cloudflare (with the Workers runtime and bindings like D1
, R2
, etc.), run:
This starts your app in Cloudflare Workers preview mode:
This simulates the production environment using Wrangler and OpenNextJS.
This mode is recommended when you need to test Cloudflare-specific behavior like:
- Worker compatibility (
globalThis
, fetch, etc.)- Database bindings (D1)
- Storage bindings (R2)
- Compatibility flags (
nodejs_compat
, etc.)
✅ API Client Config
Update your API client to match the preview mode when needed:
You can also make this dynamic with an .env.local
:
And then in .env.local
:
🛠 Available Scripts
From your package.json
:
dev
: regular Next.js dev server (Node.js)cf:preview
: run app on local Cloudflare worker runtimecf:build
: compile the app for Workerscf:upload
: deploy to production Cloudflarecf:gen
: generate Cloudflare bindings types
🧪 When to Use Each Mode
Goal | pnpm dev | pnpm cf:preview |
---|---|---|
Building UI quickly | ✅ | ✅ |
Testing D1 / R2 bindings | ✅ | ✅ |
Emulating production behavior | ✅ | ✅ |
Debugging layout / React | ✅ | ✅ |
That’s it — no dual terminal setup, no separate backend.
Shapeless + OpenNext = monolithic, edge-ready development, with full support for both Next.js DX and Cloudflare production behavior.