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

@vkcha/svg-core-react

v1.1.0

Published

React components for @vkcha/svg-core (PanZoomCanvasView, SvgCoreView)

Readme

@vkcha/svg-core-react

React components for @vkcha/svg-core.

Live demo & docs: vkcha.com/#docs

Install

npm i @vkcha/svg-core @vkcha/svg-core-react react react-dom

Components

PanZoomCanvasView (pan/zoom only)

Lightweight pan/zoom canvas for custom SVG content.

import { useRef } from "react";
import { PanZoomCanvasView } from "@vkcha/svg-core-react";
import type { PanZoomCanvasViewHandle } from "@vkcha/svg-core-react";

export function CanvasOnly() {
  const viewRef = useRef<PanZoomCanvasViewHandle>(null);

  return (
    <PanZoomCanvasView
      ref={viewRef}
      options={{ wheelMode: "pan", minZoom: 0.5, maxZoom: 4 }}
      onReady={(canvas) => console.log("Canvas ready:", canvas)}
      style={{ width: "100%", height: "100%" }}
    >
      {/* Children render inside the pan/zoom world */}
      <rect x={0} y={0} width={100} height={50} fill="#3b82f6" />
    </PanZoomCanvasView>
  );
}

Props

| Prop | Type | Description | | ------------- | --------------------------------- | -------------------------------------------------------- | | options | Partial<PanZoomOptions> | Pan/zoom configuration | | onReady | (canvas: PanZoomCanvas) => void | Called after canvas is constructed | | onDestroy | (canvas: PanZoomCanvas) => void | Called before cleanup on unmount | | autoDestroy | boolean | If true (default), calls canvas.destroy() on unmount | | children | ReactNode | Rendered into the pan/zoom world layer | | ...svgProps | SVGProps<SVGSVGElement> | Passed to the root <svg> |

Ref Handle (PanZoomCanvasViewHandle)

viewRef.current?.getSvg(); // SVGSVGElement
viewRef.current?.getCanvas(); // PanZoomCanvas instance
viewRef.current?.getWorld(); // SVGGElement (world layer)
viewRef.current?.getChildrenLayer(); // SVGGElement (React children layer)

SvgCoreView (nodes + culling + hit-testing)

Full scene management with nodes as React props.

import { useMemo, useRef } from "react";
import { SvgCoreView } from "@vkcha/svg-core-react";
import type { SvgCoreViewHandle, NodeOptions } from "@vkcha/svg-core-react";

export function Scene() {
  const coreRef = useRef<SvgCoreViewHandle>(null);

  // Memoize nodes to prevent unnecessary re-renders
  const nodes = useMemo<NodeOptions[]>(
    () => [
      {
        id: "node-1",
        x: 0,
        y: 0,
        fragment: `<rect width="120" height="60" rx="8" fill="#10b981" />`,
      },
    ],
    [],
  );

  return (
    <SvgCoreView
      ref={coreRef}
      nodes={nodes}
      init={{
        panZoom: { wheelMode: "pan" },
        culling: { enabled: true, overscanPx: 50 },
      }}
      onReady={(core) => console.log("SvgCore ready:", core)}
      style={{ width: "100%", height: "100%" }}
    />
  );
}

Props

| Prop | Type | Description | | ------------- | ------------------------- | ------------------------------------------------------ | | init | InitOptions | SvgCore init options (panZoom + culling) | | nodes | (Node \| NodeOptions)[] | Nodes to render; undefined = unchanged, [] = clear | | onReady | (core: SvgCore) => void | Called after SvgCore is constructed | | onDestroy | (core: SvgCore) => void | Called before cleanup on unmount | | children | ReactNode | Rendered into the pan/zoom world layer | | ...svgProps | SVGProps<SVGSVGElement> | Passed to the root <svg> |

Ref Handle (SvgCoreViewHandle)

coreRef.current?.getSvg(); // SVGSVGElement
coreRef.current?.getCanvas(); // PanZoomCanvas instance
coreRef.current?.getCore(); // SvgCore instance

Children Rendering

React children are rendered inside the pan/zoom world layer. Special SVG elements (<defs>, <style>, <title>, <desc>, <metadata>) are automatically hoisted to the SVG root.

<PanZoomCanvasView options={{ wheelMode: "pan" }}>
  {/* These pan/zoom with the canvas */}
  <rect x={0} y={0} width={100} height={50} fill="#3b82f6" />
  <circle cx={150} cy={25} r={20} fill="#10b981" />

  {/* Hoisted to SVG root */}
  <defs>
    <linearGradient id="grad1">...</linearGradient>
  </defs>
</PanZoomCanvasView>

Re-exported Types

Common types are re-exported for convenience:

import type {
  PanZoomState,
  PanZoomOptions,
  PanZoomWheelMode,
  WorldGroupConfig,
  InitOptions,
  CullingOptions,
  CullingStats,
  NodeOptions,
  NodeId,
  WorldLayerPosition,
} from "@vkcha/svg-core-react";

See Also