react_on_rails_pro 16.2.0.beta.20 → 16.2.0.rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +3 -1
  3. data/CONTRIBUTING.md +64 -43
  4. data/Gemfile.lock +4 -4
  5. data/README.md +1 -1
  6. data/docs/bundle-caching.md +22 -8
  7. data/docs/caching.md +39 -27
  8. data/docs/code-splitting-loadable-components.md +2 -2
  9. data/docs/code-splitting.md +74 -70
  10. data/docs/configuration.md +6 -6
  11. data/docs/contributors-info/onboarding-customers.md +2 -1
  12. data/docs/contributors-info/releasing.md +1 -0
  13. data/docs/contributors-info/style.md +23 -15
  14. data/docs/home-pro.md +33 -15
  15. data/docs/installation.md +51 -2
  16. data/docs/js-memory-leaks.md +2 -3
  17. data/docs/node-renderer/debugging.md +5 -1
  18. data/docs/node-renderer/error-reporting-and-tracing.md +27 -15
  19. data/docs/node-renderer/heroku.md +4 -5
  20. data/docs/profiling-server-side-rendering-code.md +43 -42
  21. data/docs/react-server-components/add-streaming-and-interactivity.md +1 -1
  22. data/docs/react-server-components/create-without-ssr.md +18 -18
  23. data/docs/react-server-components/glossary.md +22 -3
  24. data/docs/react-server-components/how-react-server-components-work.md +25 -18
  25. data/docs/react-server-components/inside-client-components.md +19 -18
  26. data/docs/react-server-components/purpose-and-benefits.md +24 -14
  27. data/docs/react-server-components/rendering-flow.md +7 -3
  28. data/docs/react-server-components/server-side-rendering.md +23 -22
  29. data/docs/release-notes/4.0.md +103 -94
  30. data/docs/release-notes/v4-react-server-components.md +16 -16
  31. data/docs/streaming-server-rendering.md +2 -4
  32. data/docs/troubleshooting.md +5 -2
  33. data/docs/updating.md +49 -13
  34. data/lib/react_on_rails_pro/request.rb +18 -3
  35. data/lib/react_on_rails_pro/version.rb +1 -1
  36. data/rakelib/dummy_apps.rake +4 -4
  37. data/rakelib/lint.rake +1 -1
  38. data/rakelib/run_rspec.rake +3 -3
  39. metadata +4 -4
@@ -1,6 +1,7 @@
1
1
  # SSR React Server Components
2
2
 
3
3
  Before reading this document, please read:
4
+
4
5
  1. [Create React Server Component without SSR](./create-without-ssr.md)
5
6
  2. [Add Streaming and Interactivity to RSC Page](./add-streaming-and-interactivity.md)
6
7
 
@@ -13,7 +14,7 @@ Let's make React on Rails server-side render the React Server Component Page we
13
14
  Update the `react_server_component_without_ssr.html.erb` view to pass `prerender: true` to the `react_component` helper.
14
15
 
