Skip to content

Add React on Rails-specific content to RSC migration docs #2503

@AbanoubGhadban

Description

@AbanoubGhadban

Summary

The RSC migration guide series (#2460) is well-written but ~60-70% of the framework-specific content targets Next.js rather than React on Rails. Each document needs React on Rails-specific sections or callouts.

Missing React on Rails Concepts

The following core concepts are barely or never mentioned across all 6 docs:

  • Component registration: ReactOnRails.register() vs registerServerComponent() — what changes during migration?
  • View helpers: stream_react_component, stream_react_component_with_async_props, rsc_payload_react_component_with_async_props
  • ERB integration: "After" migration examples should show both the ERB view and the React component
  • Rails controller patterns: How data flows from controllers to RSC components via props
  • Shakapacker/Webpack: RSC configuration, bundle analysis with webpack-bundle-analyzer
  • Node renderer architecture: React on Rails Pro specifics
  • @loadable/component: Migration path from @loadable/component (common in React on Rails) to RSC code splitting

Next.js-Specific Content That Needs React on Rails Equivalents

Next.js Pattern React on Rails Equivalent Needed
cookies() from next/headers (Auth, Theme, i18n providers) Controller props from current_user, Rails cookies, i18n-js
app/products/page.jsx file naming Standalone component files registered with React on Rails
revalidatePath() Rails controller redirect / Turbo
router.refresh() from next/navigation React on Rails equivalent
optimizePackageImports in next.config.js sideEffects: false / Webpack aliases in Shakapacker
NEXT_PUBLIC_ / VITE_ env var prefixes Shakapacker env var handling
@next/bundle-analyzer webpack-bundle-analyzer with Shakapacker
next-intl for i18n i18n-js or Rails I18n passed as props
Single App.jsx root assumption Multiple registered component roots per page

Per-Document Gaps

  1. migrating-to-rsc.md — Doesn't clarify if RSC is Pro-only; no mention of view helpers
  2. rsc-component-patterns.md — Zero React on Rails content; "top-down migration" should start from Rails views, not App.jsx
  3. rsc-context-and-state.md — Auth/Theme/i18n providers are entirely Next.js-specific
  4. rsc-data-fetching.md — Best of the bunch (has async props section), but missing stream_react_component (sync) migration and ERB-side examples
  5. rsc-third-party-libs.md — Missing @loadable/component guidance; optimizePackageImports is Next.js-only
  6. rsc-troubleshooting.md — Missing React on Rails-specific issues entirely

Recommendation

Each section using Next.js-specific APIs should either:

  • Have a parallel "In React on Rails" section showing the equivalent pattern
  • Be clearly labeled as "Next.js-specific" with a note about the React on Rails approach
  • Or be replaced entirely with React on Rails patterns

Related: #2460

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions