Skip to content

Conversation

@TinsFox
Copy link
Contributor

@TinsFox TinsFox commented Sep 26, 2025

Summary by CodeRabbit

  • Documentation
    • Added step-by-step Cloudflare Workers deployment guide with explicit install and configure commands.
    • Documented installing and using the Cloudflare Vite plugin and updating Vite configuration.
    • Added guidance for setting up wrangler and a deploy script, plus a build-and-deploy workflow.
    • Included concrete configuration examples and code snippets to clarify sequencing and reduce friction.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 26, 2025

Walkthrough

Adds explicit, step-by-step Cloudflare Workers deployment instructions to the React hosting docs: add @cloudflare/vite-plugin install and plugin usage in vite.config.ts, show wrangler install and wrangler.json example, and provide concrete build/deploy commands and package.json script suggestions. (Docs-only change.)

Changes

Cohort / File(s) Summary of changes
Docs: React Hosting — Cloudflare Workers
docs/start/framework/react/hosting.md
Expanded Cloudflare Workers section with explicit installation steps for @cloudflare/vite-plugin, concrete vite.config.ts import/plugin usage, wrangler installation and usage, example wrangler.json, and package.json deploy/build+deploy commands and sequencing.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Developer as Developer
  participant Docs as docs/start/framework/react/hosting.md
  participant LocalEnv as Local dev env
  participant ViteCfg as vite.config.ts
  participant WranglerCfg as wrangler.json
  participant Cloudflare as Cloudflare Workers

  Developer->>Docs: Read Cloudflare Workers steps
  Note right of Docs: Install plugin, update vite config,\ncreate wrangler.json, add scripts
  Developer->>LocalEnv: run install commands\n(e.g., pnpm add -D @cloudflare/vite-plugin)
  LocalEnv->>ViteCfg: modify to import & use plugin
  LocalEnv->>WranglerCfg: create/configure `wrangler.json`
  Developer->>LocalEnv: run build + `wrangler deploy`
  LocalEnv->>Cloudflare: push deployment
  Cloudflare-->>Developer: deployment result (success/error)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

I hop through docs with nimble feet,
Vite and Workers now shall meet.
Wrangler wired, configs neat,
Build then deploy — a tasty treat. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title Check ❓ Inconclusive The title “Update hosting.md” is too generic and does not clearly convey the primary change of adding explicit, multi-step Cloudflare Workers deployment guidance to the hosting documentation, so it fails to inform reviewers at a glance what was actually updated. Its vague phrasing makes it unclear which sections or features were affected. Because it does not meaningfully summarize the key changes, the result is inconclusive. Please revise the title to clearly summarize the main change, for example: “Add explicit Cloudflare Workers deployment steps to hosting.md” so that it immediately reflects the specific documentation enhancements.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the documentation Everything documentation related label Sep 26, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
docs/start/framework/react/hosting.md (2)

43-47: Consider adding wrangler to devDependencies

You’re introducing wrangler.json below; most users will also need wrangler installed locally for builds/dev/deploys.

Add this alongside the plugin install:

pnpm add -D wrangler
# or: npm i -D wrangler / yarn add -D wrangler / bun add -d wrangler

69-82: Tighten wrangler.json example (schema path, compatibility_date, nodejs_compat_v2, main)

  • Prefix $schema with ./ to avoid resolution errors.
  • Set compatibility_date to today’s date (e.g. 2025-09-26) and ensure it covers Node compatibility.
  • Only include nodejs_compat_v2 in compatibility_flags if your Worker uses Node APIs.
  • Point main at your Worker entry file (e.g. ./src/index.ts) per @cloudflare/vite-plugin.
  • Prefer wrangler.jsonc for new projects, but wrangler.json remains supported.

Proposed tweaks:

 {
-  "$schema": "node_modules/wrangler/config-schema.json",
+  "$schema": "./node_modules/wrangler/config-schema.json",
   "name": "tanstack-start-app",
-  "compatibility_date": "2025-09-02",
-  "compatibility_flags": ["nodejs_compat"],
-  "main": "@tanstack/react-start/server-entry",
+  "compatibility_date": "2025-09-26",
+  // Remove if you don't need Node APIs
+  "compatibility_flags": ["nodejs_compat_v2"],
+  // Worker entry file for Vite plugin
+  "main": "./src/index.ts",
   "vars": {
     "MY_VAR": "Hello from Cloudflare"
   }
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0babe5d and 182467e.

📒 Files selected for processing (1)
  • docs/start/framework/react/hosting.md (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
docs/**/*.{md,mdx}

📄 CodeRabbit inference engine (AGENTS.md)

Use internal docs links relative to the docs/ folder (e.g., ./guide/data-loading)

Files:

  • docs/start/framework/react/hosting.md
docs/{router,start}/**

📄 CodeRabbit inference engine (AGENTS.md)

Place router docs under docs/router/ and start framework docs under docs/start/

Files:

  • docs/start/framework/react/hosting.md
🔇 Additional comments (1)
docs/start/framework/react/hosting.md (1)

49-49: Cloudflare plugin usage and ordering are correct
cloudflare({ viteEnvironment: { name: 'ssr' }}) aligns with the current API and is correctly placed after react() per Vite’s plugin ordering recommendations.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/start/framework/react/hosting.md (1)

74-87: Remove invalid Wrangler “main” entry

The snippet’s "main": "@tanstack/react-start/server-entry" won’t work—Wrangler expects a file path. Remove the main field and let the Vite plugin generate dist/wrangler.json with main: "index.js", or set main to your built worker file (e.g. "main": "./dist/index.js").

🧹 Nitpick comments (3)
docs/start/framework/react/hosting.md (3)

45-47: Use consistent pnpm syntax (pnpm add -D).

Use pnpm add -D (as you do for wrangler below) for consistency and clarity.

- pnpm install @cloudflare/vite-plugin -D
+ pnpm add @cloudflare/vite-plugin -D

105-109: Consider adding local dev with Wrangler.

Optional but helpful: include wrangler dev for a full Workers-local loop.

-```bash
-pnpm run build && pnpm run deploy
-```
+```bash
+# Local dev (preview)
+pnpm wrangler dev
+
+# Build & deploy
+pnpm run build && pnpm run deploy
+```

111-111: Align wording with the CLI-based deployment.

This section shows wrangler deploy (CLI), not “one‑click” deploy. Adjust phrasing to avoid confusion.

-Deploy your application to Cloudflare Workers using their one-click deployment process, and you're ready to go!
+Deploy your application to Cloudflare Workers with `wrangler deploy`, and you're ready to go!
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6b32efc and cc6c41b.

📒 Files selected for processing (1)
  • docs/start/framework/react/hosting.md (3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
docs/**/*.{md,mdx}

📄 CodeRabbit inference engine (AGENTS.md)

Use internal docs links relative to the docs/ folder (e.g., ./guide/data-loading)

Files:

  • docs/start/framework/react/hosting.md
docs/{router,start}/**

📄 CodeRabbit inference engine (AGENTS.md)

Place router docs under docs/router/ and start framework docs under docs/start/

Files:

  • docs/start/framework/react/hosting.md
🔇 Additional comments (2)
docs/start/framework/react/hosting.md (2)

53-67: @cloudflare/vite-plugin viteEnvironment option is officially supported. The usage in your snippet is correct; no changes required.


80-82: No change required for Node.js compatibility flag. nodejs_compat remains valid with a compatibility_date of 2025-09-02 (behaves the same as nodejs_compat_v2), so your config is correct.

Comment on lines +91 to +103
```json

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

```
Copy link
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).

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

Labels

documentation Everything documentation related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants