Skip to content
Migrate from Solid · @pyreon/solid-compat

Your Solid components run on day one.

@pyreon/solid-compat runs Solid's API on Pyreon: signals, memos, effects, stores, resources and the control-flow components. Solid and Pyreon already share the model, so the final move is mostly a change of signal shape.

npm install @pyreon/solid-compat @pyreon/core @pyreon/reactivity @pyreon/runtime-dom npm install -D @pyreon/vite-plugin
before and after

The same Solid code, on Pyreon.

Migrating from Solid: before and after Solid to Pyreon, before and after: the same Solid component (11 lines) and its Pyreon version (11 lines). 4 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 { createMemo, createSignal } from 'solid-js' export function Counter(props: { step: number }) { const [count, setCount] = createSignal(0) const doubled = createMemo(() => count() * 2) return ( <button class="counter" onClick={() => setCount((c) => c + props.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 SOLID · THEN, ONE COMPONENT AT A TIMEBEFORE · SOLID (RUNS AS-IS ON SOLID-COMPAT)−import { createMemo, createSignal } from 'solid-js'export function Counter(props: { step: number }) {− const [count, setCount] = createSignal(0)− const doubled = createMemo(() => count() * 2) return (− <button class="counter" onClick={() => setCount((c) => c + props.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/solid-compat covers, and what it does not.

covers
  • Signals: createSignal, createMemo, createEffect, createComputed, createRenderEffect, createRoot, on, batch, untrack.
  • onMount, onCleanup; mergeProps, splitProps, children; createContext, useContext; getOwner, runWithOwner.
  • createResource with loading, error, latest and Solid's five state values.
  • Stores: createStore, reconcile, unwrap, produce; createSelector.
  • Control flow: <For>, <Index>, <Show>, <Switch>, <Match>, <Dynamic>, <Portal>, <ErrorBoundary>, <Suspense>; mapArray, indexArray.
  • observable, from, lazy, createDeferred, createReaction, catchError, createUniqueId, render, hydrate.
does not cover
  • Fine-grained updates inside compat components: a setter re-runs the whole component body (output and lifecycle stay correct). Converted Pyreon components get per-node updates back.
  • Mutable stores (createMutable, modifyMutable), onError and isServer: not exported, so an import fails loudly.
  • Solid's SSR entry points (renderToString, renderToStream, HydrationScript, NoHydration, Assets): use Pyreon's own SSR.
  • dom-expressions helpers (template, insert, spread, classList, delegateEvents): Pyreon's compiler replaces Solid's Babel plugin.
  • startTransition and useTransition run synchronously; isPending is always false.
setup

Install it, point the config at it.

npm install @pyreon/solid-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: 'solid' })],
})

Use it in place of vite-plugin-solid. Aliases solid-js and its JSX runtime.

tsconfig.json
// tsconfig.json
{
  "compilerOptions": {
    "jsx": "preserve",
    "jsxImportSource": "@pyreon/solid-compat"
  }
}

As given in the package README.

or start from a scaffold
npm create @pyreon/zero@latest my-app -- --compat solid
port it

Then, one component at a time

Solid (runs as-is on solid-compat) · Counter.tsx
import { createMemo, createSignal } from 'solid-js'

export function Counter(props: { step: number }) {
  const [count, setCount] = createSignal(0)
  const doubled = createMemo(() => count() * 2)
  return (
    <button class="counter" onClick={() => setCount((c) => c + props.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 read stays count(); the write moves from setCount to count.set / count.update. Lists keep <For each={rows()}> and add a key: <For each={rows()} by={(r) => r.id}>.