15
16
  ```erb
16
- <%= react_component("ReactServerComponentPage",
17
+ <%= react_component("ReactServerComponentPage",
17
18
  prerender: true,
18
19
  trace: true,
19
20
  id: "ReactServerComponentPage-react-component-0") %>
@@ -37,33 +38,33 @@ To enable streaming SSR for React Server Components, we need to:
37
38
 
38
39
  1. Create a new view called `react_server_component_ssr.html.erb` with the following content:
39
40
 
40
- ```erb
41
- # app/views/pages/react_server_component_ssr.html.erb
42
- <%= stream_react_component("ReactServerComponentPage",
43
- id: "ReactServerComponentPage-react-component-0") %>
44
-
45
- <h1>React Server Component with SSR</h1>
46
- ```
41
+ ```erb
42
+ # app/views/pages/react_server_component_ssr.html.erb
43
+ <%= stream_react_component("ReactServerComponentPage",
44
+ id: "ReactServerComponentPage-react-component-0") %>
45
+
46
+ <h1>React Server Component with SSR</h1>
47
+ ```
47
48
 
48
49
  2. Ensure our controller includes `ReactOnRailsPro::Stream` and use the `stream_view_containing_react_components` helper to render the view:
49
50
 
50
- ```ruby
51
- # app/controllers/pages_controller.rb
52
- class PagesController < ApplicationController
53
- include ReactOnRailsPro::Stream
54
-
55
- def react_server_component_ssr
56
- stream_view_containing_react_components(template: "pages/react_server_component_ssr")
57
- end
58
- end
59
- ```
51
+ ```ruby
52
+ # app/controllers/pages_controller.rb
53
+ class PagesController < ApplicationController
54
+ include ReactOnRailsPro::Stream
55
+
56
+ def react_server_component_ssr
57
+ stream_view_containing_react_components(template: "pages/react_server_component_ssr")
58
+ end
59
+ end
60
+ ```
60
61
 
61
62
  3. Add the route to `config/routes.rb`:
62
63
 
63
- ```ruby
64
- # config/routes.rb
65
- get "/react_server_component_ssr", to: "pages#react_server_component_ssr"
66
- ```
64
+ ```ruby
65
+ # config/routes.rb
66
+ get "/react_server_component_ssr", to: "pages#react_server_component_ssr"
67
+ ```
67
68
 
68
69
  Now, when you visit the page, you should see the entire React Server Component page rendered in the browser. And if you viewed the page source, you should see the HTML being streamed to the browser.
69
70
 
@@ -1,94 +1,103 @@
1
- # 4.0 Release Notes
2
-
3
- ## 🚀 Major New Features
4
-
5
- ### React Server Components (RSC) - Full Production Support
6
- React on Rails Pro now provides comprehensive support for React Server Components, enabling you to build the next generation of React applications:
7
-
8
- - **Full RSC Integration**: Seamlessly use React Server Components in your Rails apps with zero configuration
9
- - **Bundle Optimization**: Automatic client/server code splitting that significantly reduces client-side JavaScript
10
- - **Server-Side Data Fetching**: Direct access to databases, APIs, and server resources from React components
11
- - **Progressive Hydration**: Client components hydrate independently for optimal performance
12
- - **RSC Payload Streaming**: Efficient streaming of component data with embedded payloads
13
- - **Compatible with React Router**: [Use React Router with RSC](../react-server-components/inside-client-components.md)
14
-
15
- See our [complete RSC tutorial](../react-server-components-tutorial.md) to get started.
16
-
17
- ### Advanced Streaming Server Rendering
18
- Building on React 19's streaming capabilities, React on Rails Pro delivers:
19
-
20
- - **Progressive HTML Streaming**: Send page content as it becomes available
21
- - **Suspense Boundary Support**: Handle async components with proper loading states
22
- - **Selective Hydration**: Components become interactive as soon as they're ready
23
- - **Error Boundary Handling**: Graceful error handling during streaming with configurable error raising
24
- - **Async Console Log Replay**: Debug async server-side rendering with client-side console output
25
-
26
- ### Enhanced Error Reporting & Tracing
27
- Completely redesigned error reporting system with:
28
-
29
- - **Custom Integration Support**: Integrate with any error reporting service (Sentry, Honeybadger, or custom)
30
- - **Sentry SDK v8 Support**: Latest Sentry integration with improved performance
31
- - **Flexible Configuration**: Configure error reporting according to your preferences
32
- - **Enhanced Tracing**: Better visibility into rendering performance and issues
33
-
34
- ## Performance Improvements
35
-
36
- ### Node Renderer Architecture
37
- - **Fastify 5 Integration**: Upgraded from Express to Fastify for significantly better performance
38
- - **HTTP/2 Cleartext Communication**: Rails communicates with Node renderer over HTTP/2 instead of HTTP/1.1
39
- - **HTTPX Client**: Replaced Net::HTTP with HTTPX for improved connection handling
40
- - **Pino Logging**: Switched from Winston to Pino for better performance and Fastify compatibility
41
-
42
- These changes provide:
43
- - Better performance when Node renderer is deployed on the same machine as Rails
44
- - Significantly improved performance when deployed in separate workloads
45
- - Enhanced connection reuse and multiplexing capabilities
46
- - Better error handling and process management
47
-
48
-
49
- ### Changes Specific For RSC Rendering Optimization
50
- - **Cross-Bundle Communication**: Components can now interact seamlessly across different bundles using the new `runOnOtherBundle` function, enabling advanced composition and modularization patterns.
51
- - **Single-Pass Server Component Rendering**: Server components are rendered just once within the RSC bundle, then efficiently reused for both SSR and client hydration—eliminating redundant work and improving performance.
52
- - **Reduced HTTP Requests**: RSC payloads are now embedded directly into the initial HTML response. No need to make an additional request to fetch the RSC payload.
53
- - **Protocol v2.0 Unified Bundle Management**: The new protocol allows simultaneous upload of both server and RSC bundles in a single request, supporting multiple bundle uploads and providing robust, flexible bundle management for complex applications.
54
-
55
- ## Breaking Changes
56
-
57
- ### Configuration Updates
58
- - **Sentry/Honeybadger**: Remove old configuration options starting with `sentry` or `honeybadger`
59
- - **Timer Polyfills**: `includeTimerPolyfills` is renamed to `stubTimers`
60
- - **Environment Variables**: `RENDERER_STUB_TIMERS` instead of `INCLUDE_TIMER_POLYFILLS`
61
- - **Error Reporting**: Follow the [Error Reporting and Tracing](../node-renderer/error-reporting-and-tracing.md) documentation for new setup
62
-
63
- ### Dependency Requirements
64
- - **Ruby 3+**: Dropped support for Ruby 2.7 (EOL)
65
- - **React on Rails 15+**: Required for RSC and streaming features
66
- - **Node 20+**: Strongly recommended (older versions require specific package.json resolutions)
67
-
68
- ### Package.json Resolutions (for Node < 20)
69
- If using older Node versions, add to your `package.json`:
70
- ```json
71
- "resolutions": {
72
- "@fastify/formbody": "^7.4.0",
73
- "@fastify/multipart": "^8.3.1",
74
- "fastify": "^4.29.0"
75
- }
76
- ```
77
-
78
- ## Getting Started
79
-
80
- - **RSC Tutorial**: [Complete React Server Components Guide](../react-server-components-tutorial.md)
81
- - **Streaming SSR**: [Streaming Server Rendering Documentation](../streaming-server-rendering.md)
82
- - **Error Reporting**: [Error Reporting and Tracing Setup](../node-renderer/error-reporting-and-tracing.md)
83
- - **Performance**: [Caching and Optimization Guide](../caching.md)
84
-
85
- ## Support & Community
86
-
87
- - **Documentation**: Comprehensive guides and tutorials available
88
- - **Examples**: Working examples in the spec/dummy application
89
- - **GitHub**: Active development and community support
90
- - **Discussions**: Join the [React on Rails community](https://forum.shakacode.com/) for help and updates
91
-
92
- ---
93
-
94
- *React on Rails Pro 4.0 represents a major evolution in server-side React rendering, bringing React Server Components and advanced streaming to the Rails ecosystem with enterprise-grade performance and reliability.*
1
+ # 4.0 Release Notes
2
+
3
+ ## 🚀 Major New Features
4
+
5
+ ### React Server Components (RSC) - Full Production Support
6
+
7
+ React on Rails Pro now provides comprehensive support for React Server Components, enabling you to build the next generation of React applications:
8
+
9
+ - **Full RSC Integration**: Seamlessly use React Server Components in your Rails apps with zero configuration
10
+ - **Bundle Optimization**: Automatic client/server code splitting that significantly reduces client-side JavaScript
11
+ - **Server-Side Data Fetching**: Direct access to databases, APIs, and server resources from React components
12
+ - **Progressive Hydration**: Client components hydrate independently for optimal performance
13
+ - **RSC Payload Streaming**: Efficient streaming of component data with embedded payloads
14
+ - **Compatible with React Router**: [Use React Router with RSC](../react-server-components/inside-client-components.md)
15
+
16
+ See our [complete RSC tutorial](../react-server-components/tutorial.md) to get started.
17
+
18
+ ### Advanced Streaming Server Rendering
19
+
20
+ Building on React 19's streaming capabilities, React on Rails Pro delivers:
21
+
22
+ - **Progressive HTML Streaming**: Send page content as it becomes available
23
+ - **Suspense Boundary Support**: Handle async components with proper loading states
24
+ - **Selective Hydration**: Components become interactive as soon as they're ready
25
+ - **Error Boundary Handling**: Graceful error handling during streaming with configurable error raising
26
+ - **Async Console Log Replay**: Debug async server-side rendering with client-side console output
27
+
28
+ ### Enhanced Error Reporting & Tracing
29
+
30
+ Completely redesigned error reporting system with:
31
+
32
+ - **Custom Integration Support**: Integrate with any error reporting service (Sentry, Honeybadger, or custom)
33
+ - **Sentry SDK v8 Support**: Latest Sentry integration with improved performance
34
+ - **Flexible Configuration**: Configure error reporting according to your preferences
35
+ - **Enhanced Tracing**: Better visibility into rendering performance and issues
36
+
37
+ ## Performance Improvements
38
+
39
+ ### Node Renderer Architecture
40
+
41
+ - **Fastify 5 Integration**: Upgraded from Express to Fastify for significantly better performance
42
+ - **HTTP/2 Cleartext Communication**: Rails communicates with Node renderer over HTTP/2 instead of HTTP/1.1
43
+ - **HTTPX Client**: Replaced Net::HTTP with HTTPX for improved connection handling
44
+ - **Pino Logging**: Switched from Winston to Pino for better performance and Fastify compatibility
45
+
46
+ These changes provide:
47
+
48
+ - Better performance when Node renderer is deployed on the same machine as Rails
49
+ - Significantly improved performance when deployed in separate workloads
50
+ - Enhanced connection reuse and multiplexing capabilities
51
+ - Better error handling and process management
52
+
53
+ ### Changes Specific For RSC Rendering Optimization
54
+
55
+ - **Cross-Bundle Communication**: Components can now interact seamlessly across different bundles using the new `runOnOtherBundle` function, enabling advanced composition and modularization patterns.
56
+ - **Single-Pass Server Component Rendering**: Server components are rendered just once within the RSC bundle, then efficiently reused for both SSR and client hydration—eliminating redundant work and improving performance.
57
+ - **Reduced HTTP Requests**: RSC payloads are now embedded directly into the initial HTML response. No need to make an additional request to fetch the RSC payload.
58
+ - **Protocol v2.0 – Unified Bundle Management**: The new protocol allows simultaneous upload of both server and RSC bundles in a single request, supporting multiple bundle uploads and providing robust, flexible bundle management for complex applications.
59
+
60
+ ## Breaking Changes
61
+
62
+ ### Configuration Updates
63
+
64
+ - **Sentry/Honeybadger**: Remove old configuration options starting with `sentry` or `honeybadger`
65
+ - **Timer Polyfills**: `includeTimerPolyfills` is renamed to `stubTimers`
66
+ - **Environment Variables**: `RENDERER_STUB_TIMERS` instead of `INCLUDE_TIMER_POLYFILLS`
67
+ - **Error Reporting**: Follow the [Error Reporting and Tracing](../node-renderer/error-reporting-and-tracing.md) documentation for new setup
68
+
69
+ ### Dependency Requirements
70
+
71
+ - **Ruby 3+**: Dropped support for Ruby 2.7 (EOL)
72
+ - **React on Rails 15+**: Required for RSC and streaming features
73
+ - **Node 20+**: Strongly recommended (older versions require specific package.json resolutions)
74
+
75
+ ### Package.json Resolutions (for Node < 20)
76
+
77
+ If using older Node versions, add to your `package.json`:
78
+
79
+ ```json
80
+ "resolutions": {
81
+ "@fastify/formbody": "^7.4.0",
82
+ "@fastify/multipart": "^8.3.1",
83
+ "fastify": "^4.29.0"
84
+ }
85
+ ```
86
+
87
+ ## Getting Started
88
+
89
+ - **RSC Tutorial**: [Complete React Server Components Guide](../react-server-components/tutorial.md)
90
+ - **Streaming SSR**: [Streaming Server Rendering Documentation](../streaming-server-rendering.md)
91
+ - **Error Reporting**: [Error Reporting and Tracing Setup](../node-renderer/error-reporting-and-tracing.md)
92
+ - **Performance**: [Caching and Optimization Guide](../caching.md)
93
+
94
+ ## Support & Community
95
+
96
+ - **Documentation**: Comprehensive guides and tutorials available
97
+ - **Examples**: Working examples in the spec/dummy application
98
+ - **GitHub**: Active development and community support
99
+ - **Discussions**: Join the [React on Rails community](https://forum.shakacode.com/) for help and updates
100
+
101
+ ---
102
+
103
+ _React on Rails Pro 4.0 represents a major evolution in server-side React rendering, bringing React Server Components and advanced streaming to the Rails ecosystem with enterprise-grade performance and reliability._
@@ -10,33 +10,33 @@ We're thrilled to announce a major update: React on Rails Pro now supports **Rea
10
10
 
11
11
  ## 🎯 What This Means for Your Applications
12
12
 
13
- * **Faster load times**
14
- * **Smaller JavaScript bundles**
15
- * **Better Core Web Vitals**
16
- * **Improved SEO**
17
- * **Smoother user interactions**
13
+ - **Faster load times**
14
+ - **Smaller JavaScript bundles**
15
+ - **Better Core Web Vitals**
16
+ - **Improved SEO**
17
+ - **Smoother user interactions**
18
18
 
19
19
  ## 🔥 React Server Components
20
20
 
21
21
  Server Components execute on the server and stream HTML to the client—no extra JavaScript in your bundle. Real‑world results include:
22
22
 
23
- * **62% reduction** in client‑side bundle size on productonboarding.com when migrating to RSC [[1]]
24
- * **63% improvement** in Google Speed Index on the RSC version of the same site [[1]]
25
- * **52% smaller** JavaScript codebase and Lighthouse scores rising from \~50 to 90+ on GeekyAnts.com [[2]]
23
+ - **62% reduction** in client‑side bundle size on productonboarding.com when migrating to RSC [[1]]
24
+ - **63% improvement** in Google Speed Index on the RSC version of the same site [[1]]
25
+ - **52% smaller** JavaScript codebase and Lighthouse scores rising from \~50 to 90+ on GeekyAnts.com [[2]]
26
26
 
27
27
  ## 🌊 SSR Streaming
28
28
 
29
29
  SSR Streaming sends HTML to the browser in chunks as it’s generated, enabling progressive rendering:
30
30
 
31
- * **30% faster** full‑page load times at Hulu by combining streaming SSR with Server Components [[3]]
32
- * Popular libraries like styled‑components v3.1.0 have introduced streaming SSR support as the next generation of React app rendering [[4]]
31
+ - **30% faster** full‑page load times at Hulu by combining streaming SSR with Server Components [[3]]
32
+ - Popular libraries like styled‑components v3.1.0 have introduced streaming SSR support as the next generation of React app rendering [[4]]
33
33
 
34
34
  ## 📊 Core Web Vitals & TTI Improvements
35
35
 
36
- * **60% faster** Time to Interactive on Meta’s developer portal after adopting RSC (from 3.5 s to \~1.4 s) [[5]]
37
- * **45% quicker** First Contentful Paint in the same migration [[5]]
38
- * **50% lower** server response time with Server Components [[5]]
39
- * **15% improvement** in Core Web Vitals and **23% reduction** in Time to First Byte at Airbnb after RSC migration [[5]]
36
+ - **60% faster** Time to Interactive on Meta’s developer portal after adopting RSC (from 3.5 s to \~1.4 s) [[5]]
37
+ - **45% quicker** First Contentful Paint in the same migration [[5]]
38
+ - **50% lower** server response time with Server Components [[5]]
39
+ - **15% improvement** in Core Web Vitals and **23% reduction** in Time to First Byte at Airbnb after RSC migration [[5]]
40
40
 
41
41
  ---
42
42
 
@@ -45,7 +45,7 @@ Adopting these features in React on Rails Pro will help you deliver faster, lean
45
45
  **Ready to get started?**
46
46
 
47
47
  1. Update to the latest React on Rails Pro version
48
- 2. Follow our [RSC & SSR Streaming migration guide](https://github.com/shakacode/react_on_rails_pro/blob/abanoubghadban/pro465/use-rsc-payload-to-render-server-components-on-server/docs/react-server-components-tutorial.md)
48
+ 2. Follow our [RSC & SSR Streaming migration guide](../react-server-components/tutorial.md)
49
49
 
50
50
  Let’s make your apps faster—together.
51
51
 
@@ -63,4 +63,4 @@ Let’s make your apps faster—together.
63
63
  [2]: https://geekyants.com/en-gb/blog/boosting-performance-with-nextjs-and-react-server-components-a-geekyantscom-case-study
64
64
  [3]: https://www.compilenrun.com/docs/framework/nextjs/nextjs-ecosystem/nextjs-case-studies/#case-study-3-hulus-streaming-platform
65
65
  [4]: https://medium.com/styled-components/v3-1-0-such-perf-wow-many-streams-c45c434dbd03
66
- [5]: https://questlab.pro/blog-posts/web-development/wd-pl-2024-articleId912i1h212818
66
+ [5]: https://web.archive.org/web/20250908030148/https://questlab.pro/blog-posts/web-development/wd-pl-2024-articleId912i1h212818
@@ -112,7 +112,6 @@ end
112
112
 
113
113
  You can test your application by running `rails server` and navigating to the appropriate route.
114
114
 
115
-
116
115
  6. **What Happens During Streaming**
117
116
 
118
117
  When a user visits the page, they'll experience the following sequence:
@@ -152,9 +151,7 @@ For example, with our `MyStreamingComponent`, the sequence might be:
152
151
 
153
152
  <script>
154
153
  // This implementation is slightly simplified
155
- document.getElementById('s0').replaceChildren(
156
- document.getElementById('b0')
157
- );
154
+ document.getElementById('s0').replaceChildren(document.getElementById('b0'));
158
155
  </script>
159
156
  ```
