A Svelte 5 flow/node editor library with typed port connections.
raw, processed) with connection validationpnpm add kaykay
Check out the demo in src/routes/+page.svelte for a complete working example!
<script lang="ts">
import { Canvas, Handle, type NodeProps, type FlowNode } from 'kaykay';
// Define a custom node component
const MyNode = {
// ... your Svelte component with Handles
};
const nodeTypes = { custom: MyNode };
const nodes: FlowNode[] = [
{ id: '1', type: 'custom', position: { x: 0, y: 0 }, data: { label: 'Hello' } },
];
</script>
<Canvas {nodes} {nodeTypes} />
pnpm install
pnpm dev
Then open http://localhost:5173 to see the interactive demo with:
Handles have a port prop that defines what types of connections they accept:
<!-- Only connects to handles with port="raw" -->
<Handle id="in" type="input" port="raw" />
<!-- Accepts multiple port types -->
<Handle id="in" type="input" port="data" accept={["raw", "processed"]} />
MIT