Async reactivity

Say a product page shows a hard-coded product, and you want to load it from the server instead. Put the fetch in a createMemo: the memo still returns a Product, not a promise, so the components that show it do not change.

Async data also changes how updates work. When you change an input of an async memo, Solid keeps the current page on screen until the new data is ready, then shows everything at once. The page never shows a mix of old and new data. If you are used to each panel showing its own spinner, this is the part that will surprise you; Updates keep the current page explains it.

The examples continue the shopping cart from the Reactivity page.


A memo that returns a promise

import { Loading, createMemo } from "solid-js";
type Product = { id: string; name: string; price: number; description: string };
async function fetchProduct(id: string): Promise<Product> {
const response = await fetch(`/api/products/${id}`);
if (!response.ok) throw new Error(`Could not load product ${id}`);
return response.json();
}
function ProductDetail(props: { id: string }) {
const product = createMemo(() => fetchProduct(props.id));
return (
<Loading fallback={<p>Loading product…</p>}>
<article>
<h1>{product().name}</h1>
<p>{product().description}</p>
</article>
</Loading>
);
}

product() has type Product, not Product | undefined or Promise<Product>. There is no loading flag to check and no optional chaining.

Until the first result arrives, the nearest Loading boundary shows its fallback. When the promise resolves, the content renders.

When props.id changes later, the fallback does not come back. The current product stays on screen while the next one loads. Updates keep the current page explains why.


Passing is not reading

Only the expressions that read an async value wait for it. Passing the value as a prop does not read it, because a prop compiles to a getter that runs where the child uses it:

function ProductPage(props: { id: string }) {
const product = createMemo(() => fetchProduct(props.id));
return <ProductLayout product={product()} />;
}
function ProductLayout(props: { product: Product }) {
return (
<div class="layout">
<CategoryNav />
<main>
<Loading fallback={<p>Loading product…</p>}>
<ProductDetail product={props.product} />
</Loading>
</main>
</div>
);
}

product={product()} looks like it reads the value before the data exists. It does not: the expression runs when ProductDetail reads props.product.name. ProductLayout and CategoryNav render immediately, and only the detail pane waits.

Derived values behave the same way:

function ProductDetail(props: { product: Product }) {
const priceLabel = createMemo(() => `$${props.product.price.toFixed(2)}`);
return (
<>
<h1>{props.product.name}</h1>
<p>{priceLabel()}</p>
</>
);
}

priceLabel does not know that product is async. While product is loading, priceLabel is loading too, and its readers wait. No await and no promise type appear between the fetch and the JSX.


Fetch high, block low

Because passing a value does not wait for it, you make two separate decisions:

  • Where to create the async value affects performance. Higher in the tree, the request starts earlier.
  • Where to put Loading affects design. Lower in the tree, a smaller region shows a fallback.

Neither decision changes the components in between. Here the fetch is at the top of the app and the boundary is around the one pane that shows a skeleton:

function App() {
const [selectedId, setSelectedId] = createSignal("mug");
const product = createMemo(() => fetchProduct(selectedId()));
return <ProductPage product={product()} onSelect={setSelectedId} />;
}
function ProductPage(props: {
product: Product;
onSelect: (id: string) => void;
}) {
return (
<div class="layout">
<ProductList onSelect={props.onSelect} />
<main>
<Loading fallback={<DetailSkeleton />}>
<ProductDetail product={props.product} />
</Loading>
</main>
</div>
);
}

With a hard-coded product the code would be the same, minus the Loading element.


Nesting is not a waterfall

A child component does not wait for its parent's async value unless it reads that value too:

function ProductDetail(props: { id: string }) {
const product = createMemo(() => fetchProduct(props.id));
return (
<article>
<h1>{product().name}</h1>
<p>{product().description}</p>
<Reviews productId={props.id} />
</article>
);
}
function Reviews(props: { productId: string }) {
const reviews = createMemo(() => fetchReviews(props.productId));
return (
<For each={reviews()}>{(review) => <ReviewRow review={review} />}</For>
);
}

Reviews sits under product().name, but it only reads props.productId, which is available immediately. Both requests start at the same time. The order of requests follows the data, not the component tree.

A waterfall happens only when the second request needs the first response:

