Skip to content

Conversation

@onurtemizkan
Copy link
Collaborator

@onurtemizkan onurtemizkan commented Jan 19, 2026

Resolves: #17337

Adds experimental instrumentation for React Router v7.9.0+ React Server Components (RSC).

React Router's RSC support is currently behind unstable_reactRouterRSC() and subject to change. These wrappers provide error capture and performance tracing for RSC server requests, server components, and server functions.

RSC Request Handlers

Added wrapMatchRSCServerRequest() and wrapRouteRSCServerRequest():

  • wrapMatchRSCServerRequest - Wraps RSC server matching with spans for generateResponse and loadServerAction
  • wrapRouteRSCServerRequest - Wraps SSR request handling with spans for fetchServer and renderHTML
// rsc-handler.ts
import {
  unstable_matchRSCServerRequest as matchRSCServerRequest,
  unstable_routeRSCServerRequest as routeRSCServerRequest,
} from "react-router";
import { wrapMatchRSCServerRequest, wrapRouteRSCServerRequest } from "@sentry/react-router";

const sentryMatchRSCServerRequest = wrapMatchRSCServerRequest(matchRSCServerRequest);
const sentryRouteRSCServerRequest = wrapRouteRSCServerRequest(routeRSCServerRequest);

Server Components

Added wrapServerComponent() for error instrumentation:

// routes/users.$id.tsx
import { wrapServerComponent } from "@sentry/react-router";

async function _UserPage({ params }: Route.ComponentProps) {
  const user = await getUser(params.id);
  return <UserProfile user={user} />;
}

export const ServerComponent = wrapServerComponent(_UserPage, {
  componentRoute: "/users/:id",
  componentType: "Page",
});

Redirect (3xx) and not-found (404) responses are not captured as errors.

Server Functions

Added wrapServerFunction() and wrapServerFunctions() for "use server" functions:

// actions.ts
"use server";
import { wrapServerFunction } from "@sentry/react-router";

async function _updateUser(formData: FormData) {
  await db.users.update(formData.get("id"), { name: formData.get("name") });
}

export const updateUser = wrapServerFunction("updateUser", _updateUser);

Needs docs PR

@github-actions
Copy link
Contributor

github-actions bot commented Jan 20, 2026

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 9,035 - 8,944 +1%
GET With Sentry 1,712 19% 1,786 -4%
GET With Sentry (error only) 6,020 67% 6,223 -3%
POST Baseline 1,205 - 1,206 -0%
POST With Sentry 569 47% 597 -5%
POST With Sentry (error only) 1,063 88% 1,064 -0%
MYSQL Baseline 3,296 - 3,304 -0%
MYSQL With Sentry 425 13% 513 -17%
MYSQL With Sentry (error only) 2,678 81% 2,667 +0%

View base workflow run

@onurtemizkan onurtemizkan force-pushed the onur/react-router-rsc-experimental branch from 1357e0d to 159fb80 Compare January 23, 2026 14:35
@onurtemizkan onurtemizkan force-pushed the onur/react-router-rsc-experimental branch from 159fb80 to 07fc2d6 Compare January 23, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support React Router Server Components

2 participants