An open API service indexing awesome lists of open source software.

https://github.com/renderffx/ppr-scratch

partial-pre-rendering engine react 19
https://github.com/renderffx/ppr-scratch

ppr render static-hole

Last synced: 6 days ago
JSON representation

partial-pre-rendering engine react 19

Awesome Lists containing this project

README

          

# ppr-scratch

[![CI](https://github.com/renderffx/ppr-scratch/actions/workflows/ci.yml/badge.svg)](https://github.com/renderffx/ppr-scratch/actions/workflows/ci.yml)

Next.js-style Partial Prerendering engine using React 19 Canary (`prerenderToNodeStream` / `resumeToPipeableStream`).

## Quick Start

```bash
npm install
npm run build
npm start
# http://localhost:3000
```

## Commands

| Command | Description |
|---------|-------------|
| `npm run build` | Full pipeline: prereqs → clean → bundle → RSC flight → prerender |
| `npm start` | Start Express server on port 3000 |
| `npm run test` | Artifact contract tests |
| `npm run test:unit` | Unit tests (phase, dynamic-apis, flight-cache) |
| `npm run test:e2e` | End-to-end prerender→resume pipeline test |
| `npm run test:all` | All tests |
| `npm run dev:loop` | Build + all tests |
| `npm run clean` | Remove `dist/` |
| `npm run clean:cache` | Remove `.rsc_cache/` |
| `npm run prewarm` | Prewarm RSC cache entries |

## API

| Method | Path | Description |
|--------|------|-------------|
| GET | `/` | Serves static prerendered shell HTML |
| GET | `/rsc-payload` | Raw RSC Flight v1 binary payload |
| GET | `/cache/:name` | Cached RSC entry by component name |
| POST | `/resume` | Resume postponed boundaries (JSON) |
| POST | `/resume/stream` | Resume boundaries as chunked HTML |
| GET | `/api/status` | Build status and artifact health |
| GET | `/api/manifest` | Raw build manifest |

Environment: `PORT` (default 3000), `PPR_RESUME_TIMEOUT` (default 10000ms).

## Architecture

### Build Pipeline

```
src/App.js ──esbuild──▶ dist/App.bundle.js

build-rsc.js │
└── react-server-dom-webpack ──▶ dist/rsc-payload.bin

build.js
├── setPhase('prerender')
├── prewarm-cache → .rsc_cache/*.bin
├── prerenderToNodeStream(App)
│ └── dynamic components throw NEVER promise
│ └── Suspense boundaries → postponed state
│ └── onShellReady fires → abort(request) via patch
│ └── resolves with {postponed, prelude}
├── prelude → dist/shell.html ( markers)
├── postponed JSON → dist/postponed.json
├── RSC payload embedded in shell