Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions AGENTS_USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
gem search react_on_rails --remote

# Verify prerequisites
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.

The AI agent guide now recommends the bare minimum versions (3.0+/18+) rather than the CI-tested range. Agents following these instructions may set up environments that work but haven't been validated by CI. Consider keeping the CI-tested range here to bias agents toward well-tested configurations:

Suggested change
# Verify prerequisites
ruby -v # Should be 3.2+ (CI tested: 3.2 - 3.4; minimum: 3.0)
node -v # Should be 20+ (CI tested: 20 - 22; minimum: 18)

ruby -v # Should be 3.2+
node -v # Should be 20+
ruby -v # Should be 3.0+
node -v # Should be 18+
rails -v # Should be 7+ (5.2+ supported)
```

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ _Requires creating a free account._

- Ruby on Rails >= 5
- Shakapacker >= 6.0 (CI tested: 8.2.0 - 9.5.0; autobundling requires >= 7.0)
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.

The phrase "package minimum" implies this is enforced by a package metadata field (e.g. engines in package.json), but neither packages/react-on-rails/package.json nor the monorepo root package.json currently declares an engines.node constraint. This is an asserted minimum, not a formally enforced one. Either add an engines field to back up the claim, or rephrase to "documented minimum" to avoid confusion.

- Ruby >= 3.2 (CI tested: 3.2 - 3.4)
- Node.js >= 20 (CI tested: 20 - 22)
- Ruby >= 3.0 (package minimum; CI tested: 3.2 - 3.4)
- Node.js >= 18 (package minimum; CI tested: 20 - 22)
- A JavaScript package manager (npm, yarn, pnpm, or bun)

# 🆘 Get Help & Support
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ React on Rails is one product with two tiers: open source for Rails + React inte
- [API Reference](./oss/api-reference/view-helpers-api.md)
- [Deployment and troubleshooting](./oss/deployment/README.md)
- [Configuration](./oss/configuration/README.md)
- [Changelog](./oss/upgrading/changelog.md)
- [Changelog](https://github.com/shakacode/react_on_rails/blob/main/CHANGELOG.md)

## Pro features

Expand Down
4 changes: 2 additions & 2 deletions docs/oss/api-reference/generator-details.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ can pass the redux option if you'd like to have redux setup for you automaticall
Passing the --rsc generator option sets up React Server Components support.
This automatically includes Pro setup (--rsc implies --pro). Creates RSC
webpack configuration, a HelloServer example component, and RSC routes.
Requires React 19.0.x.
Requires React 19 with a compatible `react-on-rails-rsc` version.

*******************************************************************************

Expand Down Expand Up @@ -261,7 +261,7 @@ rails generate react_on_rails:install --rsc
**Prerequisites:**

- React on Rails Pro gem installed (see Pro prerequisites above)
- React 19.0.x (RSC is not yet supported on React 19.1.x or later)
- React 19 with a compatible `react-on-rails-rsc` version

RSC builds on React on Rails Pro's Node rendering infrastructure. The generator adds a separate webpack entry point for server components, configures the `RSCWebpackPlugin` in both client and server webpack configs, and sets up the `RSC_BUNDLE_ONLY` environment variable handling in `ServerClientOrBoth.js` for independent RSC bundle compilation.

Expand Down
13 changes: 8 additions & 5 deletions docs/oss/building-features/node-renderer/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@ For the most control over the setup, create a JavaScript file to start the NodeR
mkdir renderer-app
cd renderer-app
```
2. Make sure you have **Node.js** version **14** or higher and **Yarn** installed.
3. Init node application and install the `react-on-rails-pro-node-renderer` package.
2. Make sure you have **Node.js 18+** and a JavaScript package manager such as **npm**, **pnpm**, **Yarn**, or **bun**.
3. Initialize a Node application and install the `react-on-rails-pro-node-renderer` package.
```sh
yarn init
yarn add react-on-rails-pro-node-renderer
npm init -y
npm install react-on-rails-pro-node-renderer
# or: pnpm add react-on-rails-pro-node-renderer
# or: yarn add react-on-rails-pro-node-renderer
# or: bun add react-on-rails-pro-node-renderer
```
4. Configure a JavaScript file that will launch the rendering server per the docs in [Node Renderer JavaScript Configuration](./js-configuration.md). For example, create a file `node-renderer.js`. Here is a simple example that uses all the defaults except for serverBundleCachePath:

Expand All @@ -82,7 +85,7 @@ For the most control over the setup, create a JavaScript file to start the NodeR
Create `config/initializers/react_on_rails_pro.rb` and configure the **renderer server**. See configuration values in [Configuration](../../configuration/configuration-pro.md). Pay attention to:

