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

vite-plugin-rsc-pages

v0.1.1

Published

React Server Components (RSC) NextJS-like app router plugin for Vite.

Downloads

8

Readme

vite-plugin-rsc-pages

React Server Components (RSC) NextJS-like app router plugin for Vite.

Overview

The plugin is built on top of @vitejs/plugin-rsc and provides file system based routing with RSC and server actions.

Features

  • RSC (React Server Components) & SSR (Server Side Rendering)
  • Server Actions
  • File system based routing with pages and layouts
  • Custom not found pages
  • Support for CSS and static assets
  • Helpers for RSC components
  • Works out of the box

Basic Concepts

This example is a basic NextJS-like app router that uses RSC components to render pages.

app/layout.tsx:

'use client';

import { LayoutProps } from '~rsc';

export default function Layout({ children }: LayoutProps) {
    return (
        <html lang="en">
            <body>{children}</body>
        </html>
    );
}

app/page.tsx:

'use client';

import { PageProps } from '~rsc';

export default function Page({ url }: PageProps) {
    return <h1>{url}</h1>;
}

app/not-found.tsx:

'use client';

import { PageProps } from '~rsc';

export default function NotFound({ /* ... */ }: PageProps) {
    return <h1>Not Found.</h1>;
}

Routing

app/path/page.tsx - will be rendered at /path

app/path/layout.tsx - will be used as a layout for /path/*

app/path/[id]/page.tsx - will be rendered at /path/123 where id is a dynamic parameter:

import { PageProps } from '~rsc';

export default function Page({ params }: PageProps<{ id: string }>) {
    return <h1>{params.id}</h1>;
}

app/path/[...all]/page.tsx - will be rendered at any path starting with /path/

Server Actions

'use server'

let serverCounter = 0

export async function getServerCounter() {
    return serverCounter
}

export async function updateServerCounter(change: number) {
    serverCounter += change
}

Taken from github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-rsc/examples/starter/src/action.tsx.

Getting Started

Install necessary RSC plugins:

npm i -D vite-plugin-rsc-pages @vitejs/plugin-rsc

Make sure you also have @vitejs/plugin-react or @vitejs/plugin-react-swc installed.

Add plugins to your config:

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import rsc from '@vitejs/plugin-rsc';

export default defineConfig({
    plugins: [
        react(),
        rsc(),
        rscPages(),
    ],
});

Update your tsconfig.json:

{
    "compilerOptions": {
        // ...
        "types": ["vite/client", "@vitejs/plugin-rsc/types", "vite-plugin-rsc-pages/types"],
    }
}

Options

root

Type: string
Default: ./app

Path used to resolve pages and layouts.

patterns

Glob patterns used to match pages and layouts.\

page

Type: string
Default: **/page.{js,jsx,ts,tsx}

Glob pattern used to match pages.

layout

Type: string
Default: **/layout.{js,jsx,ts,tsx}

Glob pattern used to match layouts.

Other Options

For more complex setups, see @vitejs/plugin-rsc.

Helpers

Helpers are exported from ~rsc a virtual module.

rsc

Type: (request: Request) => Promise<Response>

Server request handler for RSC pages.

redirect

Type: (location: string, status?: 303 | 307 | 308) => void
Default status: 308 (Permanent Redirect)

Redirects to another location in the server environment.

'use server';

import { redirect } from '~rsc';

export default async function Page() {
    redirect('/path');
}

Helper types

export interface PageProps<
    TParams extends Record<string, string> = Record<string, string>,
    TSearch extends Record<string, string> = Record<string, string>,
> {
    params: TParams;
    searchParams: TSearch;
    headers: Headers;
    url: string;
}

export interface LayoutProps<
    TParams extends Record<string, string> = Record<string, string>,
    TSearch extends Record<string, string> = Record<string, string>,
> extends PageProps<TParams, TSearch> {
    children: ReactNode;
}

License

MIT 💖