const product = createMemo(() => fetchProduct(props.id));
const brand = createMemo(() => fetchBrand(product().brandId));

brand cannot start until product resolves, because the id comes from the response. With attribution enabled, development builds report long chains like this as ASYNC_WATERFALL; see Debugging reactivity.


Updates keep the current page

Once a value has loaded, changing an input does not blank the screen. Solid keeps showing the current value while it loads the next one:

A timeline showing a Loading fallback during the first request, Answer A remaining visible during a held update, and Answer B appearing when the next request settles.

Before the first value, there is nothing to show, so the Loading boundary shows its fallback. After that, Solid holds the update: the page stays as it is until the new value is ready. Other writes made at the same time wait too, and everything appears together, so the page never shows a mix of old and new.

Holding is automatic and does not need a Loading boundary. If you have wrapped updates in a transition before, this is that behavior by default. Loading only decides what shows before the first value.

Several panels on one input

A dashboard has a period selector and three panels. Each panel fetches its own data from the selected period, and the fetches take 200 milliseconds, one second, and ten seconds:

function Dashboard() {
const [period, setPeriod] = createSignal("2026-Q2");
return (
<>
<PeriodSelect value={period()} onChange={setPeriod} />
<Loading fallback={<DashboardSkeleton />}>
<SummaryPanel period={period()} />
<TrendPanel period={period()} />
<AuditPanel period={period()} />
</Loading>
</>
);
}
function SummaryPanel(props: { period: string }) {
const summary = createMemo(() => fetchSummary(props.period));
return <p>{summary().total} orders</p>;
}

If each panel managed its own loading flag, the selector would change at once and each panel would update when its own request finished. For ten seconds the page would show the new period's summary next to the old period's audit log.

In Solid the change to period is held. The selector and all three panels keep the old period, and after ten seconds they all change together. The page never disagrees with itself. The cost is that the fast panels wait for the slow one, and if nothing on the page responds to the click, the page looks frozen for ten seconds.

Neither behavior is right for every screen. A detail page, a form, or totals that must add up should change together. Independent widgets do not need to. Ask this about the update, not about each request:

While this update is in flight, what should the user see?

The user should see…Use
Nothing change until everything that depends on the input is readyThe default. Add isPending to acknowledge the click.
The control they touched reflect their input now, and the content waitlatest on the control, isPending to dim the content.
A placeholder in place of the content for the changed subject<Loading on={key}> around that content.
The input and the rest of the page change now, and one panel keep its old content until its own data loadscreateDeferred for that panel's data, isPending to dim it.

The first two rows usually go together: the tab highlight moves at once, and the content dims until the new content is ready. The third row is for content that should not stay on screen when its subject changes, such as a panel for a different account. The fourth row is for a panel that can fall behind without making the page wrong, such as the ten-second audit log.

Holding applies only to updates. Each panel's first load still shows the nearest Loading fallback, and nested boundaries let panels appear as their own data arrives.

Keep a write out of a held update: onFlush

Writes made in the same synchronous call are applied together, so when one of them starts async work, the others wait with it. That is usually what you want, but not when a component writes its own state and then calls code it does not control:

function Menu(props: { onSelect?: (id: string) => void }) {
const [open, setOpen] = createSignal(false);
const select = (id: string) => {
setOpen(false); // held if onSelect starts a navigation: the menu stays open
props.onSelect?.(id);
};
// ...
}

If onSelect changes the route, the write to open waits for the navigation, and the menu stays open until the next page is ready. onFlush runs its callback once, right after the current batch of writes is applied and before the browser paints, so the write becomes its own update:

const select = (id: string) => {
onFlush(() => setOpen(false)); // closes now, whatever onSelect does
props.onSelect?.(id);
};

The write is still held if something it changes also depends on the pending async work. Call onFlush from event handlers and effect callbacks. In a component body or a computation it warns in development with ON_FLUSH_IN_OWNED_SCOPE; setup after the first stable render belongs in onSettled. queueMicrotask is not a substitute: called before the frame's first write, its callback runs before that flush and the write joins it.


Show that an update is loading: isPending

Because the old value stays visible, the UI needs a way to show that a new one is loading. isPending(fn) returns true while the expression is waiting for new data:

