UNPKG

dinou

Version:

Dinou is a modern React 19 framework with React Server Components, Server Functions, and streaming SSR.

24 lines (18 loc) 570 B
import { use } from "react"; import { createFromFetch } from "@matthamlin/react-server-dom-esm/client"; import { hydrateRoot } from "react-dom/client"; const cache = new Map(); const route = window.location.href.replace(window.location.origin, ""); function Root() { let content = cache.get(route); if (!content) { content = createFromFetch(fetch("/____rsc_payload____" + route)); cache.set(route, content); } return use(content); } hydrateRoot(document, <Root />); // HMR if (import.meta.hot) { import.meta.hot.accept(); }