Render React components as async functions — await user interaction just like fetching data.
promise-render is a tiny utility that lets you render a React component imperatively and wait for its result via a Promise. Perfect for confirmation dialogs, pickers, wizards, forms, and any UI that needs to “return a value” to your async code.
- Render any React component and get its output via a Promise
- Call UI from thunks, sagas, services, or any async function
- No context, no event bus, no global stores
- Component automatically unmounts after resolve/reject
- TypeScript support included
promiseRender(Component) returns a pair:
- AsyncComponent is a React component you render once (e.g. in a modal root).
- asyncFunction(props?) renders that component and returns a Promise.
- Inside the component, two special props are available:
- resolve(value) — resolves the promise & unmounts the component
- reject(error) — rejects the promise & unmounts the component
This allows you to control UI flow like this:
- ✅ No global event emitters.
- ✅ No prop drilling.
- ✅ Just await your UI.
You can pass any props to the async function. They will be forwarded to the component automatically.
- ✅ Confirmation dialogs
- ✅ Pickers / Select modals
- ✅ Login or consent popups
- ✅ Form dialogs that “return” values
- ✅ Wizards or multi-step flows
- ✅ Any async interaction that should “pause” logic until user acts
If you ever wished JavaScript had await confirmDialog() — now it does.
promise-render handles lifecycle automatically:
- Component mounts when the async function is called
- Component unmounts when resolve or reject is triggered
- The same mounted component instance is reused between calls
No global state or manual cleanup required.
This project is licensed under the MIT License - see the LICENSE file for details.
Feel free to extend or modify this README according to your preferences!
.png)