import { For, createMemo, createSignal, isPending } from "solid-js";
function Search() {
const [query, setQuery] = createSignal("");
const results = createMemo(() => searchProducts(query()));
return (
<>
<input onInput={(event) => setQuery(event.currentTarget.value)} />
<ul class={{ stale: isPending(results) }}>
<For each={results()}>{(product) => <li>{product.name}</li>}</For>
</ul>
</>
);
}

Typing changes query, results starts a new request, and the previous results stay on screen with the stale class until the new ones arrive.

You can call isPending on the async source, on a memo derived from it, on a prop several components down, or on the signal whose write started the update:

function App() {
const [selectedId, setSelectedId] = createSignal("mug");
return (
<>
<ProductList selectedId={selectedId()} onSelect={setSelectedId} />
<main class={{ pending: isPending(selectedId) }}>
<ProductPage id={selectedId()} />
</main>
</>
);
}

The fetch is inside ProductPage, and App knows nothing about it. isPending(selectedId) is still true from the click until everything that depends on selectedId has loaded, because the write to selectedId is what is held.

The list highlight does not move on click either. selectedId() keeps its old value like everything else, so the highlighted row always matches the content. To move the highlight immediately, read the input with latest, covered next.

A held update with no visible response looks like a click that did nothing. With attribution enabled, development builds report it as SILENT_HOLD; Debugging reactivity covers the report and the fixes.

isPending reports on updates to a value that has already loaded. On the first load, the read still shows the surrounding Loading fallback.

An error is not pending either. When the request rejects, isPending(results) returns false and does not rethrow the error. A region that reads results only through isPending never reports the failure:

// Avoid: the only read of results is the probe
<Errored fallback={<p>Search failed.</p>}>
<p class={{ stale: isPending(results) }}>Showing results for {query()}</p>
</Errored>
// Prefer: the region also reads the value, so a rejection reaches Errored
<Errored fallback={<p>Search failed.</p>}>
<ul class={{ stale: isPending(results) }}>
<For each={results()}>{(product) => <li>{product.name}</li>}</For>
</ul>
</Errored>

In the Avoid version, a failed search removes the stale class, and the paragraph stays as if the search had succeeded. In the Prefer version, the results() read inside <For> throws the error, and the boundary shows "Search failed.". Read the value itself next to each isPending call, inside the Errored boundary that should report it.


Show the input now: latest

A held update keeps the old input value on screen along with the old content. That is right for the content, but usually not for the control the user touched: a tab that does not highlight when clicked looks broken.

latest(fn) reads the new value before the update is applied:

<ProductList selectedId={latest(selectedId)} onSelect={setSelectedId} />
<main class={{ pending: isPending(selectedId) }}>
<ProductPage id={selectedId()} />
</main>

If an update is waiting, latest(selectedId) returns the new value. Otherwise it returns the current value. Before any value exists, the read shows the Loading fallback as usual.

Use the three together: latest on the control, a plain read for the content, and isPending to dim the content. The highlight moves at once, the old product dims, and the new product replaces it when its data is ready. This is the usual pattern for a held update.

Use latest on inputs, not on data. Reading data through latest can show a new result while the rest of the page still shows the old one. To show a placeholder for a panel instead, see Show a placeholder again.


Let a panel lag: createDeferred

latest changes what one reader shows, but the update is still held until the slowest data loads. When a panel can keep its old data while the rest of the page moves on, create the panel's data with createDeferred instead of createMemo:

function AuditPanel(props: { period: string }) {
const entries = createDeferred(() => fetchAudit(props.period));
return (
<ul class={{ stale: isPending(() => entries()) }}>
<For each={entries()}>{(entry) => <li>{entry.text}</li>}</For>
</ul>
);
}

After its first load, a deferred memo does not hold updates. When the period changes, the selector and the other two panels change at once. The audit panel keeps its old entries, dims through isPending, and shows the new entries when its request finishes.

The difference between the two:

  • latest goes on a reader. That control shows the new input now, but the update still waits for the slow data.
  • createDeferred goes on the source. The update no longer waits for that data at all.

Use createDeferred for data that can lag without making the page wrong: an independent widget, a feed, or search suggestions. Keep createMemo for data that must match the rest of the page, such as totals that must add up or the details of the selected item.

