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

@vimazing/vim-snake

v3.0.0

Published

Classic Snake reimagined with Vim controls — a lightweight, typed React hook library for building snake games with hjkl navigation.

Downloads

20

Readme

@vimazing/vim-snake

Lightweight, typed React hooks and utilities for building interactive snake games with VIM-inspired controls.

Part of the VIMazing project - GitHub.


Contents


Features

  • Drop-in hooks for snake game mechanics, scoring, and key logging.
  • Typed API with generated declaration files for editor IntelliSense.
  • VIM-style controls (h, j, k, l for direction changes).
  • Composable architecture – bring your own rendering and platform-specific bindings.
  • Tree-shakeable exports to keep bundles lean.

Installation

Using npm:

npm install @vimazing/vim-snake

Or with bun:

bun add @vimazing/vim-snake

Quick Start

import { useEffect } from "react";
import { useGame } from "@vimazing/vim-snake";
import "@vimazing/vim-snake/game.css";

export function SnakeGame() {
  const { containerRef, gameStatus, score, level } = useGame();

  return (
    <section className="mx-auto w-fit space-y-4">
      <h1 className="text-2xl font-bold">VIMazing Snake</h1>
      <div className="flex gap-4 justify-center">
        <div>Score: {score}</div>
        <div>Level: {level}</div>
      </div>
      <div ref={containerRef} className="relative" />
      {gameStatus === "game-over" && <p>Game Over! Press Space to restart</p>}
    </section>
  );
}

Note: You must manually import the CSS file. The package exports styles but does not auto-import them, giving you control over when and how styles are loaded.

Default Controls

| Key | Action | | ----------- | ------------------- | | Space | Start / Restart | | h / l | Turn left / right | | j / k | Turn down / up | | q | Quit game | | p | Pause / unpause |

Game Options

Use GameOptions to customize the game:

const game = useGame({
  cols: 40,                    // Board width (default: 30)
  rows: 25,                    // Board height (default: 20)
  startingLevel: 5,            // Initial level (default: 1)
  foodsPerLevel: 5,            // Foods to level up (default: 10)
  maxLevel: 20,                // Maximum level (default: 25)
  initialSnakeSize: 5,         // Snake segments at start (default: 3)
  initialFoodCount: 2,         // Food items at start (default: 1)
});

All options are optional with sensible defaults. Call useGame() with no arguments for default settings.


API

useGame Hook

Main hook that orchestrates all game mechanics:

const gameManager = useGame(options?, platformHook?);

Parameters:

  • options (optional): GameOptions object for customization
  • platformHook (optional): Function to handle platform-specific logic

Returns: GameManager with:

  • containerRef – DOM ref for game board rendering
  • gameStatus – Current state ('waiting' | 'started' | 'game-over' | 'game-won')
  • score – Current game score
  • level – Current level (also equals game speed in FPS)
  • scoreManager – Tracks time, keystrokes, and final score
  • cursor – Snake manager with movement and state
  • keyLog – Array of all key presses during game
  • Control methods: startGame(), quitGame(), togglePause(), etc.

gameInfo Export

Get complete game documentation for platforms:

import { gameInfo } from "@vimazing/vim-snake";

console.log(gameInfo.name);           // "VIMazing Snake"
console.log(gameInfo.controls);       // Control mappings
console.log(gameInfo.scoring);        // Scoring rules
console.log(gameInfo.configuration);  // All GameOptions

Perfect for building help screens, settings, and platform integrations.


Utilities

Besides the hooks, the library exports:

  • types – shared TypeScript types such as GameStatus, Direction, and Position.
import { GameStatus } from "@vimazing/vim-snake";

Example App

A demo application lives under example/ and consumes the package directly.

cd example
bun install
bun run dev

During local development the Vite config aliases @vimazing/vim-snake to the source folder so you can iterate without rebuilding. When publishing, run the build first (see below) so editors consume the generated declarations in dist/.


Build & Release

Build the distributable bundle and type declarations:

bun run build

This writes JavaScript, type definitions, and styles to dist/. The prepublishOnly hook reuses the same command to guarantee fresh artifacts before publishing.


License

MIT © André Padez


Acknowledgements

Classic Snake game reimagined for the VIMazing platform with Vim-style controls.