160
157
 
@@ -182,6 +179,7 @@ Streaming SSR is particularly valuable in specific scenarios. Here's when to con
182
179
  ### Best Practices for Streaming
183
180
 
184
181
  1. **Component Structure**
182
+
185
183
  ```jsx
186
184
  // Good: Independent sections that can stream separately
187
185
  <Layout>
@@ -1,6 +1,7 @@
1
1
  # Troubleshooting
2
2
 
3
3
  ## Invalid Token Workaround
4
+
4
5
  On June 27, 2024, tokens mysteriously did not work for a few hours. The problem resolved itself within a few hours.
5
6
 
6
7
  If you do see this problem, get in touch with the package maintainers via Slack. You can also message
@@ -10,6 +11,7 @@ As an alternative to the token issue, if you have an account with access to the
10
11
  create a new token and follow these steps.
11
12
 
12
13
  To create a new token, visit https://github.com/settings/apps:
14
+
13
15
  1. Developer Settings
14
16
  2. Personal access tokens
15
17
  3. Tokens (classic)
@@ -18,7 +20,8 @@ To create a new token, visit https://github.com/settings/apps:
18
20
  6. Repo privileges (not ideal) but shouldn't last long
19
21
 
20
22
  Then follow these steps to use your token:
21
- * [Ruby Gem](https://github.com/shakacode/react_on_rails_pro/blob/master/docs/installation.md#using-a-branch-in-your-gemfile)
22
- * [Node Package](https://github.com/shakacode/react_on_rails_pro/blob/master/docs/installation.md#instructions-for-using-a-branch)
23
+
24
+ - [Ruby Gem](https://github.com/shakacode/react_on_rails_pro/blob/master/docs/installation.md#using-a-branch-in-your-gemfile)
25
+ - [Node Package](https://github.com/shakacode/react_on_rails_pro/blob/master/docs/installation.md#instructions-for-using-a-branch)
23
26
 
24
27
  Note that this token gives `repo` access, so you want to revoke this token ASAP.
data/docs/updating.md CHANGED
@@ -23,8 +23,12 @@ React on Rails Pro packages are now **publicly distributed** via npmjs.org and R
23
23
 
24
24
  Package names have changed:
25
25
 
26
- - **Scoped** (old): `@shakacode-tools/react-on-rails-pro-node-renderer`
27
- - **Unscoped** (new): `react-on-rails-pro-node-renderer`
26
+ | Package | Old (Scoped) | New (Unscoped) |
27
+ | ------------- | --------------------------------------------------- | ---------------------------------- |
28
+ | Client | `react-on-rails` | `react-on-rails-pro` |
29
+ | Node Renderer | `@shakacode-tools/react-on-rails-pro-node-renderer` | `react-on-rails-pro-node-renderer` |
30
+
31
+ **Important:** Pro users should now import from `react-on-rails-pro` instead of `react-on-rails`. The Pro package includes all core features plus Pro-exclusive functionality.
28
32
 
29
33
  ### Your Current Setup (GitHub Packages)
30
34
 
@@ -98,11 +102,12 @@ rm .npmrc
98
102
 
99
103
  #### Step 3: Update package.json
100
104
 
101
- Change the package name from **scoped** to **unscoped**:
105
+ **Add the client package** and update the node renderer package name:
102
106
 
103
107
  ```diff
