Bones
Suspense wrapper that automatically renders skeletons as the fallback.
import { Bones } from "@lovo/bones";<Bones> wraps its children in a <Suspense> boundary. The fallback is the same component tree, but with all Promise props replaced by forceBones and a loading flag set so nested createBones calls return skeleton attributes.
Usage
import { Bones } from "@lovo/bones";
export default function Page() {
return (
<Bones>
<UserCard user={fetchUser()} />
</Bones>
);
}When fetchUser() is pending, <Bones> renders <UserCard> with skeletons. When it resolves, the real content appears.
How the fallback works
<Bones>clones each direct child element.- Any prop that is a
Promisegets swapped withforceBones. - The fallback subtree runs inside a
React.cache-based loading context, so allcreateBonescalls return skeleton attributes. - When the real promises resolve, React swaps in the actual content.
Props
| Prop | Type | Description |
|---|---|---|
children | ReactNode | Components that receive Promise data props |
Notes
<Bones>only swapsPromiseprops on direct children. Deeply nested promises need their own<Bones>or<Suspense>boundary.- Multiple
<Bones>boundaries on a page are independent. Each one reveals content when its promises resolve.