Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions docs/start/framework/react/hosting.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ Once you've chosen a deployment target, you can follow the deployment guidelines
### Cloudflare Workers

When deploying to Cloudflare Workers, you'll need to complete a few extra steps before your users can start using your app.
1. Install `@cloudflare/vite-plugin`

1. Update `vite.config.ts`
```bash
pnpm install @cloudflare/vite-plugin -D
```

2. Update `vite.config.ts`

Add the cloudflare plugin to your `vite.config.ts` file.

Expand All @@ -60,8 +65,13 @@ export default defineConfig({
],
})
```
3. Install `wrangler`

```bash
pnpm add wrangler -D
```

2. Add a `wrangler.json` config file
4. Add a `wrangler.json` config file

```json
{
Expand All @@ -76,6 +86,28 @@ export default defineConfig({
}
```

5. Modify package.json script

```json

{
"scripts": {
"dev": "vite dev",
"build": "vite build && tsc --noEmit",
"start": "node .output/server/index.mjs",
// ============ 👇 add this line ============
"deploy": "wrangler deploy"
},
}

```
Comment on lines +91 to +103
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

JSON snippet is invalid (comments and trailing comma).

The example uses a JSON code fence with comments and a trailing comma, which will not parse. Use jsonc or remove comments and trailing comma.

-```json
-
-{
-    "scripts": {
-    "dev": "vite dev",
-    "build": "vite build && tsc --noEmit",
-    "start": "node .output/server/index.mjs",
-    // ============ 👇 add this line ============
-    "deploy": "wrangler deploy"
-  },
-}
-
-```
+```jsonc
+{
+  "scripts": {
+    "dev": "vite dev",
+    "build": "vite build && tsc --noEmit",
+    "start": "node .output/server/index.mjs",
+    // 👇 add this line
+    "deploy": "wrangler deploy"
+  }
+}
+```
🤖 Prompt for AI Agents
In docs/start/framework/react/hosting.md around lines 91-103, the JSON example
uses a code-fence labeled json but contains JS-style comments and a trailing
comma which makes it invalid; change the fence to jsonc or remove the comment
and trailing comma so the snippet is valid JSON (either replace the fence with
```jsonc and keep the inline comment, or remove the comment line and the
trailing comma after the scripts object so it remains valid ```json).


6. Build and deploy

```bash
pnpm run build && pnpm run deploy
```

Deploy your application to Cloudflare Workers using their one-click deployment process, and you're ready to go!

### Netlify ⭐ _Official Partner_
Expand Down