Layout

Motion · Next.js

Add to cart, and see it's done

The button says what it's doing, adding then added, and makes room for a way to the cart.

With Wardic: Solid 1 · Solid 2

Live demo

Loading the piece…

Reduced motion: The button changes width at once, and "View cart" fades in without sliding.

Beside Wardic

React 19's useOptimistic is Solid 2's createOptimistic: "Adding…" shows at once inside the transition, and goes when it ends, the store answered or not (Solid 1 reads the router's useSubmission). The write is a server action that calls refresh(), which renders the page's server components again: the piece is read again along with the cart, where Solid revalidates the cart's query alone.

The code

Highlighting…