Skip to content

Conversation

@SolidKalium
Copy link

Emphasize the necessity of creating a D1 database and how to configure wrangler so nuxi preview works.

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Changes

  • Places more emphasis on a D1 database being required
  • Provides a minimal example wrangler config for running preview locally
  • Explains what this example config does
  • Links to Nuxt Content's docs section for D1 configuration
  • Links more directly to Cloudflare's documentation about creating and binding a D1 database

Why

My initial reading of the statement that the module will "prepare the necessary configuration" caused me to misunderstand the importance of D1 being required. I think the new emphasis should help prevent that misreading.

I also had trouble running nuxi preview locally to check a mismatch between local and prod behavior. I no longer recall if nuxi preview actually helped me solve my problems, but I suspect other people probably don't want to be stuck configuring preview when they think it will help debugging something else.

For context, the issues I was debugging (and have since resolved) were:

  • Some content not loading correctly. This was likely because another source told me to use generate instead of build, and I then also didn't have D1 set up.
  • An infinite 404 loop. This was likely caused by the fact that I didn't have an error.vue file and the fact that my default slug was throwing a 404 when content was missing. But local dev was ok because it provides an error page.
  • A file I created postbuild wasn't being added to _routes, because _routes is created during build and I didn't understand that part of Cloudflare enough to expect the issue.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Emphasize the necessity of creating a D1 database and how to configure wrangler so `nuxi preview` works.
@vercel
Copy link

vercel bot commented Oct 27, 2025

@SolidKalium is attempting to deploy a commit to the NuxtLabs Team on Vercel.

A member of the Team first needs to authorize it.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 27, 2025

npm i https://pkg.pr.new/@nuxt/content@3587

commit: 8aa82f9

Copy link
Member

@atinux atinux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update spacing

Comment on lines +35 to +36
### Local Preview
While `nuxi dev` and `nuxi build` don't require any extra configuration, testing a build locally with `nuxi preview` requires Cloudflare's Wrangler to be configured to provide a temporary, local database for Nuxt Content to bind. This can be done with a `wrangler.jsonc` or `wrangler.toml` file. Because Wrangler creates a local database, `database_name` and `database_id` can safely, but don't need to, match the values in production.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Local Preview
While `nuxi dev` and `nuxi build` don't require any extra configuration, testing a build locally with `nuxi preview` requires Cloudflare's Wrangler to be configured to provide a temporary, local database for Nuxt Content to bind. This can be done with a `wrangler.jsonc` or `wrangler.toml` file. Because Wrangler creates a local database, `database_name` and `database_id` can safely, but don't need to, match the values in production.
### Local Preview
While `nuxi dev` and `nuxi build` don't require any extra configuration, testing a build locally with `nuxi preview` requires Cloudflare's Wrangler to be configured to provide a temporary, local database for Nuxt Content to bind. This can be done with a `wrangler.jsonc` or `wrangler.toml` file. Because Wrangler creates a local database, `database_name` and `database_id` can safely, but don't need to, match the values in production.


- [Nuxt Deploy documentation](https://nuxt.com/deploy/cloudflare)
- [Cloudflare D1 documentation](https://developers.cloudflare.com/d1/)
- [Create and bind a D1 database](https://developers.cloudflare.com/d1/get-started/)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [Create and bind a D1 database](https://developers.cloudflare.com/d1/get-started/)
- [Create and bind a D1 database](https://developers.cloudflare.com/d1/get-started/)

Comment on lines +30 to +31
## D1 Database
A D1 database connected to the app is **required** for the Nuxt Content module to work. By default the module uses the binding name **`DB`**. You can override the [database configuration](/docs/getting-started/configuration#d1) by providing your own in `nuxt.config.ts`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## D1 Database
A D1 database connected to the app is **required** for the Nuxt Content module to work. By default the module uses the binding name **`DB`**. You can override the [database configuration](/docs/getting-started/configuration#d1) by providing your own in `nuxt.config.ts`.
## D1 Database
A D1 database connected to the app is **required** for the Nuxt Content module to work. By default the module uses the binding name **`DB`**. You can override the [database configuration](/docs/getting-started/configuration#d1) by providing your own in `nuxt.config.ts`.

@atinux
Copy link
Member

atinux commented Oct 27, 2025

Thank you for your help, would you be happy to also update the Cloudflare Workers page @SolidKalium ?

@SolidKalium
Copy link
Author

I haven't built for that target directly and don't have a plan to. So I don't think I'd be a good author for that. But feel free to copy over any relevant content I added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants