npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

rsbuild-plugin-rsc

v0.0.2

Published

React server component plugin for Rsbuild

Readme

rsbuild-plugin-rsc

This package provides React Server Components (RSC) support for Rsbuild.

Examples

  • client - Client-driven RSC integration
  • server - Full server-rendered application with routing and Server Actions
  • static - Static site generation

Each example includes a complete setup with development and production configurations.

Getting Started

Create an Rsbuild React Project

First, ensure you have a functional Rsbuild React project. If you are starting from scratch, follow the Rsbuild - React guide.

Install Dependencies

Install the plugin along with the necessary RSC runtime dependencies for Rspack:

npm install rsbuild-plugin-rsc react-server-dom-rspack

Note: Server Components require react and react-dom v19.1.0 or later.

Basic Configuration

Add the RSC plugin to your rsbuild.config.js:

import path from 'node:path';
import { defineConfig } from '@rsbuild/core';
import { pluginReact } from '@rsbuild/plugin-react';
import { Layers, pluginRSC } from 'rsbuild-plugin-rsc';

export default defineConfig({
  plugins: [
    pluginReact(),
    pluginRSC({
      layers: {
        ssr: path.join(import.meta.dirname, './src/framework/entry.ssr.tsx'),
      },
    }),
  ],
  environments: {
    server: {
      source: {
        entry: {
          index: {
            import: './src/framework/entry.rsc.tsx',
            layer: Layers.rsc,
          },
        },
      },
    },
    client: {
      source: {
        entry: {
          index: './src/framework/entry.client.tsx',
        },
      },
    },
  },
});

Configuration

environments

  • Type:
type PluginRSCOptions = {
  environments?: {
    server?: string;
    client?: string;
  };
  // other options...
};
  • Default: { server: 'server', client: 'client' }

Specify the names of the server and client environments in your Rsbuild configuration.

To build a React Server Components project, Rsbuild requires two environments: one for server-side code and one for client-side code. By default, these are named server and client respectively. You can customize these names to match your project structure:

import { defineConfig } from '@rsbuild/core';
import { pluginReact } from '@rsbuild/plugin-react';
import { pluginRSC } from 'rsbuild-plugin-rsc';

export default defineConfig({
  plugins: [
    pluginReact(),
    pluginRSC({
      environments: {
        server: 'node',
        client: 'browser',
      },
      // other options
    }),
  ],
  environments: {
    node: {
      // server environment configuration
    },
    browser: {
      // client environment configuration
    },
  },
});

layers

  • Type:
import type { Rspack } from '@rsbuild/core';

type PluginRSCOptions = {
  layers?: {
    rsc?: Rspack.RuleSetCondition;
    ssr?: Rspack.RuleSetCondition;
  };
  // other options...
};
  • Default: undefined

Configure module layer rules to distinguish between RSC and SSR runtimes in the server environment.

The plugin uses layers to differentiate between React Server Components runtime and SSR runtime within the server environment:

  • rsc layer: Modules matching this rule will use the react-server export condition
  • ssr layer: Modules matching this rule will use the default export condition

There are two ways to configure layers:

1. Plugin Options

Define layers directly in the plugin configuration:

import path from 'node:path';
import { pluginRSC } from 'rsbuild-plugin-rsc';

pluginRSC({
  layers: {
    rsc: path.join(import.meta.dirname, './src/framework/entry.rsc.tsx'),
    ssr: path.join(import.meta.dirname, './src/framework/entry.ssr.tsx'),
  },
});

2. Environment Entry Configuration

Specify the layer for each entry point in the Rsbuild environment configuration:

import { Layers } from 'rsbuild-plugin-rsc';

export default defineConfig({
  environments: {
    server: {
      source: {
        entry: {
          index: {
            import: './src/framework/entry.rsc.tsx',
            layer: Layers.rsc,
          },
        },
      },
    },
  },
});

Architecture

This plugin is built on top of Rspack's native RSC implementation. For detailed architecture documentation and implementation details, see the Rspack RSC Documentation.

License

MIT