Skip to content
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.

Migrating from React: before and after React to Pyreon, before and after: the same React component (11 lines) and its Pyreon version (11 lines). 6 lines change; the changed lines are marked with a minus rail in the before code and a plus rail in the after code. Code before: 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> ) } Code after: 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> ) } MIGRATE FROM REACT · THEN, ONE COMPONENT AT A TIMEBEFORE · REACT (RUNS AS-IS ON REACT-COMPAT)−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> )}AFTER · PYREON+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> )}
An illustration of the code on each side, not a recording.
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, StrictMode and Profiler (both render their children).
  • createRoot and render from @pyreon/react-compat/dom, standing in for react-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: Component and PureComponent are stubs; setState and forceUpdate warn and do nothing, lifecycle methods never fire.
  • Concurrent rendering: useTransition, useDeferredValue, startTransition and flushSync run synchronously.
  • Nested state across a parent re-render: the parent rebuilds its subtree, so a child's useState, useReducer and useRef reset and useEffect([]) runs again. memo does not stop it; lift the state up.
  • useLayoutEffect and useInsertionEffect run with useEffect's timing.
  • react-dom resolves to @pyreon/react-compat/dom, which exports createRoot and render only. Import createPortal and flushSync from react; hydrateRoot and react-dom/server are not provided.
  • Libraries that use React internals or its scheduler: zustand/react's useStore, @xyflow/react, the heavier react-aria hooks. Prefer a /vanilla or /core entry where one exists.
  • version reports 19.0.0-pyreon, so code that checks for an exact React version will not match.
  • A few React 19 exports: useEffectEvent, <Activity>, <ViewTransition> and cache are 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.