---
title: Twist
description: The runtime your pages run on: React's API, and Solid's, on one core of fine-grained signals, with nothing to install.
section: Frontend
order: 1.5
---

# Twist

The runtime your pages run on: React's API, and Solid's, on one core of fine-grained signals, with nothing to install.

Twist is Sluurp's own runtime for components. Your app writes React as React is written, and Sluurp answers every `react`, `react-dom` and `react-dom/client` import with Twist. There's no virtual DOM: a component runs once, and when state changes, only the parts of the page that read it update. To write a component, import React as usual:

```tsx title="counter.tsx"
import { useState } from "react";

export function Counter() {
  const [count, setCount] = useState(0);
  return <button onClick={() => setCount(count + 1)}>Clicked {count} times</button>;
}
```

Features include:

- React 19's API: hooks, Suspense, transitions, context, refs and portals
- Server rendering, streaming and hydration, for [server components](/docs/server-components) and islands
- Fine-grained updates on signals, with no diffing of a virtual DOM
- Solid 2's API beside React's, in the same tree
- The same runtime for your pages, your islands and Sluurp's admin

## React, with nothing to install

Your app doesn't install React's runtime: the server answers React's modules with Twist, in development, in production builds and when it renders pages on the server. Libraries written for React (shadcn's components, Base UI, charts) work unchanged, because they import `react` like your code does.

Your editor gets React's and Solid's types from Twist, so there's nothing to add to your `package.json`. React's come from `@types/react` 19.3, which Twist depends on. Solid's are Twist's own, its JSX included. A new app's `tsconfig.json` is set for React, with Solid's types named too:

```json title="tsconfig.json"
{
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "react",
    "types": ["bun", "@sluurp/twist/solid-types"]
  }
}
```

A Solid component beside React ones says so at the top of its file:

```tsx title="counter.tsx"
/** @jsxImportSource @solidjs/web */
import { createSignal } from "solid-js";

export function Counter() {
  const [count, setCount] = createSignal(0);
  return <button onClick={() => setCount(count() + 1)}>{count()}</button>;
}
```

In an app written only with Solid, set it for the whole app instead:

```json title="tsconfig.json"
{
  "compilerOptions": {
    "jsx": "preserve",
    "jsxImportSource": "@solidjs/web",
    "types": ["bun", "@sluurp/twist/solid-types"]
  }
}
```

The same goes for Sluurp's client: `@sluurp/client` and `@sluurp/react` come with Sluurp (see [Browser client](/docs/client)).

## Signals underneath

Every piece of state is a signal, and every component, memo and effect reads the signals it uses. When one changes, Twist runs only what read it. That's why a list of 10,000 rows updates a row without visiting the others, and why React's `useMemo` and `memo` matter less here.

Sluurp's own reactive APIs use the same signals. `@sluurp/twist/signals` gives you `signal`, `computed` and `effect` for state that lives outside components:

```ts title="cart.ts"
import { computed, signal } from "@sluurp/twist/signals";

export const items = signal<{ price: number }[]>([]);
export const total = computed(() => items().reduce((sum, item) => sum + item.price, 0));
```

In a component, `useSignal` from `@sluurp/react` reads one and draws again when it changes:

```tsx title="total.tsx"
import { useSignal } from "@sluurp/react";
import { total } from "./cart";

export function Total() {
  const [sum] = useSignal(total);
  return <p>Total: {sum}</p>;
}
```

[Sync](/docs/sync) and [live views](/docs/live-views) keep rows current in these same signals.

## Solid components

Twist also answers Solid 2's API: `createSignal`, `createMemo`, stores, `<For>`, `<Show>` and `<Loading>`. A file that imports `solid-js` or `@solidjs/web` is compiled as a Solid component, to templates whose changing parts alone are bound to the page. React and Solid components can render each other in the same tree; the code that lets them is loaded only on pages where one draws the other.

Solid's APIs follow Solid 2's release candidate and may still change with it.

## Compatibility

Twist is checked against React's and Solid's own test suites. With React 19, all 4,065 tests pass. With Solid 2, all 8,906 tests pass. Tests that only check Solid's private structures or its own build files are left out, and so are a few where Twist works differently on purpose, each with its reason.

Twist is in beta (version 0.5). It also works outside Sluurp, with Vite: see [Twist on GitHub](https://github.com/SluurpHQ/twist).
