@supermemory/memory-graph on npm
Check out the NPM page for more details
Installation
Quick start
Two pieces: a server route that reads the signed-in user’s graph, and<MemoryGraph endpoint> in the browser.
1. Add a server route
fetchMemoryGraph from @supermemory/memory-graph/server calls POST /ns/{namespace}/graph with your API key, follows nextCursor to the last page and returns the documents MemoryGraph renders. It uses only the global fetch, so it runs on Node 18+, Bun, Deno, Cloudflare Workers and other edge runtimes.
fetchMemoryGraph options:
On a failed request it throws
MemoryGraphError, whose status is the API’s status code and whose message is the API’s reason: 400 for an invalid namespace or limit, 401 for a bad key, 403 when the key cannot read the namespace, 429 when rate limited.
2. Render the graph
MemoryGraph sends a POST to endpoint (cookies are sent to a same-origin route, so your session auth applies) and shows a loading indicator, then the graph. An empty namespace shows “No memories yet” (override it with labels.emptyGraph or children), and a failed request shows the error.
Other backends
From Python, Go, Ruby or any other server, call the API directly and return the result from your route:POST https://api.supermemory.ai/ns/{namespace}/graph?limit=100withAuthorization: Bearer $SUPERMEMORY_API_KEYand the JSON body{}.- The response is
{ nodes, edges, nextCursor }. WhilenextCursoris notnull, repeat the call with&cursor=<nextCursor>. - Return
{ "nodes": [...], "edges": [...] }with the nodes and edges of every page.<MemoryGraph endpoint>accepts this shape as well as the arrayfetchMemoryGraphreturns.
Python
Optional rendering and document navigation
Existing icon-based document nodes and connection styling remain the defaults. Opt in to stacked squares and stronger semantic connections withappearance:
documentNodes accepts 'icons' or 'stacked'; connections accepts 'default' or 'emphasized'. Both fields are optional and also work on GraphCanvas. Stacks stay inside existing node bounds and simplify at low zoom. Use colors.edgeDocument to configure document-source ink; older custom GraphCanvas palettes without that field use textSecondary in emphasized mode.
openDocumentOnEnter is off by default. With an onOpenDocument callback, MemoryGraph exposes a focused Enter action for the selected persisted document or one confirmed memory source. Typing, modifier shortcuts, repeats, composition and keys outside the graph do not open documents. Your callback retains responsibility for routing and access control; consumers without a callback receive no new opening behavior.
Variants
Console Variant - Full dashboard view: themed surface with a dot grid, nodes colored by theme:Examples
Paging in the browser
To load pages on demand instead of the whole graph in one request, return one raw page from your route (step 1 of Other backends, forwardingcursor) and pass documents yourself, converting each page with graphPageToDocuments:
Highlighting search results
Custom empty state
Props reference
Core props
Pagination props
Display props
Data types
GraphApiDocument
GraphApiMemory
GraphPage
One page ofPOST /ns/{namespace}/graph: { nodes, edges, nextCursor }. graphPageToDocuments(page) turns it into GraphApiDocument[].
DocumentWithMemories and MemoryEntry are still exported as backward-compatible types.
Exports
Components
Server
Adapters
Hooks
Engine classes
Constants
Performance
The graph handles hundreds of nodes efficiently through:- Canvas-based rendering (not DOM elements)
- Viewport culling (only draws visible nodes)
- Level-of-detail optimization (simplifies when zoomed out)
- Change-based rendering (only redraws when state changes)