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

@vimee/react

v0.3.0

Published

React hooks for the vimee headless vim engine

Downloads

146

Readme

@vimee/react

React hooks for the vimee headless vim engine

npm License: MIT

A thin React binding for @vimee/core. Provides the useVim hook that turns the headless engine into reactive state.

Install

npm install @vimee/core @vimee/react

Requires react >= 18.0.0 as a peer dependency.

Quick Start

import { useVim } from "@vimee/react";

function VimEditor() {
  const { content, cursor, mode, handleKeyDown } = useVim({
    content: "Hello, vim!",
  });

  return (
    <div tabIndex={0} onKeyDown={handleKeyDown} style={{ outline: "none" }}>
      <div>-- {mode.toUpperCase()} --</div>
      <pre>{content}</pre>
      <div>
        {cursor.line + 1}:{cursor.col + 1}
      </div>
    </div>
  );
}

useVim(options)

Options (UseVimOptions)

| Property | Type | Default | Description | |----------|------|---------|-------------| | content | string | required | Initial editor content | | cursorPosition | string | "1:1" | Initial cursor in "line:col" format (1-based) | | readOnly | boolean | false | Prevent all mutations | | onChange | (content: string) => void | — | Called when content changes | | onYank | (text: string) => void | — | Called when text is yanked | | onSave | (content: string) => void | — | Called when :w is executed | | onModeChange | (mode: VimMode) => void | — | Called when mode changes | | onAction | (action: VimAction, key: string) => void | — | Called for every engine action | | indentStyle | "space" \| "tab" | "space" | Indent character | | indentWidth | number | 2 | Spaces per indent level |

Return Value (UseVimReturn)

| Property | Type | Description | |----------|------|-------------| | content | string | Current editor content | | cursor | CursorPosition | Current cursor position (0-based) | | mode | VimMode | Current vim mode | | statusMessage | string | Status bar text (e.g. "--INSERT--") | | visualAnchor | CursorPosition \| null | Visual selection anchor | | commandLine | string | Command-line display (e.g. ":wq", "/search") | | options | Record<string, boolean> | Options set via :set commands | | lastSearch | string | Last search pattern (for highlighting) | | handleKeyDown | (e: React.KeyboardEvent) => void | Attach to onKeyDown | | handleScroll | (direction, visibleLines, amount?) => void | Page scroll handler | | updateViewport | (topLine, height) => void | Viewport info for H/M/L motions |

Examples

Read-only viewer

const { content, cursor, mode, handleKeyDown } = useVim({
  content: sourceCode,
  readOnly: true,
});

With callbacks

const vim = useVim({
  content: initialCode,
  onChange: (c) => saveToLocalStorage(c),
  onSave: (c) => uploadToServer(c),
  onModeChange: (m) => analytics.track("mode", m),
  onYank: (text) => navigator.clipboard.writeText(text),
});

Rendering cursor position

function Editor() {
  const { content, cursor, mode, handleKeyDown } = useVim({
    content: "line 1\nline 2\nline 3",
  });

  const lines = content.split("\n");

  return (
    <div tabIndex={0} onKeyDown={handleKeyDown}>
      {lines.map((line, i) => (
        <div key={i}>
          {i === cursor.line ? (
            <>
              {line.slice(0, cursor.col)}
              <span className="cursor">{line[cursor.col] ?? " "}</span>
              {line.slice(cursor.col + 1)}
            </>
          ) : (
            line || " "
          )}
        </div>
      ))}
    </div>
  );
}

Scroll integration

function ScrollableEditor() {
  const { content, cursor, handleKeyDown, handleScroll, updateViewport } =
    useVim({ content: largeFile });

  const containerRef = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = containerRef.current;
    if (!el) return;
    const lineHeight = 20;
    const topLine = Math.floor(el.scrollTop / lineHeight);
    const height = Math.floor(el.clientHeight / lineHeight);
    updateViewport(topLine, height);
  });

  return (
    <div
      ref={containerRef}
      tabIndex={0}
      onKeyDown={handleKeyDown}
      style={{ height: 400, overflow: "auto" }}
    >
      <pre>{content}</pre>
    </div>
  );
}

Re-exported Types

For convenience, the following types are re-exported from @vimee/core:

  • CursorPosition
  • VimMode
  • VimAction
  • VimContext
import type { CursorPosition, VimMode } from "@vimee/react";

License

MIT