Cloudflare Workers
Quick Setup
- Use
cloudflare_module
preset and compatibility date of2024-09-19
or later. - Create a D1 database and connect it to your project in the Cloudflare Dashboard under the
DB
binding name, and configure the database configuration in thenuxt.config.ts
file. - Build and deploy your app
The Nuxt Content module has a built-in integration with Cloudflare Workers to deploy your content.
The module will automatically detect the build target and prepare the necessary configuration for Cloudflare Workers.
All you need to do is create a Cloudflare D1 database and connect it to your project. After creating a D1 database, you should
define the database configuration in the nuxt.config.ts
file with the nitro.cloudflare.wrangler.d1_databases
option.
By default, the module will use the DB
binding name. You can override the database configuration by providing your own database configuration in nuxt.config.ts
.
export default defineNuxtConfig({
compatibilityDate: "2025-05-15",
nitro: {
preset: 'cloudflare_module',
cloudflare: {
deployConfig: true,
wrangler: {
d1_databases: [
{
binding: 'DB',
database_name: 'database-name',
database_id: '*********-***-****-****-*********'
}
]
},
},
}
})
nuxt.config.ts
. Check out Database Configuration2024-09-19
or later.Build your project with the nuxi build
command, and you can deploy the project with the wrangler deploy
command.
npx wrangler deploy
That's it! 🎉
Check out: