-
Notifications
You must be signed in to change notification settings - Fork 0
React Integration
lostcause edited this page Aug 24, 2026
·
1 revision
@0xx0lostcause0xx0/polypack/react provides hooks over a
PolyGraph. React is an optional peer dependency, only
loaded from this subpath. React 18 and 19 are supported.
useGraphQuery(graph, queryFn, deps, delay?, nodeTypes?, onError?)
useLiveQuery(graph, querier, deps?, defaultResult?)Both hooks execute immediately, subscribe to graph changes, and support sync or async queries:
-
useGraphQuerydefaults to a 200ms debounce. WhennodeTypesis supplied, change events for other known node types are ignored. Query errors are logged, passed to the optionalonError(error)callback, and set the result toundefined. - The dependency list controls query closure refresh the same way it does
for other React hooks. Changing
nodeTypesordelayupdates the active subscription without requiring dependency-list changes. In-flight queries are serialized; stale results are discarded after dependency changes or unmounting, and one follow-up run is retained when mutations arrive during an asynchronous query.
useWorkingMemory(graph, limit?, deps?, delay?, nodeTypes?, engine?)A live view of the current working memory: the limit
most-activated loaded nodes, re-queried after any graph change (including
activation_updated).
-
depscontrols re-runs and must includelimitwhen it can change. - Without
engine, it ranks bygraph.topActivated(durable score only). - Pass an
ActivationEngineto rank byengine.workingMemoryinstead (durable score plus transient attention frombumpAttention). - Sub-threshold
bumpAttentioncalls never emit a graph change event, so they won't trigger an automatic re-run on their own — include something that changes after a bump indepsif the view needs to reflect it immediately.
Back to Home.
polypack
By feature
- Property graph
- Query builder
- Vector search & embeddings
- Persistence
- Database core
- Schema migrations
- Adaptive memory
- Real-time sync
- React integration
Related projects
In the repo