Derived values

Derived signals

Edit this page

Derived signals are functions that rely on one or more signals to produce a value.

These functions are not executed immediately, but instead are only called when the values they rely on are changed. When the underlying signal is changed, the function will be called again to produce a new value.

const double = () => count() * 2;

In the above example, the double function relies on the count signal to produce a value. When the count signal is changed, the double function will be called again to produce a new value.

Similarly you can create a derived signal that relies on a store value because stores use signals under the hood. To learn more about how stores work, you can visit the stores section.

const fullName = () => store.firstName + ' ' + store.lastName;

These dependent functions gain reactivity from the signal they access, ensuring that changes in the underlying data propagate throughout your application. It is important to note that these functions do not store a value themselves; instead, they can update any effects or components that depend on them. If included within a component's body, these derived signals will trigger an update when necessary.

While you can create derived values in this manner, Solid provides the createMemo primitive for cached, read-only derived values. To dive deeper into how memos work, check out the memos section.


Writable derived signals (Solid 2.0)

In Solid 2.0, createSignal can accept a function as its first argument to create a writable derived signal. This is a signal whose value is computed reactively from other signals, but can also be overridden with the setter:

const [count, setCount] = createSignal(0);
// A derived signal that tracks `count` and doubles it
const [doubled] = createSignal(() => count() * 2);
doubled(); // 0
setCount(3);
// After flush, doubled() will be 6

This pattern replaces the removed createComputed primitive from Solid 1.x. Use it when you need a derived value that can also be written to (e.g. controllable components, manual overrides). For read-only derived values, prefer createMemo.

Report an issue with this page