Replace Next.js data fetching patterns with React on Rails async props in RSC docs#2791
Replace Next.js data fetching patterns with React on Rails async props in RSC docs#2791
Conversation
…s in RSC migration docs Fixes #2523 - Replace `await getProduct()` / `await getUser()` with Rails props and `getReactOnRailsAsyncProp` throughout all examples - Rewrite waterfall section to show Ruby-side `emit.call` parallelization instead of JS-side `Promise.all` / preload patterns - Replace React Query prefetch+hydrate with `initialData` from Rails props - Replace SWR server fetch with Rails props as `fallbackData` - Remove Server Actions (`'use server'`) as unsupported; add explicit notes throughout all affected docs - Reduce `React.cache()` section; note that `getReactOnRailsAsyncProp` already returns a cached promise - Rewrite progressive streaming section to use async props - Fix migration checklist to reference Rails props and async props - Add ERB view examples alongside component examples Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughReplaces Next.js-style Server Component data fetching and Server Actions in migration docs with React on Rails patterns: Rails supplies synchronous props via Changes
Sequence Diagram(s)sequenceDiagram
participant Rails as Rails (ERB)
participant RSC as React Server Component
participant Child as Child Component
participant Client as Browser Client
Rails->>RSC: stream_react_component(props: { title, product })
Rails->>RSC: stream_react_component_with_async_props(async: { stats, orders })
RSC->>RSC: getReactOnRailsAsyncProp("stats") → statsPromise
RSC->>Child: pass statsPromise / ordersPromise as props
Child->>Child: await statsPromise (server) or use(statsPromise) (client)
Child->>Client: render incrementally as promises resolve
Client->>Rails: POST /api/... with X-CSRF-Token (form/mutation)
Rails->>Client: respond (controller handles mutation)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
Overall this is a solid, well-scoped rewrite. Replacing generic Next.js-style async/await fetch patterns with getReactOnRailsAsyncProp / stream_react_component_with_async_props throughout makes the docs much more accurate for React on Rails users. The consistent addition of ERB view examples alongside JSX is a big usability win, and the removal/replacement of Server Actions content with clear 'not supported' notices prevents a lot of confusion. A few issues to address before merging: Bug: missing export default on Stats component — In rsc-component-patterns.md (Pattern 4), the refactored Stats.jsx snippet drops the export default that was there before. A module-only unexported component silently does nothing — readers who copy this will get a blank Suspense slot with no error. Thread safety: ActiveRecord connections in Ruby threads — The parallel-threads example (Solution 1 in rsc-data-fetching.md) spawns bare Thread.new blocks that call ActiveRecord (User.find, DashboardStats.compute, Post.recent). Rails' connection pool does not automatically check out connections for new threads, so these queries can raise ActiveRecord::ConnectionTimeoutError under load. The example should wrap each block with ActiveRecord::Base.connection_pool.with_connection { ... } or note the requirement. There is also no error handling around threads.each(&:join) — an exception in one thread will be silently swallowed until join re-raises it, by which point other threads may have already emitted partial data. Misleading BEST label on Solution 2 — Solution 2 (Progressive Streaming) is labeled BEST but its timings (~200ms, ~500ms, ~750ms) show sequential/cumulative execution — it is not faster than Solution 1 (threads). It has different trade-offs (progressive browser delivery vs. parallel queries). Calling one unconditionally best without qualification misleads readers. Fetch examples lack error handling — Multiple new form/mutation examples (CommentForm, UserForm, ClientForm) call await fetch(...) without checking response.ok or catching errors. Docs examples get copy-pasted into real applications; a minimal check would prevent silent failures. Product.all.as_json without pagination — Two ERB snippets use Product.all.as_json as a prop. In any real application this loads an unbounded table into memory and serializes it into the page. Either scope/paginate the query in the example, or add a comment clarifying it is simplified for illustration purposes. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/oss/migrating/rsc-component-patterns.md`:
- Around line 167-177: Update the comment in the AddToCartButton example to
remove the “Server Action” wording and instead reference a Rails controller/API
endpoint for performing the mutation; locate the AddToCartButton snippet (and
the nearby mutation example referenced around ProductPage) and replace phrases
like “Server Action or API call for mutation” with “Rails controller or API
endpoint for the mutation” (also apply the same wording change to the other
duplicated snippet mentioned).
In `@docs/oss/migrating/rsc-troubleshooting.md`:
- Around line 80-81: Update the serialization table entry that currently states
functions are allowed "except Server Actions" so it no longer makes an exception
for Server Actions—remove the phrase "except Server Actions" and make the table
entry state functions are allowed (or disallowed) consistent with the guide's
explicit statement that "'use server' / Server Actions are not supported by
React on Rails"; also search the document for other instances of the same
phrasing (the serialization table and the earlier paragraph that mentions
functions) and replace any "except Server Actions" language so the guide
consistently states Server Actions are unsupported and that Rails controller
endpoints must be used for mutations.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 56a3eeb6-3d49-4a22-9bc2-df7c8f28390a
📒 Files selected for processing (5)
docs/oss/migrating/rsc-component-patterns.mddocs/oss/migrating/rsc-context-and-state.mddocs/oss/migrating/rsc-data-fetching.mddocs/oss/migrating/rsc-third-party-libs.mddocs/oss/migrating/rsc-troubleshooting.md
There was a problem hiding this comment.
💡 Codex Review
This troubleshooting table still tells readers that Server Actions are the one kind of function that can cross the boundary, but the rest of the page now says React on Rails does not support Server Actions at all. Leaving the exception here sends people debugging serialization errors toward an unsupported API instead of the actual fix: function props are always disallowed in this stack.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Greptile SummaryThis PR significantly rewrites five RSC migration guide files to replace Next.js-idiomatic data fetching patterns ( Key changes:
Issues found:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Browser
participant Rails as Rails Controller/View
participant RoR as React on Rails (Node)
participant SC as Server Component
Browser->>Rails: GET /page
Rails->>Rails: Fetch sync props (name, price)
Rails->>RoR: stream_react_component_with_async_props(sync_props)
RoR->>SC: Render shell with sync props
SC-->>Browser: Stream: initial HTML shell
par Async props stream in independently
Rails->>Rails: emit.call("reviews", ...)
Rails->>RoR: async prop: reviews
RoR->>SC: reviewsPromise resolves
SC-->>Browser: Stream: reviews content
and
Rails->>Rails: emit.call("related", ...)
Rails->>RoR: async prop: related
RoR->>SC: relatedPromise resolves
SC-->>Browser: Stream: related content
end
Note over Browser,SC: Suspense boundaries show skeletons until each prop arrives
Last reviewed commit: "Replace Next.js data..." |
…erver Action refs - Add missing `export default` on Stats component (separate file needs export) - Wrap Thread.new AR queries in with_connection for connection pool safety - Rename "BEST" to "PROGRESSIVE" and clarify sequential vs parallel trade-off - Replace "Server Action or API call" with "Rails controller endpoint" - Remove "except Server Actions" from serialization table (not supported) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
docs/oss/migrating/rsc-data-fetching.md (1)
82-89:⚠️ Potential issue | 🟠 MajorUpdate documentation to use correct helper names:
stream_react_componentandrsc_payload_react_component.The docs reference
stream_react_component_with_async_propsandrsc_payload_react_component_with_async_props, but these helpers do not exist in the codebase. The actual helper names arestream_react_component(line 126 inreact_on_rails_pro/app/helpers/react_on_rails_pro_helper.rb) andrsc_payload_react_component(line 188). Update all documentation examples to use the correct names.This affects lines 82, 91, 148, 184, 358, 378, 408, 475, 522, 819, 911, 922 in
docs/oss/migrating/rsc-data-fetching.md, plus references indocs/oss/migrating/rsc-third-party-libs.md,docs/oss/migrating/rsc-component-patterns.md, anddocs/oss/migrating/rsc-context-and-state.md.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/oss/migrating/rsc-data-fetching.md` around lines 82 - 89, Documentation examples use non-existent helpers stream_react_component_with_async_props and rsc_payload_react_component_with_async_props; update every example to use the actual helper names stream_react_component and rsc_payload_react_component respectively, ensuring argument/emit usage remains the same (e.g., replace stream_react_component_with_async_props("ProductPage", props: {...}) do ... end with stream_react_component("ProductPage", props: {...}) do ... end and similarly for rsc_payload_react_component), and verify other occurrences in the migrating docs are updated to match these exact helper symbols.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@docs/oss/migrating/rsc-data-fetching.md`:
- Around line 82-89: Documentation examples use non-existent helpers
stream_react_component_with_async_props and
rsc_payload_react_component_with_async_props; update every example to use the
actual helper names stream_react_component and rsc_payload_react_component
respectively, ensuring argument/emit usage remains the same (e.g., replace
stream_react_component_with_async_props("ProductPage", props: {...}) do ... end
with stream_react_component("ProductPage", props: {...}) do ... end and
similarly for rsc_payload_react_component), and verify other occurrences in the
migrating docs are updated to match these exact helper symbols.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 402c2fb9-3a90-4494-8c81-5d463e61f86e
📒 Files selected for processing (3)
docs/oss/migrating/rsc-component-patterns.mddocs/oss/migrating/rsc-data-fetching.mddocs/oss/migrating/rsc-troubleshooting.md
🚧 Files skipped from review as they are similar to previous changes (1)
- docs/oss/migrating/rsc-troubleshooting.md
There was a problem hiding this comment.
💡 Codex Review
react_on_rails/docs/oss/migrating/rsc-data-fetching.md
Lines 82 to 83 in 8902722
I ran rg -n "stream_react_component_with_async_props|getReactOnRailsAsyncProp|WithAsyncProps" across the repo, and the only matches are the new migration docs. The shipped Ruby helper is still stream_react_component (react_on_rails_pro/app/helpers/react_on_rails_pro_helper.rb#stream_react_component), and packages/react-on-rails-pro/package.json exports no matching JS/TS API. Readers following this section will hit undefined method stream_react_component_with_async_props or missing-export/type errors before they can apply the documented migration pattern.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
ReviewThis is a solid, well-scoped documentation rewrite. Replacing generic RSC patterns (direct A few issues worth fixing before merge: Bugs / Correctness
Missing Context
Minor
|
- Fix "waits for stats too" comment to clarify the wait is due to sequential execution, not a data dependency on stats - Add ERB snippet showing how to pass csrf_token via form_authenticity_token to the CommentForm component Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
PR ReviewThis is a valuable, well-scoped documentation rewrite. The direction is right and the ERB examples alongside JSX are a real improvement. One blocking issue and a few consistency fixes needed before merge. MUST FIX1. A repo-wide search confirms these symbols appear only in the new docs - not in Every reader who follows the new Async Props pattern will hit:
This affects ~15 call sites across all five changed files. If these are planned APIs (docs written ahead of implementation), the examples should either use the currently-shipped API or be clearly labelled as upcoming. 2. Checklist inconsistency ( The migration checklist still says "add server prefetch" for React Query/SWR cases, but the body of the guide now recommends passing Rails props as 3. TanStack Query table ( The Data Fetching Libraries table still describes the old pattern: "Prefetch on server with DISCUSS4. The auth provider example uses 5. Thread error handling ( The parallel threads example has no exception handling. If a thread raises (e.g. |
| 5. Add direct data fetching with `await` | ||
| 6. Remove the API route if it was only used by this component | ||
| 4. Receive data as props from Rails (controller and/or ERB view helper props) | ||
| 5. For streaming data, use `getReactOnRailsAsyncProp` with `stream_react_component_with_async_props` in the ERB view |
There was a problem hiding this comment.
stream_react_component_with_async_props and getReactOnRailsAsyncProp do not exist in the codebase. A repo-wide search finds these symbols only in the new docs — the shipped Ruby helper is stream_react_component (react_on_rails_pro/app/helpers/react_on_rails_pro_helper.rb:126).
Readers following step 5 will hit undefined method 'stream_react_component_with_async_props' in ERB.
Also, the checklist item just above this block (line 924: "add server prefetch") is inconsistent with the rest of the guide, which now recommends initialData/fallbackData from Rails props. It should be updated to match.
- Fix snake_case props to camelCase in CommentForm (postId, csrfToken) and ChatPage (channelId, initialMessages) for consistency across docs - Add missing ERB snippet showing how Rails supplies csrfToken to ClientForm in troubleshooting guide - Fix race condition in test example by adding waitFor around async assertion - Change Product.all to Product.limit(50) in ERB examples to avoid unbounded query footgun - Add prose note about thread error handling in parallel fetch example - Rename ../actions import to ../api to avoid Server Actions confusion Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Overall this is a solid, well-structured documentation update. The inline comments I posted flag the specific items below. Bugs (should fix before merge):
Clarity (nice-to-have):
|
There was a problem hiding this comment.
💡 Codex Review
react_on_rails/docs/oss/migrating/rsc-data-fetching.md
Lines 82 to 83 in d157b42
product/post locals in the new ERB snippets
These new examples switched to bare product/post locals, but the snippets never assign those locals first. In a normal Rails view, copying this literally raises undefined local variable or method 'product' before any async props can stream. The same problem recurs in the later mixed-strategy and use() examples in this commit, so the docs should either define the local explicitly or use instance vars (@product, @post) consistently.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| **Pattern 2: Standard Rails form (no JavaScript required)** | ||
|
|
||
| ```erb | ||
| <%= form_with(model: @user, url: users_path) do |f| %> |
There was a problem hiding this comment.
Mark the “no JavaScript required”
form_with example as local
react_on_rails still supports Rails >= 5.2 (react_on_rails/react_on_rails.gemspec:33), and the Rails guides note that form_with generated remote/Ajax forms by default until the 6.1 defaults flipped that setting (guides.rubyonrails.org/v6.1.0/form_helpers.html, guides.rubyonrails.org/configuring.html#config-action-view-form-with-generates-remote-forms). As written, this “no JavaScript required” snippet still depends on JS on supported 5.2/6.0 apps unless you add local: true or explicitly scope the advice to Rails 6.1+.
Useful? React with 👍 / 👎.
- Use params[:user_id] instead of bare user_id in waterfall examples - Fix comment: posts waits because calls are sequential, not because it depends on stats Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
| <%# ERB view — pass the CSRF token so the client component can make authenticated requests %> | ||
| <%= stream_react_component("CommentForm", | ||
| props: { postId: @post.id, | ||
| csrfToken: form_authenticity_token }) %> |
There was a problem hiding this comment.
Security consideration: Passing form_authenticity_token as a component prop embeds it in the RSC payload (visible in <script> tags in the page source) and in any logging/tracing of component props. The token is session-bound, so exposure isn't catastrophic, but it's better practice to read it from a <meta> tag or a cookie on the client side, which is how Rails' own UJS/Turbo handle it.
An alternative pattern worth mentioning:
<%# In the layout — already present in most Rails apps via csrf_meta_tags %>
<%= csrf_meta_tags %>
<%# Then in the component view, no need to pass the token as a prop %>
<%= stream_react_component("CommentForm",
props: { postId: @post.id }) %>// Client Component reads the token directly from the DOM
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.content;This avoids embedding the token in the serialized props payload and keeps it out of component prop logs.
Review: RSC Docs — Replace Next.js patterns with React on Rails async propsOverall this is a high-quality, well-structured rewrite. The core direction — replacing 🔴 Thread safety in parallel emit pattern (important)The Ruby threading examples in both Fix: use a 🔴 Incomplete thread failure semanticsThe note "An unhandled exception in any thread will be re-raised by 🟡 CSRF token in component props (security consideration)All the form examples pass A lower-exposure alternative — which is already how Rails' own UJS/Turbo work — is to read it from the const csrfToken = document.querySelector('meta[name="csrf-token"]')?.content;Worth at minimum adding a note that both approaches exist and flagging the props approach exposes the token in the serialized payload. 🟡
|
## Summary - Stamp `### [16.5.0.rc.0]` version header with today's date - Add 10 new changelog entries for PRs merged since v16.4.0 - Fix incomplete PR 2818 entry (missing author link) ### New entries added **Added:** - `create-react-on-rails-app --pro` support (PR 2818) - Global prerender env override `REACT_ON_RAILS_PRERENDER_OVERRIDE` (PR 2816) - `react_on_rails:sync_versions` rake task (PR 2797) - Pro/RSC setup checks in `react_on_rails:doctor` (PR 2674) **Changed:** - [Pro] Canonical env var for worker count is now `RENDERER_WORKERS_COUNT` (PR 2611) **Improved:** - Smoother `create-react-on-rails-app` and install generator flows (PR 2650) - Pro upgrade hint after install (PR 2642) **Fixed:** - Preserve runtime env vars across `Bundler.with_unbundled_env` (PR 2836) - Fix doctor prerender check and ExecJS display for Pro/RSC apps (PR 2773) - Fix doctor false positives for custom layouts (PR 2612) ### Skipped PRs (not user-visible) Docs-only: #2845, #2842, #2826, #2830, #2820, #2809, #2803, #2785, #2801, #2791, #2789, #2788, #2772, #2778, #2780, #2784, #2671, #2676, #2662, #2657, #2669 CI/internal tooling: #2825, #2817, #2819, #2812, #2815, #2810, #2808, #2807, #2634, #2798, #2761, #2760, #2658, #2639, #2667, #2656 ## Test plan - [x] Verified version header and diff links are correct - [x] Verified all entries follow changelog formatting conventions - [x] Verified file ends with newline - [ ] After merge, run `rake release` to publish 16.5.0.rc.0 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Documentation-only change updating `CHANGELOG.md` with a new `16.5.0.rc.0` section and compare links; no runtime code is modified. > > **Overview** > Adds a new `16.5.0.rc.0` (2026-03-25) section to `CHANGELOG.md`, consolidating recent PR entries under **Added/Changed/Improved/Fixed** and correcting the previously incomplete `--pro` CLI entry author attribution. > > Updates the bottom compare links so `[unreleased]` now compares from `v16.5.0.rc.0` and adds a link definition for `[16.5.0.rc.0]`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 481a71c. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes - v16.5.0.rc.0 * **New Features** * Added sync_versions task for streamlined version management * Expanded doctor checks for Pro and RSC support * **Improvements** * Enhanced generator workflow and Pro upgrade guidance * Improved environment variable handling and preservation * **Bug Fixes** * Fixed detection issues with doctor tools and ExecJS/prerender functionality <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…s in RSC docs (#2791) ## Summary Fixes #2523 - Replace `await getProduct()` / `await getUser()` / `await getStats()` etc. with Rails controller props and `getReactOnRailsAsyncProp` across all RSC migration docs - Rewrite waterfall avoidance section to show Ruby-side `emit.call` parallelization (threads) instead of JS-side `Promise.all` / preload patterns - Replace React Query prefetch+hydrate pattern with `initialData` from Rails props - Replace SWR server fetch with Rails props as `fallbackData` - Remove all Server Actions (`'use server'`) examples and add explicit unsupported notes throughout - Reduce `React.cache()` section — note that `getReactOnRailsAsyncProp` already returns a cached promise - Rewrite progressive streaming section to use async props with ERB examples - Fix migration checklist to reference Rails props and `getReactOnRailsAsyncProp` - Add corresponding ERB view examples alongside component code examples **Affected files:** - `rsc-data-fetching.md` — major rewrite (waterfall, React Query, SWR, use() hook, React.cache(), Server Actions, hybrid pattern, streaming, checklist) - `rsc-component-patterns.md` — Patterns 1, 4, 5 + Mistake 4 note - `rsc-context-and-state.md` — Providers and Redux examples - `rsc-third-party-libs.md` — Form libraries table + Server Action form pattern - `rsc-troubleshooting.md` — serialization table, Server Action fix, testing, validation, error catalog ## Test plan - [ ] Review each code example for correctness — ERB syntax, async props API, TypeScript types - [ ] Verify all internal links still resolve (anchors may have changed) - [ ] Confirm no remaining `await getProduct()` / `await getUser()` patterns outside of the React.cache() and troubleshooting diagnostic sections - [ ] Confirm all `'use server'` references are now in warning/unsupported contexts only 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk documentation-only update, but it changes recommended migration patterns (async props, mutations, and caching) so inaccuracies could mislead adopters. > > **Overview** > Updates the RSC migration docs to **replace Next.js-style server fetching** (`async` components calling `getX()`/`Promise.all`) with **React on Rails patterns**: Rails-provided sync props plus streamed async props via `stream_react_component_with_async_props` and `getReactOnRailsAsyncProp` (with new ERB examples throughout). > > Reworks guidance for common integrations: React Query now seeds the client cache via Rails props (`initialData`), SWR uses Rails props (`fallbackData`), and the waterfall section is rewritten around Ruby-side `emit.call` sequencing/parallelization. Removes Server Actions examples and adds explicit notes that `'use server'` is unsupported in React on Rails, with updated mutation, CSRF, testing, and validation examples centered on Rails controller endpoints. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 9279c97. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Migration guides now favor props-first: Rails supplies synchronous props and can stream async props into React. * New/renamed patterns: Async Props with Suspense, async-prop streaming, and Async Props → client via use(). * Updated data-fetching, React Query/SWR guidance, and progressive streaming strategies/examples. * Replaced Server Actions guidance with Rails-controller form/mutation patterns; added CSRF, testing, and validation notes. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…s in RSC docs (#2791) ## Summary Fixes #2523 - Replace `await getProduct()` / `await getUser()` / `await getStats()` etc. with Rails controller props and `getReactOnRailsAsyncProp` across all RSC migration docs - Rewrite waterfall avoidance section to show Ruby-side `emit.call` parallelization (threads) instead of JS-side `Promise.all` / preload patterns - Replace React Query prefetch+hydrate pattern with `initialData` from Rails props - Replace SWR server fetch with Rails props as `fallbackData` - Remove all Server Actions (`'use server'`) examples and add explicit unsupported notes throughout - Reduce `React.cache()` section — note that `getReactOnRailsAsyncProp` already returns a cached promise - Rewrite progressive streaming section to use async props with ERB examples - Fix migration checklist to reference Rails props and `getReactOnRailsAsyncProp` - Add corresponding ERB view examples alongside component code examples **Affected files:** - `rsc-data-fetching.md` — major rewrite (waterfall, React Query, SWR, use() hook, React.cache(), Server Actions, hybrid pattern, streaming, checklist) - `rsc-component-patterns.md` — Patterns 1, 4, 5 + Mistake 4 note - `rsc-context-and-state.md` — Providers and Redux examples - `rsc-third-party-libs.md` — Form libraries table + Server Action form pattern - `rsc-troubleshooting.md` — serialization table, Server Action fix, testing, validation, error catalog ## Test plan - [ ] Review each code example for correctness — ERB syntax, async props API, TypeScript types - [ ] Verify all internal links still resolve (anchors may have changed) - [ ] Confirm no remaining `await getProduct()` / `await getUser()` patterns outside of the React.cache() and troubleshooting diagnostic sections - [ ] Confirm all `'use server'` references are now in warning/unsupported contexts only 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk documentation-only update, but it changes recommended migration patterns (async props, mutations, and caching) so inaccuracies could mislead adopters. > > **Overview** > Updates the RSC migration docs to **replace Next.js-style server fetching** (`async` components calling `getX()`/`Promise.all`) with **React on Rails patterns**: Rails-provided sync props plus streamed async props via `stream_react_component_with_async_props` and `getReactOnRailsAsyncProp` (with new ERB examples throughout). > > Reworks guidance for common integrations: React Query now seeds the client cache via Rails props (`initialData`), SWR uses Rails props (`fallbackData`), and the waterfall section is rewritten around Ruby-side `emit.call` sequencing/parallelization. Removes Server Actions examples and adds explicit notes that `'use server'` is unsupported in React on Rails, with updated mutation, CSRF, testing, and validation examples centered on Rails controller endpoints. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 9279c97. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Migration guides now favor props-first: Rails supplies synchronous props and can stream async props into React. * New/renamed patterns: Async Props with Suspense, async-prop streaming, and Async Props → client via use(). * Updated data-fetching, React Query/SWR guidance, and progressive streaming strategies/examples. * Replaced Server Actions guidance with Rails-controller form/mutation patterns; added CSRF, testing, and validation notes. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
Fixes #2523
await getProduct()/await getUser()/await getStats()etc. with Rails controller props andgetReactOnRailsAsyncPropacross all RSC migration docsemit.callparallelization (threads) instead of JS-sidePromise.all/ preload patternsinitialDatafrom Rails propsfallbackData'use server') examples and add explicit unsupported notes throughoutReact.cache()section — note thatgetReactOnRailsAsyncPropalready returns a cached promisegetReactOnRailsAsyncPropAffected files:
rsc-data-fetching.md— major rewrite (waterfall, React Query, SWR, use() hook, React.cache(), Server Actions, hybrid pattern, streaming, checklist)rsc-component-patterns.md— Patterns 1, 4, 5 + Mistake 4 notersc-context-and-state.md— Providers and Redux examplesrsc-third-party-libs.md— Form libraries table + Server Action form patternrsc-troubleshooting.md— serialization table, Server Action fix, testing, validation, error catalogTest plan
await getProduct()/await getUser()patterns outside of the React.cache() and troubleshooting diagnostic sections'use server'references are now in warning/unsupported contexts only🤖 Generated with Claude Code
Note
Low Risk
Low risk documentation-only update, but it changes recommended migration patterns (async props, mutations, and caching) so inaccuracies could mislead adopters.
Overview
Updates the RSC migration docs to replace Next.js-style server fetching (
asynccomponents callinggetX()/Promise.all) with React on Rails patterns: Rails-provided sync props plus streamed async props viastream_react_component_with_async_propsandgetReactOnRailsAsyncProp(with new ERB examples throughout).Reworks guidance for common integrations: React Query now seeds the client cache via Rails props (
initialData), SWR uses Rails props (fallbackData), and the waterfall section is rewritten around Ruby-sideemit.callsequencing/parallelization. Removes Server Actions examples and adds explicit notes that'use server'is unsupported in React on Rails, with updated mutation, CSRF, testing, and validation examples centered on Rails controller endpoints.Written by Cursor Bugbot for commit 9279c97. This will update automatically on new commits. Configure here.
Summary by CodeRabbit