Starter template for building TrustGraph UI plugins. Includes a hello world page, an interactive graph explorer, a Graph RAG query view, and an explainable RAG view — all in under 80 lines of code.
- Node.js 20+
- A checkout of trustgraph-ui at
../trustgraph-ui(thedevDependencieslink to it viafile:references)
# Install dependencies
npm install
# Build the IIFE bundle
npm run buildThis produces dist/template.iife.js.
-
Symlink the built file into the demo's public directory:
ln -s $(pwd)/dist/template.iife.js ../trustgraph-ui/packages/demo/public/plugins/template.iife.js -
Add the plugin entry to
packages/demo/public/config/plugins.json. Copy the entry fromplugin-config.jsonin this repo into thedemosarray:{ "id": "template", "title": "Plugin Template", "icon": "\u25b3", "paletteKey": "cyan", "description": "Starter template for building TrustGraph plugins.", "url": "/plugins/template.iife.js", "globalName": "TemplatePlugin" } -
Start (or restart) the demo app and open the Demos page. Your plugin should appear as a card.
After rebuilding the plugin, hard-refresh the browser (Ctrl+Shift+R) because IIFE scripts loaded via
<script>tags are not handled by Vite HMR.
ux-plugin-template/
src/
index.ts # Default export (entry point)
TemplateExplorer.tsx # Main component with tabbed views
vite.config.js # IIFE build config
tsconfig.json # TypeScript config
plugin-config.json # Manifest entry for plugins.json
package.json
Plugins are built as IIFE bundles that export a single React component as
their default export. The demo app loads them via <script> tags and
resolves the component from window[globalName].default.
Shared dependencies (React, trustkit, react-provider, react-state) are
not bundled into the plugin. They are mapped to window.TrustKitShared.*
globals that the host app provides at runtime. This keeps plugin bundles
small and avoids duplicate React instances.
-
Rename the plugin — update
nameinpackage.json,nameandfileNameinvite.config.js, and the entry inplugin-config.json. -
Add your views — create new components under
src/and add tabs inTemplateExplorer.tsx. The template shows the pattern. -
Use trustkit components — everything exported from
@trustgraph/trustkitis available. Some useful ones:Component What it does RawGraphExplorerFull graph explorer (search + canvas + detail panel) SimpleRagViewGraph RAG query with streaming response RagExplainViewSplit-pane RAG with explainability events SimpleAgentViewAgent query with streaming response AgentExplainViewSplit-pane agent with explainability events SimpleDocRagViewDocument RAG query useTheme()Access theme colors and scalable font sizing useRawGraphState()Low-level graph state if you need custom layout LoadingStateConsistent loading/error display SplitPaneCollapsible side panel layout -
Query the knowledge graph — use
useSocket()from@trustgraph/react-providerto access the WebSocket API:import { useSocket } from "@trustgraph/react-provider"; import { useSessionStore, useSettings } from "@trustgraph/react-state"; const socket = useSocket(); const flowId = useSessionStore((s) => s.flowId); const { settings } = useSettings(); const api = socket.flow(flowId); const triples = await api.triplesQuery( subject, predicate, object, limit, settings.collection, "" );
-
Add npm dependencies — any package you add to
dependencieswill be bundled into the IIFE. Keep it lean for fast loads.
See LICENSE.