note

A deferred memo can fall behind the page, but never get ahead of it. Its first load shows the nearest Loading fallback as usual. If it reads a value that another update is still holding, its new data appears with that update.


Show a placeholder again: Loading on

Once a Loading boundary has shown content, later updates do not bring the fallback back. Some content should not stay, though. An account panel showing account 1 while account 2 loads is worse than a skeleton.

The on prop tells the boundary to show its fallback again when something it reads changes:

<Loading on={accountId()} fallback={<AccountSkeleton />}>
<AccountPanel id={accountId()} />
</Loading>

When accountId() changes and the new account is not ready, the boundary shows its skeleton instead of the old account, and the update no longer waits for this panel. If the panel was the only thing waiting, the update applies at once: controls outside the boundary show the new id, and the panel shows its skeleton until the account loads. Anything on does not read, such as a refresh of the same account, leaves the content in place as usual.

The fallback appears together with the rest of the update. If nothing else is waiting, that is immediate. If other content outside the boundary is waiting on the same change, the fallback appears when that content is ready, so the skeleton never shows next to a page that has not updated yet. If the same data is also read outside the boundary, the update waits for that data, so the fallback never appears:

// account is createMemo(() => fetchAccount(accountId()))
// Avoid: the heading reads the same account outside the boundary
<h1>{account().name}</h1>
<Loading on={accountId()} fallback={<AccountSkeleton />}>
<AccountDetails account={account()} />
</Loading>
// Prefer: everything that reads the new account is inside the boundary
<Loading on={accountId()} fallback={<AccountSkeleton />}>
<h1>{account().name}</h1>
<AccountDetails account={account()} />
</Loading>

In the Avoid version, picking another account seems to do nothing until the account loads, and then the heading and details change together. The heading outside the boundary keeps the update waiting, so on has no visible effect. Development reports this as LOADING_ON_OUTSIDE_HOLD. The fix is the Prefer version: move every reader of that data inside the boundary.

You then have a design choice:

  • One boundary with on around everything that shows the subject. The whole subject shows one skeleton and appears at once.
  • A boundary with on around each region. Each region shows its own skeleton and appears when its own data arrives.

If neither fits, for example because a title elsewhere shows the same data, drop on and use isPending and latest instead.

on is tracked, so it must read the signal: on={accountId()}, not on={accountId}. Pass several inputs as an array, on={[accountId(), tab()]}.

The same choice applies to the dashboard above. With on={period()} on a boundary around each panel, the period change applies at once: the selector changes, every panel shows its skeleton, and each panel fills in as its request finishes. With on on only one panel, the other two still hold the update, and the panel with on shows its skeleton from when they finish until its own data arrives. Boundaries covers placement and how Reveal orders several boundaries.

Deep diveA skeleton on every refetch: on=

A refetch of the same subject normally leaves the content in place. To show the skeleton on every refetch too, pass the data itself to on:

<Loading on={account()} fallback={<AccountSkeleton />}>
<AccountDetails account={account()} />
</Loading>

Now refresh(account) or a revalidation after an action brings the skeleton back, even when the data is unchanged. As above, a read of account() outside the boundary stops the skeleton from appearing, and development warns. For most regions, keeping the old content with isPending is a better experience.

Deep diveA placeholder value instead of a fallback: loadingValue

Most first loads should show a Loading fallback. When the placeholder can use the same UI as the real data, such as an empty result list, the loadingValue option gives a value to use until the first result arrives:

const results = createMemo(() => searchProducts(query()), {
loadingValue: [] as Product[],
});

A source with a loadingValue does not show a Loading fallback on its first load, and isPending stays false until the first result arrives. Later updates are held as usual. The store form is seedLoadingValue: true on createStore(async () => ..., seed), which makes the seed the placeholder. The createMemo and createStore references list the option contracts.


Handle errors: Errored

If async work rejects, the error passes to everything that reads the value. An Errored boundary shows fallback UI for an error that nothing else handles:

import { Errored, Loading } from "solid-js";
<Errored
fallback={(error, reset) => (
<section>
<p>{String(error())}</p>
<button onClick={reset}>Retry</button>
</section>
)}
>
<Loading fallback={<p>Loading product…</p>}>
<ProductDetail product={product()} />
</Loading>
</Errored>;