104
108
  {
105
109
  "dependencies": {
110
+ + "react-on-rails-pro": "^16.2.0",
106
111
  - "@shakacode-tools/react-on-rails-pro-node-renderer": "16.1.1"
107
112
  + "react-on-rails-pro-node-renderer": "^16.2.0"
108
113
  }
@@ -117,18 +122,36 @@ npm install
117
122
  yarn install
118
123
  ```
119
124
 
120
- #### Step 4: Update Require Statements
125
+ #### Step 4: Update Import Statements
126
+
127
+ **Client code:** Change all imports from `react-on-rails` to `react-on-rails-pro`:
128
+
129
+ ```diff
130
+ - import ReactOnRails from 'react-on-rails';
131
+ + import ReactOnRails from 'react-on-rails-pro';
132
+ ```
133
+
134
+ **Pro-exclusive features** (React Server Components, async loading):
135
+
136
+ ```diff
137
+ - import { RSCRoute } from 'react-on-rails/RSCRoute';
138
+ + import { RSCRoute } from 'react-on-rails-pro/RSCRoute';
121
139
 
122
- Update all require/import statements to use the **unscoped** package name:
140
+ - import registerServerComponent from 'react-on-rails/registerServerComponent/client';
141
+ + import registerServerComponent from 'react-on-rails-pro/registerServerComponent/client';
142
+
143
+ - import { wrapServerComponentRenderer } from 'react-on-rails/wrapServerComponentRenderer/client';
144
+ + import { wrapServerComponentRenderer } from 'react-on-rails-pro/wrapServerComponentRenderer/client';
145
+ ```
123
146
 
124
- **In your node renderer configuration file:**
147
+ **Node renderer configuration file:**
125
148
 
126
149
  ```diff
127
150
  - const { reactOnRailsProNodeRenderer } = require('@shakacode-tools/react-on-rails-pro-node-renderer');
128
151
  + const { reactOnRailsProNodeRenderer } = require('react-on-rails-pro-node-renderer');
129
152
  ```
130
153
 
131
- **If using integrations (Sentry, Honeybadger):**
154
+ **Node renderer integrations (Sentry, Honeybadger):**
132
155
 
133
156
  ```diff
134
157
  - require('@shakacode-tools/react-on-rails-pro-node-renderer/integrations/sentry').init();
@@ -171,10 +194,12 @@ bundle list | grep react_on_rails_pro
171
194
  #### 2. Verify NPM Package Installation
172
195
 
173
196
  ```bash
174
- npm list react-on-rails-pro-node-renderer
175
- # or
176
- yarn list --pattern react-on-rails-pro-node-renderer
197
+ # Verify client package
198
+ npm list react-on-rails-pro
199
+ # Should show: react-on-rails-pro@16.2.0 or higher
177
200
 
201
+ # Verify node renderer (if using)
202
+ npm list react-on-rails-pro-node-renderer
178
203
  # Should show: react-on-rails-pro-node-renderer@16.2.0 or higher
179
204
  ```
180
205
 
@@ -202,11 +227,22 @@ If the license is invalid or missing, you'll see an error with instructions.
202
227
  - Run `bundle install` again
203
228
  - Check that you have the correct version specified
204
229
 
205
- #### "Cannot find module 'react-on-rails-pro-node-renderer'"
230
+ #### "Cannot find module 'react-on-rails-pro'" or "Cannot find module 'react-on-rails-pro-node-renderer'"
206
231
 
207
- - Verify you updated all require statements to the unscoped name
232
+ - Verify you added `react-on-rails-pro` to your package.json dependencies
233
+ - Verify you updated all import/require statements to use the correct package names
208
234
  - Delete `node_modules` and reinstall: `rm -rf node_modules && npm install`
209
- - Check that package.json has the correct unscoped package name
235
+
236
+ #### "Cannot mix react-on-rails (core) with react-on-rails-pro"
237
+
238
+ This error occurs when you import from both `react-on-rails` and `react-on-rails-pro`. Pro users should **only** import from `react-on-rails-pro`:
239
+
240
+ ```diff
241
+ - import ReactOnRails from 'react-on-rails';
242
+ + import ReactOnRails from 'react-on-rails-pro';
243
+ ```
244
+
245
+ The Pro package re-exports everything from core, so you don't need both.
210
246
 
211
247
  #### "License validation failed"
212
248
 
@@ -7,9 +7,17 @@ require_relative "stream_request"
7
7
  module ReactOnRailsPro
8
8
  class Request # rubocop:disable Metrics/ClassLength
9
9
  class << self
10
+ # Mutex for thread-safe connection management.
11
+ # Using a constant eliminates the race condition that would exist with @mutex ||= Mutex.new
12
+ CONNECTION_MUTEX = Mutex.new
13
+
10
14
  def reset_connection
11
- @connection&.close
12
- @connection = create_connection
15
+ CONNECTION_MUTEX.synchronize do
16
+ new_conn = create_connection
17
+ old_conn = @connection
18
+ @connection = new_conn
19
+ old_conn&.close
20
+ end
13
21
  end
14
22
 
15
23
  def render_code(path, js_code, send_bundle)
@@ -83,7 +91,14 @@ module ReactOnRailsPro
83
91
  private
84
92
 
85
93
  def connection
86
- @connection ||= create_connection
94
+ # Fast path: return existing connection without locking (lock-free for 99.99% of calls)
95
+ conn = @connection
96
+ return conn if conn
97
+
98
+ # Slow path: initialize with lock (only happens once per process)
99
+ CONNECTION_MUTEX.synchronize do
100
+ @connection ||= create_connection
101
+ end
87
102
  end
88
103
 
89
104
  def perform_request(path, **post_options) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ReactOnRailsPro
4
- VERSION = "16.2.0.beta.20"
4
+ VERSION = "16.2.0.rc.0"
5
5
  PROTOCOL_VERSION = "2.0.0"
6
6
  end
@@ -7,12 +7,12 @@ include ReactOnRailsPro::TaskHelpers
7
7
  # rubocop:enable Style/MixinUsage
8
8
 
9
9
  namespace :dummy_app do
10
- task :yarn_install do
11
- yarn_install_cmd = "yarn install --frozen-lockfile --mutex network"
12
- sh_in_dir(dummy_app_dir, yarn_install_cmd)
10
+ task :pnpm_install do
11
+ pnpm_install_cmd = "pnpm install --frozen-lockfile"
12
+ sh_in_dir(dummy_app_dir, pnpm_install_cmd)
13
13
  end
14
14
 
15
- task dummy_app: [:yarn_install] do
15
+ task dummy_app: [:pnpm_install] do
16
16
  dummy_app_dir = File.join(gem_root, "spec/dummy")
17
17
  bundle_install_in(dummy_app_dir)
18
18
  end
data/rakelib/lint.rake CHANGED
@@ -19,7 +19,7 @@ namespace :lint do
19
19
 
20
20
  desc "Run eslint as shell"
21
21
  task :eslint do
22
- sh_in_dir(gem_root, "yarn run eslint")
22
+ sh_in_dir(gem_root, "pnpm run eslint")
23
23
  end
24
24
 
25
25
  desc "Run all eslint, rubocop linters. Skip ruby-lint and scss"
@@ -36,9 +36,9 @@ namespace :run_rspec do
36
36
  end
37
37
  end
38
38
 
39
- desc "js tests (same as 'yarn run test')"
39
+ desc "js tests (same as 'pnpm run test')"
40
40
  task :js_tests do
41
- sh "yarn run test"
41
+ sh "pnpm run test"
42
42
  end
43
43
 
44
44
  msg = <<~DESC
@@ -77,5 +77,5 @@ end
77
77
 
78
78
  def clean_gen_assets(dir)
79
79
  path = calc_path(dir)
80
- sh_in_dir(path.realpath, "yarn run build:clean")
80
+ sh_in_dir(path.realpath, "pnpm run build:clean")
81
81
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: react_on_rails_pro
3
3
  version: !ruby/object:Gem::Version
4
- version: 16.2.0.beta.20
4
+ version: 16.2.0.rc.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Gordon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-12-13 00:00:00.000000000 Z
11
+ date: 2025-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - '='
130
130
  - !ruby/object:Gem::Version
131
- version: 16.2.0.beta.20
131
+ version: 16.2.0.rc.0
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - '='
137
137
  - !ruby/object:Gem::Version
138
- version: 16.2.0.beta.20
138
+ version: 16.2.0.rc.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: bundler
141
141
  requirement: !ruby/object:Gem::Requirement