Getting started
Installation and setup with Next-Cloudflare-Turbo
Prerequisites
- Node v22.17.0 (LTS). Earlier version may still work
- Free Cloudflare account
Quick start
Get up and running with Next-Cloudflare-Turbo locally.
Installation & Local Setup
Clone and install
git clone https://github.com/cording12/next-cloudflare-turbo.gitFrom the project directory, run:
npm installAuthenticate with Cloudflare
npx wrangler loginThis opens your browser to authorise Wrangler with your Cloudflare account.
Validation (optional)
Run npx wrangler whoami to confirm authentication worked.
npx wrangler whoamiRun database setup script
npm run setup:dbThis creates the D1 database, runs migrations, and adds seed data.
Running the project locally
The following commands should be run from the project root to fully leverage the power of the Turbo monorepo.
The turbo.json at the project root contains the configuration for the monorepo. This means that all dependencies of a task are automatically run (and cached where configured).
Run locally
npm install turbo run devRun in preview
The final step is to test the Next.js application works in the context of a Cloudflare Worker.
npm run previewIf you only want to preview one application (instead of both), you can alternatively run npm run preview:app or npm run preview:docs
Deployment
After you have finished the initial setup, and tested it works using npm run preview, you need to apply migrations and seed the remote database before deploying to Cloudflare.
npm run setup:db script. For a more detailed understanding, see Manual setupApply remote database migrations
npm run db:migrate:prodSeed the remote database
npm run db:seed:prodDeploy the application to Cloudflare
npm run deploy:appAfter successfully deploying your application, the CLI will give you your domain to visit the live Worker. For Next-Cloudflare-Turbo, this is a custom domain, but for you it will be a worker.dev URL.
✨ Success! Uploaded 6 files (41 already uploaded) (2.82 sec)
Total Upload: 10751.33 KiB / gzip: 2066.24 KiB
Worker Startup Time: 27 ms
Your Worker has access to the following bindings:
Binding Resource
env.DB (test-new-db) D1 Database
env.WORKER_SELF_REFERENCE (next-cloudflare-turbo) Worker
env.ASSETS Assets
Uploaded next-cloudflare-turbo (19.65 sec)
Deployed next-cloudflare-turbo triggers (6.08 sec)
app.cording.dev (custom domain)
Current Version ID: e185c6e3-b32b-4d38-879c-872c119819a2FAQ
Next steps
How is this guide?
Last updated on