open-rsc
v0.0.82
Published
OpenRSC is an unopinionated, open source React Server Components implementation package for Vite.
Downloads
276
Readme
OpenRSC
OpenRSC is a self-owned, open-source React Server Components implementation package for Vite.
Features
- Lightweight: The OpenRSC archive is ~30kb. No more bloated React applications!
- Asynchronous RSC: Leverage the power of React Server Components for improved performance and user experience.
- Vite HMR: Enjoy hot module replacement, even in server components, for rapid development.
- "use client" directive: Easily distinguish between server and client components.
- Self-owned: Modify OpenRSC to fit your specific project needs and requirements.
- Scalable and Flexible: Designed to grow with your project, from small applications to large-scale systems.
- Framework Agnostic: Supports multiple server frameworks including Hono, Express, Koa, and node-http.
- TypeScript Support: Built with TypeScript for enhanced developer experience and type safety.
Getting Started
Prerequisites
- Node.js (version 14 or higher)
- npm or yarn
- A Vite-based React application
Installation
To install OpenRSC in your Vite project, navigate to the root directory of your repository and run:
npx open-rsc@latest init
This command will guide you through the setup process, including selecting your preferred server framework and project structure.
Configuration
- Route Configuration Add your routes in the routes configuration file generated by the OpenRSC CLI:
export const routes = [
// Route example
{
path: '/',
component: () => import('./modules/lander'),
}
];
- App Entry
Add the OpenRSC router in your app entry (usually
src/app.tsx
):
function App() {
return <OpenRSCRouter routes={routes} />;
}