One domain. One hook.
comwit is state management for React and Next.js, built for vibe coding. Give your coding agent
llms.txt: one compact guide covers the core interface, domain structure, and examples
it needs to start building.
It powers the comwit.io vibe coding platform, where more than 1,000 projects use it. Sponsored by burrr.ai.
The interface
// Load when the view mounts. Render the query state directly.
const products = useProduct((s) => s.products.load(filter))
// Read existing data without starting a request.
const detail = useProduct((s) => s.detail.data)
// Keep mutations and side effects in the domain.
const actions = useProduct((s) => s.actions)
A domain defines its types, initial state, and actions. create() combines them into a hook.
Actions mutate state directly; components subscribe to the fields they use. One ComwitProvider
scopes the state for your app, and models initialize on access.
Pick the data flow
| You need to… | Use |
|---|---|
| Fetch for a mounted view | query() + .load(arg) |
| Render data fetched by a Server Component | useDomain.hydrate(...) |
| Restore an exact IndexedDB snapshot and revalidate | local.query() |
| Restore cached data without an API call | local() + .restore(arg) |
| Save preferences or a local draft | persist() |
| Run a command, optimistic update, or several requests | action() |
Related lists, details, filters, and UI state stay in the same domain. Add derived values, validation, undo/redo, or action decorators when the feature needs them.
Start building
- Quickstart — install, create a domain, and render it.
- LLM Setup — hand your agent the interface in one file.
- Project Structure — grow from one domain to a full app.