Skip to main content
Memory Graph is a React component that visualizes your Supermemory documents and memories as an interactive network. Documents appear as rectangular nodes, memories as hexagonal nodes, and connections between them show relationships and similarity.

@supermemory/memory-graph on npm

Check out the NPM page for more details

Installation

Requirements: React 18.0.0 or higher

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.
Keep the API key on the server. It can read and write every namespace in your organization, so a key shipped to the browser lets anyone read every user’s memories. Your route checks who is signed in and only ever passes that user’s namespace.
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:
  1. POST https://api.supermemory.ai/ns/{namespace}/graph?limit=100 with Authorization: Bearer $SUPERMEMORY_API_KEY and the JSON body {}.
  2. The response is { nodes, edges, nextCursor }. While nextCursor is not null, repeat the call with &cursor=<nextCursor>.
  3. Return { "nodes": [...], "edges": [...] } with the nodes and edges of every page. <MemoryGraph endpoint> accepts this shape as well as the array fetchMemoryGraph returns.
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 with appearance:
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:
Consumer Variant - Embedded widget view: transparent surface, nodes colored by cluster:

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, forwarding cursor) 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 of POST /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)
For very large datasets (1000+ documents), use pagination to load data in chunks.

Browser support

Works in all modern browsers supporting Canvas 2D API, ES2020, and CSS custom properties. Tested on Chrome, Firefox, Safari, and Edge.