Loading and Errored handle separate states. Loading does not catch errors, and Errored does not show loading UI.

An error is not permanent. When the data changes, because an input changed or a refresh finished, the boundary tries again and the content returns. reset retries the failed sources. While the retry runs, the error fallback stays on screen; the Loading inside the boundary does not replace it. Boundaries covers placement and recovery in detail, including how to show a placeholder during a retry.


Read every input before the first await

Solid tracks reads synchronously. An async computation tracks the reads it makes before its first await. A read after the await is not tracked, so a later change to that source does not re-run the computation.

// Avoid: permissions() is read after the await and is never tracked
const profile = createMemo(async () => {
const user = await fetchUser(id());
return { user, canEdit: permissions().includes("edit") };
});
// Prefer: read every input first, then await
const profile = createMemo(async () => {
const userId = id();
const canEdit = permissions().includes("edit");
const user = await fetchUser(userId);
return { user, canEdit };
});

Run the Avoid version and change permissions: the memo does not recompute and the page keeps the old canEdit.

A source first read after await cannot notify you

This is worse when the late read is itself async and still loading. The source cannot notify the computation when it loads, so the computation would stay pending forever. Development builds turn that read into an error so it reaches Errored instead of hanging; production builds do not include the check. Read every reactive input at the top of the function, before the first await.


Stop the work a run started

When a newer run replaces an older one, Solid ignores the older result, but any request, timer, or subscription the older run started keeps going unless you stop it. When cleanup runs depends on whether the run was ever shown:

  • A run that was never shown is cleaned up as soon as a newer run replaces it. An onCleanup registered before the first await cancels an unfinished request:
const results = createMemo(async () => {
const q = query();
const controller = new AbortController();
onCleanup(() => controller.abort()); // before the first await
const response = await fetch(`/search?q=${q}`, { signal: controller.signal });
return response.json();
});
  • The run on screen stays active until its replacement is shown. Its subscriptions and timers keep running, because the user still sees it. Its cleanups run when the replacement appears.

An iterable returned by the computation is closed as soon as the run is replaced, because nothing can show what it yields any more. To stop work as soon as one input changes, put that work in a child computation that reads the input, so it re-runs without waiting for the whole update.

Do not wait on a cleanup from inside the update that replaces it

The cleanups of the run on screen run only when the held update is applied. Anything in that update that waits for one of those cleanups can wait forever, such as a new run that awaits a lock the old run releases in onCleanup. Use the changed input instead: compare against the changed value, or hand the lock over when the new run takes it.


Recap

  • Return a promise from a memo and read the result as a plain value; the type is Product, not Promise<Product> or Product | undefined.
  • Only the expression that reads an async value waits for it; passing it as a prop costs nothing.
  • Create the async value high in the tree so the request starts early, and place Loading low so a small region shows the fallback.
  • Requests are ordered by data dependency, not by component nesting; a waterfall exists only when one request needs another's response.
  • After a value has loaded, a change to its input is held: the current page stays visible and everything updates together when the new value is ready.
  • Acknowledge a held update with isPending on the content and latest on the control the user touched.
  • Put on={key()} on a Loading boundary whose subject changed and should show a placeholder instead of the old content; on is tracked, and the fallback never appears when the same data is also read outside the boundary.
  • Read every reactive input before the first await.
  • Cancel a request with onCleanup and an AbortController registered before the first await.

Next steps

  • Mutations: writes that cross a round trip, with action, createOptimisticStore, and refresh, built up from the client-only cart.
  • Boundaries: where to place Loading and Errored, how Reveal orders sibling regions, and how an errored region recovers.
  • Data fetching patterns: search as you type, several requests per page, pagination, sharing a request, polling, and failures, each as working code.
  • Migrate data fetching from Solid 1: what changes when createResource or an effect-and-flag pattern becomes an async memo, and how to keep the old feel where you want it.
  • Server functions: a "use server" function returns a promise, so everything on this page applies to it unchanged; that page covers the transport, GET reads, and live streams.
Last updated: 11/17/26, 5:53 PMEdit this pageReport an issue with this page