1. Set `config.server_renderer = "NodeRenderer"`
2. Leave the default of `config.prerender_caching = true` and ensure your Rails cache is properly configured to handle the additional cache load.
2. Decide whether to enable `config.prerender_caching = true`. The default is `false`; turn it on only if you want Rails cache-backed SSR result caching and your cache is configured for the additional load.
3. Configure values beginning with `renderer_`
4. Use ENV values for values like `renderer_url` so that your deployed server is properly configured. If the ENV value is unset, the default for the renderer_url is `localhost:3800`.
5. Here's a tiny example using mostly defaults:
Expand Down
59 changes: 45 additions & 14 deletions docs/oss/building-features/node-renderer/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,62 @@
Because the renderer communicates over a port to the server, you can start a renderer instance locally in your application and debug it.

## Yalc vs Yarn Link
## Monorepo Workflow

The project is setup to use [yalc](https://github.com/whitecolor/yalc). This means that at the top level
directory, `yalc publish` will send the node package files to the global yalc store. Running `yarn` in the
`/spec/dummy/client` directory will copy the files from the global yalc store over to the local `node_modules`
directory.
For renderer debugging inside this repo, use the Pro dummy app at `react_on_rails_pro/spec/dummy`.
It is a `pnpm` workspace app and already points at the local packages in this monorepo.

## Debugging the Node Renderer

1. cd to the top level of the project.
1. `yarn` to install any libraries.
1. To compile renderer files on changes, open console and run `yarn build:dev`.
1. Open another console tab and run `RENDERER_LOG_LEVEL=debug yarn start`
1. Reload the browser page that causes the renderer issue. You can then update the JS code, and restart the `yarn start` to run the renderer with the new code.
1. Be sure to restart the rails server if you change any ruby code in loaded gems.
1. Note, the default setup for spec/dummy to reference the pro renderer is to use yalc, which may or may not be using a link, which means that you have to re-run yarn to get the files updated when changing the renderer.
1. Check out the top level nps task `nps renderer.debug` and `spec/dummy/package.json` which has script `"node-renderer-debug"`.
### Quick start: debugging with the full stack running

If you already have the dummy app running via `bin/dev` (which uses `Procfile.dev`), the node renderer is already listening on port 3800 with `--inspect` enabled. To debug:

1. Open `chrome://inspect` in Chrome and connect to the renderer process.
2. Use overmind to isolate renderer logs: `overmind connect node-renderer` (Ctrl-B to detach).
3. After a code change, restart just the renderer: `overmind restart node-renderer`.

### Isolated debugging: manual per-terminal startup

Use this when you need full control over the renderer process — different flags, a specific bundle, or rebuilding just the renderer package.

1. From the repo root, install dependencies and build the local packages:
```bash
pnpm install
pnpm run build
```
1. In one terminal, start the Pro dummy bundle watcher:
```bash
cd react_on_rails_pro/spec/dummy
pnpm run build:dev:watch
```
1. In another terminal, start the renderer with verbose logging:
```bash
cd react_on_rails_pro/spec/dummy
RENDERER_LOG_LEVEL=debug pnpm run node-renderer
```
1. If you want to attach a debugger instead, run:
```bash
cd react_on_rails_pro/spec/dummy
pnpm run node-renderer-debug
```
1. Reload the page that triggers the SSR issue and reproduce the problem.
1. If you change Ruby code in loaded gems, restart the Rails server.
1. If you change code under `packages/react-on-rails-pro-node-renderer`, rebuild that package before restarting the renderer:
```bash
pnpm --filter react-on-rails-pro-node-renderer run build
```
1. If you are debugging an external app instead of the monorepo dummy app, refresh the installed renderer package using your local package workflow (for example `yalc`, `npm pack`, or a workspace link) before rerunning the renderer.

## Debugging Memory Leaks

If worker memory grows over time, use heap snapshots to find the source:

1. Start the renderer with `--expose-gc` to enable forced GC before snapshots:
```bash
node --expose-gc node-renderer.js
cd react_on_rails_pro/spec/dummy
# Adjust the port if your Rails app points at a different renderer URL.
RENDERER_PORT=3800 node --expose-gc client/node-renderer.js
```
2. Take heap snapshots at different times using `v8.writeHeapSnapshot()` (triggered via `SIGUSR2` signal or a custom endpoint).
3. Load both snapshots in Chrome DevTools (Memory tab → Load) and use the **Comparison** view to see which objects accumulated between snapshots.
Expand Down
16 changes: 9 additions & 7 deletions docs/oss/deployment/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ bin/rails generate react_on_rails:install

**Why:** The generator needs clean git state to show you exactly what it changed.

### "Node/Yarn not found"
### "Node or package manager not found"

**Error:** `Yarn executable was not detected` or `Node.js not found`
**Error:** `Node.js not found`, `npm executable was not detected`, or `Yarn executable was not detected`

**Solution:**

- Install Node.js 20+ from [nodejs.org](https://nodejs.org)
- Install Yarn: `npm install -g yarn`
- Or use system package manager: `brew install node yarn`
- Install Node.js 18+ from [nodejs.org](https://nodejs.org)
- Use the bundled `npm`, or install another package manager such as `pnpm`, `yarn`, or `bun`
- On macOS, for example: `brew install node pnpm`

## 🔧 Build Issues

Expand All @@ -51,8 +51,10 @@ bin/rails generate react_on_rails:install
**Solution:**

```bash
# Make sure the NPM package is installed
yarn add react-on-rails
# Make sure the npm package is installed
pnpm add react-on-rails
# or: npm install react-on-rails --save
# or: yarn add react-on-rails

# If using local development with yalc
cd react_on_rails/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ React on Rails installs the matching `react-on-rails` JavaScript package during
If you manage versions manually, keep the Ruby gem and npm package on the same release. Pre-release gems use dots while npm uses hyphens.

```ruby
gem "react_on_rails", "16.4.0.rc.10"
gem "react_on_rails", "16.4.0"
```

```bash
npm install [email protected] --save-exact
# or: yarn add [email protected] --exact
# or: pnpm add [email protected] --save-exact
npm install [email protected] --save-exact
# or: yarn add [email protected] --exact
# or: pnpm add [email protected] --save-exact
# or: bun add [email protected] --exact
```

## 2. Run the generator
Expand Down
2 changes: 1 addition & 1 deletion docs/oss/getting-started/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Before starting, make sure you have:
- **🚨 Shakapacker 6+** (7+ recommended for React on Rails 16)
- **Rails 7+** application (Rails 5.2+ supported)
- **Ruby 3.0+** (required)
- **Node.js 20+** and a package manager (**npm**, **Yarn**, or **pnpm**)
- **Node.js 18+** and a package manager (**npm**, **pnpm**, **Yarn**, or **bun**)
- **Foreman or Overmind** (for running `bin/dev`)
- **Basic familiarity** with React and Rails

Expand Down
2 changes: 1 addition & 1 deletion docs/oss/getting-started/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ bundle exec rails shakapacker:install
Commit all the changes so far to avoid getting errors in the next step.

```bash
git commit -am "Initial commit"
git add . && git commit -m "Initial commit"
```

Alternatively, you can use `--ignore-warnings` in the next step.
Expand Down
2 changes: 1 addition & 1 deletion docs/oss/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Read the full **[React on Rails Doctrine](./misc/doctrine.md)** for our design p

- **Rails 7+** (Rails 5.2+ supported)
- **Ruby 3.0+**
- **Node.js 20+**
- **Node.js 18+**
- **Shakapacker 6+** (7+ recommended for React on Rails v16)

## Need Help?
Expand Down
2 changes: 1 addition & 1 deletion docs/pro/home-pro.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# React on Rails Pro

Node rendering and caching performance enhancements for [React on Rails](https://github.com/shakacode/react_on_rails). Now supports React 18 with updates to React on Rails! Check the [React on Rails CHANGELOG.md](https://github.com/shakacode/react_on_rails/blob/main/CHANGELOG.md) for details and the updates to the [loadable-components instructions](../oss/building-features/code-splitting.md).
Node rendering, caching, streaming SSR, and React Server Components for [React on Rails](https://github.com/shakacode/react_on_rails). Check the [React on Rails CHANGELOG.md](https://github.com/shakacode/react_on_rails/blob/main/CHANGELOG.md) for the latest version and upgrade notes.

## Getting Started

Expand Down
2 changes: 1 addition & 1 deletion docs/pro/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ See [License Configuration](#license-configuration-production-only) below for ot

## Adding React Server Components

RSC requires React on Rails Pro and React 19.0.x. To add RSC support, use `--rsc` (fresh install) or the RSC generator (existing app):
RSC requires React on Rails Pro and React 19 with a compatible `react-on-rails-rsc` version. To add RSC support, use `--rsc` (fresh install) or the RSC generator (existing app):

```bash
# Fresh install with RSC
Expand Down
2 changes: 1 addition & 1 deletion docs/pro/js-memory-leaks.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Avoiding Memory Leaks in Node Renderer SSR

> **Pro Feature** — Available with [React on Rails Pro](https://pro.reactrails.com).
> **Pro Feature** — Available with [React on Rails Pro](https://reactonrails.com/docs/pro/).

## Why Memory Leaks Happen in the Node Renderer

Expand Down
11 changes: 9 additions & 2 deletions docs/pro/react-server-components/create-without-ssr.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ To use Server Components in your React on Rails Pro project, you need to follow
yarn add --exact [email protected]
# npm install --save-exact [email protected]
# pnpm add --save-exact [email protected]
# bun add --exact [email protected]

# Then add the Ruby gems:
bundle add react_on_rails --version "16.4.0" --strict
Expand All @@ -24,11 +25,17 @@ bundle add react_on_rails_pro --version "16.4.0" --strict
Also, install version 19 of React, React DOM, and `react-on-rails-rsc`:

```bash
yarn add [email protected] [email protected] [email protected]
yarn add [email protected] [email protected] [email protected]
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.

The react-on-rails-rsc package is pinned to 19.0.4 in the same command as React 19.0.4, which implies its version tracks React's — but that's not obvious to readers. The note below explains "update to the latest 19.x patch", which suggests the RSC package version intentionally mirrors React's version number. A brief explanation of this convention (e.g. "the react-on-rails-rsc version should match your React version") would prevent confusion when users try to find [email protected] after upgrading React.

# npm install [email protected] [email protected] [email protected]
# pnpm add [email protected] [email protected] [email protected]
# bun add [email protected] [email protected] [email protected]
```

> [!NOTE]
> While React Server Components in React 19 are stable, the underlying APIs used to implement React Server Components bundlers may break between minor versions (19.x). According to the [React Documentation](https://react.dev/reference/rsc/server-components#how-do-i-build-support-for-server-components). React on Rails Pro currently only supports React 19.0.x.
> React on Rails Pro currently supports React 19 with a compatible `react-on-rails-rsc` version.
> The example above pins `19.0.4`; update to the latest `19.x` patch that your `react-on-rails-rsc`
> compatibility range allows. The RSC bundler APIs used internally can change between React minor
> versions. See the [React documentation on Server Components](https://react.dev/reference/rsc/server-components#how-do-i-build-support-for-server-components) for details.

2. Enable support for Server Components in React on Rails Pro configuration:

Expand Down
10 changes: 5 additions & 5 deletions docs/pro/react-server-components/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# React Server Components in React on Rails Pro

> **Pro Feature** — React Server Components require [React on Rails Pro](https://reactonrails.com/docs/pro/) 4+ with the node renderer.
> **Pro Feature** — React Server Components require [React on Rails Pro](https://reactonrails.com/docs/pro/) with the node renderer.
> Free or very low cost for startups and small companies. [Get a license →](https://pro.reactonrails.com/)

## What Are React Server Components?
Expand Down Expand Up @@ -34,7 +34,7 @@ Server components can access databases, file systems, and internal APIs directly

## Current Support Status

React on Rails Pro 4+ provides full RSC support with:
Current React on Rails Pro releases provide full RSC support with:

- RSC webpack loader (`react-on-rails-rsc/WebpackLoader`) for server/client component separation
- RSC webpack plugin (`react-on-rails-rsc/WebpackPlugin`) for client manifest generation
Expand All @@ -44,9 +44,9 @@ React on Rails Pro 4+ provides full RSC support with:

### Requirements

- React on Rails Pro v4.0.0 or higher
- React 19.0.x (19.1.x and later are not yet supported)
- React on Rails v16.0.0 or higher
- React on Rails Pro v16.4.0 or higher
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.

The old requirement listed "React on Rails Pro v4.0.0 or higher", which was a much lower bar. Bumping the documented minimum to v16.4.0 is a significant change — users on v4–v16.3 who relied on that section as a compatibility baseline would now see a different requirement. If there was any RSC support before v16.4.0, a brief deprecation note (e.g. "RSC support was significantly revised in v16.4.0; earlier versions had partial support") would help users on older versions understand what changed.

- React on Rails v16.4.0 or higher
- React 19 with a compatible `react-on-rails-rsc` version
- Node renderer — installed separately via `react-on-rails-pro-node-renderer` npm package (see [Pro Installation](../installation.md#install-react-on-rails-pro-node-renderer))
- Shakapacker or Rspack for bundling

Expand Down
Loading
Loading