@k8ordo/framework
A React Server Components framework that lets the same code run with or without a server
npm
yarn
pnpm
npm install -D @k8ordo/framework @k8ordo/routervite.config.tsimport { framework } from '@k8ordo/framework/vite';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [framework({ mode: 'static' })],
});src/routes/products/page.tsxexport default function ProductsPage() {
return <h1>Products</h1>;
}vite builddist/client/
products/index.htmlURLs from the directory tree
Under src/routes/, a directory is a URL segment and page.tsx is the page at that URL. [id] is a parameter.
A page another route always answers first, or two files for the same URL, fail the build, and the error names the files.
src/routes/
layout.tsx
page.tsx
not-found.tsx
products/
page.tsx
[id]/page.tsxTwo modes, chosen per app
mode: 'static' renders the pages at build time, into an app that goes on a static host with no server. mode: 'server' renders on a server per request, into an app that can also use Server Actions and cookies.
Pages and layouts are written the same way in both modes.
vite.config.tsframework({ mode: 'static' });Terminalvite buildvite.config.tsframework({ mode: 'server' });Terminalvite build
node dist/server.js