Migrate from React · @pyreon/react-compat
Your React code, on Pyreon's engine.
@pyreon/react-compat covers React 19's public API with near-full parity, and it runs the value-and-re-render model you know: useState returns the value, the body re-runs, deps arrays are honoured. Most components move over with their imports untouched.
npm install @pyreon/react-compat @pyreon/core @pyreon/reactivity @pyreon/runtime-dom
npm install -D @pyreon/vite-plugin before and after
The same React code, on Pyreon.
coverage
What @pyreon/react-compat covers, and what it does not.
covers
- Every React 19 hook except
useEffectEvent:useState,useReducer,useEffect,useLayoutEffect,useInsertionEffect,useMemo,useCallback,useRef,useId,useContext,useSyncExternalStore,useTransition,useDeferredValue,useImperativeHandle,useActionState,useOptimistic,use,useDebugValue. - React's hook rules: positional hooks, deps arrays, stale-closure semantics.
createContext,createPortal,lazy,Suspense,ErrorBoundary,memo,forwardRef,cloneElement,Children,createRef,isValidElement,StrictModeandProfiler(both render their children).createRootandrenderfrom@pyreon/react-compat/dom, standing in forreact-dom/client.- Pyreon's own components work inside a compat app: the router, query, form, toast, head and UI providers ship marked with
nativeCompat()(33 components across 17 packages).
does not cover
- Class components:
ComponentandPureComponentare stubs;setStateandforceUpdatewarn and do nothing, lifecycle methods never fire. - Concurrent rendering:
useTransition,useDeferredValue,startTransitionandflushSyncrun synchronously. - Nested state across a parent re-render: the parent rebuilds its subtree, so a child's
useState,useReduceranduseRefreset anduseEffect([])runs again.memodoes not stop it; lift the state up. useLayoutEffectanduseInsertionEffectrun withuseEffect's timing.react-domresolves to@pyreon/react-compat/dom, which exportscreateRootandrenderonly. ImportcreatePortalandflushSyncfromreact;hydrateRootandreact-dom/serverare not provided.- Libraries that use React internals or its scheduler:
zustand/react'suseStore,@xyflow/react, the heavierreact-ariahooks. Prefer a/vanillaor/coreentry where one exists. versionreports19.0.0-pyreon, so code that checks for an exact React version will not match.- A few React 19 exports:
useEffectEvent,<Activity>,<ViewTransition>andcacheare not provided, so an import of them fails.
setup
Install it, point the config at it.
npm install @pyreon/react-compat @pyreon/core @pyreon/reactivity @pyreon/runtime-dom
npm install -D @pyreon/vite-plugin vite.config.ts
// vite.config.ts
import { defineConfig } from 'vite'
import pyreon from '@pyreon/vite-plugin'
export default defineConfig({
plugins: [pyreon({ compat: 'react' })],
})Use it in place of @vitejs/plugin-react. Aliases react, react/jsx-runtime, react-dom and react-dom/client.
tsconfig.json
// tsconfig.json
{
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "@pyreon/react-compat"
}
}Types and the JSX runtime come from the compat package.
or start from a scaffold
npm create @pyreon/zero@latest my-app -- --compat react port it
Then, one component at a time
React (runs as-is on react-compat) · Counter.tsx
import { useState } from 'react'
export function Counter({ step }: { step: number }) {
const [count, setCount] = useState(0)
const doubled = count * 2
return (
<button className="counter" onClick={() => setCount(count + step)}>
{count} / {doubled}
</button>
)
}Pyreon · Counter.tsx
import { computed, signal } from '@pyreon/reactivity'
export function Counter(props: { step: number }) {
const count = signal(0)
const doubled = computed(() => count() * 2)
return (
<button class="counter" onClick={() => count.update((c) => c + props.step)}>
{count()} / {doubled()}
</button>
)
}The Pyreon side is the final form, after compat is switched off. While the app is still in compat mode, wrap it in nativeCompat() and write the text as an arrow ({() => …}), as in step 4 on /migrate.