Migrating a Next.js app from node:sqlite to Cloudflare D1

TL;DR AI
2 min readKey summary
A small Next.js app was migrated from Node.js’s built-in `node:sqlite` to Cloudflare D1 for deployment on Workers.
The schema was moved into a migration file, while the SQL itself changed very little.
The main code changes were switching from synchronous `DatabaseSync` calls to D1’s async `prepare/bind` API and awaiting route handlers.
The D1 binding was wired through the Workers context via OpenNext and `wrangler.jsonc`.
The example shows a low-friction path from local SQLite on Node.js to Cloudflare’s serverless database setup.
