npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@filekit-studio/diagram

v1.0.10

Published

Declarative Diagram-as-Code & JSON graph compiler for @filekit-studio/sketch

Readme

@filekit-studio/diagram

Declarative Diagram-as-Code & JSON graph compiler for @filekit-studio/sketch.

npm version License: MIT

Documentation • Quickstart Guide • Live Playground

@filekit-studio/diagram lets you generate and render beautiful hand-drawn whiteboards, architecture diagrams, and flowcharts directly from declarative JSON or Diagram-as-Code in React and Next.js.

  • Zero Coordinates Required: Provide nodes, edges, and clusters — the deterministic DAG layout engine positions and aligns everything automatically.
  • Sketch Aesthetics: Powered by @filekit-studio/sketch, rendering organic hand-drawn shapes, rough fills, and magnetic connector arrows.
  • Obstacle Evasion & Corridor Seeking: Orthogonal elbow lines automatically navigate around shapes without crossing intermediate services.
  • Submerged Passthrough Tunneling: Traversed lines automatically turn into subtle dashed X-ray paths underneath shapes.
  • Directional Flows: Supports Left-to-Right (LR), Top-to-Bottom (TB), Right-to-Left (RL), and Bottom-to-Top (BT).
  • Excalidraw Native: Direct conversion from .excalidraw schema files and element arrays.
  • 100% Client-Side: Zero server calls, zero tracking, works fully offline.

Installation

bun add @filekit-studio/diagram @filekit-studio/sketch
# or
npm install @filekit-studio/diagram @filekit-studio/sketch
# or
pnpm add @filekit-studio/diagram @filekit-studio/sketch

Required Stylesheet Import

Import the self-contained stylesheet in your root layout (app/layout.tsx or pages/_app.tsx):

import '@filekit-studio/diagram/styles.css'
// or: import '@filekit-studio/sketch/styles.css'

Zero CSS Leaks: All styles are strictly scoped under .fk-sketch-root. Importing this stylesheet will never conflict with your app's global CSS, fonts, or Tailwind config.


Quickstart

1. Declarative <Diagram /> Component

'use client'

import React from 'react'
import { Diagram, type DiagramData } from '@filekit-studio/diagram'
import '@filekit-studio/diagram/styles.css'

const architecture: DiagramData = {
  title: 'Cloud Payment Pipeline',
  direction: 'LR',
  nodes: [
    {
      id: 'client',
      label: 'Client Browser\n(React / Next.js)',
      shape: 'rectangle',
      color: 'indigo',
      badge: 'FRONTEND',
    },
    {
      id: 'gateway',
      label: 'API Gateway',
      description: 'Kong / Cloudflare',
      shape: 'rounded',
      color: 'blue',
    },
    {
      id: 'auth',
      label: 'Auth Service',
      description: 'JWT / OAuth2',
      shape: 'diamond',
      color: 'amber',
    },
    {
      id: 'db',
      label: 'Primary Database\n(PostgreSQL)',
      shape: 'cylinder',
      color: 'emerald',
      badge: 'STORAGE',
    },
  ],
  edges: [
    { from: 'client', to: 'gateway', label: 'HTTPS POST' },
    { from: 'gateway', to: 'auth', label: 'Verify Token' },
    { from: 'auth', to: 'db', label: 'SQL Query' },
  ],
  groups: [
    {
      id: 'backend',
      label: 'Internal VPC Cluster',
      nodeIds: ['gateway', 'auth', 'db'],
      color: 'indigo',
    },
  ],
}

export default function ArchitectureDoc() {
  return (
    <div className="w-full h-[500px] rounded-xl overflow-hidden border">
      {/* Automatically inherits dark/light mode and sets contrast */}
      <Diagram
        data={architecture}
        mode="viewer"
        autoFit={true}
        showCopyButton={true}
        copyFormat="elements" // 'elements' for 1-click Ctrl+V paste into Whiteboard, 'image' for PNG, or 'json'
        showZoomControls={true}
      />
    </div>
  )
}

2. Programmatic Compilation (diagramToSketch)

If you want to compile graph JSON into a SketchDocument to save, mutate, or export:

import { diagramToSketch } from '@filekit-studio/diagram'

const sketchDoc = diagramToSketch(architecture, {
  direction: 'LR',
  nodeSpacing: 80,
  rankSpacing: 220,
})

console.log(sketchDoc.elements) // Array of SketchBoardElement objects

3. Rendering Excalidraw JSON Files

import { Diagram } from '@filekit-studio/diagram'
import excalidrawFile from './diagram.excalidraw.json'

export function ExcalidrawViewer() {
  return (
    <div className="w-full h-[600px]">
      <Diagram data={excalidrawFile} mode="viewer" autoFit={true} />
    </div>
  )
}

<Diagram /> Props Reference

| Prop | Type | Default | Description | | :--- | :--- | :--- | :--- | | data | DiagramData \| string | required | Diagram specification object or JSON string. | | mode | 'viewer' \| 'editor' | 'viewer' | Display mode: clean doc viewer or full whiteboard studio. | | direction | 'TB' \| 'BT' \| 'LR' \| 'RL' | 'LR' | Flow direction for the DAG auto-layout engine. | | theme | 'light' \| 'dark' \| 'system' | 'system' | Color theme mode. Automatically detects active website dark mode. | | canvasBackground | string | '#f0f4f8' | Hex background color override (#121214 in dark mode). | | gridStyle | 'grid' \| 'dots' \| 'cross' \| 'none' | 'dots' | Canvas grid pattern. | | autoFit | boolean | true | Scale and center elements to fit container on mount. | | interactive | boolean | true | Allow click-and-drag panning and wheel zooming. | | showCopyButton | boolean | true | Display 1-click clipboard export button. | | copyFormat | 'elements' \| 'image' \| 'json' | 'elements' | 'elements' for Ctrl+V paste into Sketch whiteboard, 'image' for PNG, or 'json'. | | showZoomControls | boolean | true | Display minimal floating zoom percentage and +/-/Fit controls. | | layoutOptions | DiagramLayoutOptions | {} | Fine-tuning for spacing (nodeSpacing, rankSpacing), margins, and padding. | | uiConfig | SketchUIConfig | {} | Granular toggle flags for all 54 UI controls and menus (editor mode). | | controllerRef | Ref<SketchController> | undefined | Ref to imperative controller methods (zoomToFit, zoomIn, zoomOut, etc.). |


License

MIT © FileKit Studio