ilokesto

createOverlayStore

createOverlayStore() returns an OverlayStoreApi with open, close, remove, clear, subscribe, getSnapshot, and getInitialSnapshot. Internally it stores OverlayState in @ilokesto/store and keeps pending promise resolvers by overlay id.

const store = createOverlayStore();
const request = store.open<boolean>({ type: 'confirm', props: { title: 'Delete?' } });
store.close(request.id, true);
store.remove(request.id);
const result = await request.promise;

open creates an OverlayItem and returns { id, promise }. close marks a matching open item as closing and records closeResult. remove removes a specific item, or the last item when no id is passed, and settles the promise. clear settles and removes every item. Use the store directly in tests or advanced shells; use useOverlay in normal React components.

Practical note

The reference pages describe the runtime contract exactly. Guides may wrap these APIs into product-specific helpers, but those helpers should keep the same lifecycle language: open creates an item, close starts a closing state, remove settles and deletes an item, and clear ends every pending overlay in the provider scope.

On this page