-
-
Notifications
You must be signed in to change notification settings - Fork 725
docs: Clarify Cloudflare Pages and D1 #3587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SolidKalium
wants to merge
1
commit into
nuxt:main
Choose a base branch
from
SolidKalium:patch-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,35 +7,51 @@ description: Deploy your Content app to Cloudflare Pages | |||||||||||
| Quick Setup | ||||||||||||
|
|
||||||||||||
| 1. Use `nuxi build --preset=cloudflare_pages` to build your app | ||||||||||||
| 2. Create D1 database and connect to your project in Cloudflare Dashboard under `DB` binding name | ||||||||||||
| 2. Create and connect a D1 database to your project in the Cloudflare Dashboard using binding name `DB` | ||||||||||||
| 3. Deploy/Redeploy your app | ||||||||||||
| :: | ||||||||||||
|
|
||||||||||||
| :hr | ||||||||||||
|
|
||||||||||||
| Nuxt Content module has a built-in integration with [Cloudflare Pages](https://pages.cloudflare.com) to deploy your content. | ||||||||||||
| The Nuxt Content module has a built-in integration with [Cloudflare Pages](https://pages.cloudflare.com) to deploy your content. | ||||||||||||
|
|
||||||||||||
| Module will automatically detects the build target and prepare the necessary configuration for Cloudflare Pages. | ||||||||||||
| The Module will automatically detect the build target and prepare the necessary configuration for Cloudflare Pages. | ||||||||||||
|
|
||||||||||||
| You can either use `--preset=cloudflare_pages` option on `nuxi build` command or use `nuxt.config.ts` to configure the preset. | ||||||||||||
| You can either use the `--preset=cloudflare_pages` option with the `nuxi build` command or use `nuxt.config.ts` to configure the preset. | ||||||||||||
|
|
||||||||||||
| ```ts | ||||||||||||
| ```ts [nuxt.config.ts] | ||||||||||||
| export default defineNuxtConfig({ | ||||||||||||
| nitro: { | ||||||||||||
| preset: 'cloudflare_pages', | ||||||||||||
| }, | ||||||||||||
| }); | ||||||||||||
| ``` | ||||||||||||
|
|
||||||||||||
| The module requires a D1 database to be connected to the app in order to work. By default it will use the `DB` binding name. You can override the database configuration by providing your own database configuration 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`. | ||||||||||||
|
|
||||||||||||
| After creating a new Cloudflare Pages project, you need to create a new D1 database and connect it to the project. Make sure to use the same binding name as the module is using. (default is `DB`) | ||||||||||||
| After creating a new Cloudflare Pages project, you need to create a new D1 database and connect it to the project. Make sure to use the same binding name as the module is using. | ||||||||||||
|
|
||||||||||||
| ### 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. | ||||||||||||
|
Comment on lines
+35
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
|
|
||||||||||||
| ```jsonc [wrangler.jsonc] | ||||||||||||
| { | ||||||||||||
| "d1_databases": [ | ||||||||||||
| { | ||||||||||||
| "binding": "DB", | ||||||||||||
| "database_name": "example-db", | ||||||||||||
| "database_id": "example-db-id" | ||||||||||||
| } | ||||||||||||
| ] | ||||||||||||
| } | ||||||||||||
| ``` | ||||||||||||
|
|
||||||||||||
| That's it :tada: | ||||||||||||
|
|
||||||||||||
| Checkout: | ||||||||||||
| Relevant resources: | ||||||||||||
|
|
||||||||||||
| - [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/) | ||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
| - [Cloudflare Pages documentation](https://developers.cloudflare.com/pages/) | ||||||||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.