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

@load-games/react

v0.2.1

Published

React <GameCanvas/> wrapper for load-games engines.

Readme

@load-games/react

React components for load-games engines. Exports <GameCanvas/> (raw) and <LoadingGame/> (bundled UX with optional Skip button).

Install

pnpm add @load-games/react @load-games/core @load-games/snake

react and react-dom >=18 are peer dependencies. React 19 also supported.

Quick start (bundled UX)

import { LoadingGame } from '@load-games/react'
import { SnakeEngine } from '@load-games/snake'

export function Loader({ done }: { done: boolean }) {
  return (
    <LoadingGame
      engine={SnakeEngine}
      width={320}
      height={320}
      ready={done}
      onDismiss={(score, reason) => console.log('exit', score, reason)}
    />
  )
}

Renders the canvas with an external "Skip" button below. Player can:

  • Play through to game-over and tap "continue" (when ready={true})
  • Tap the in-canvas "● READY" badge in the top-right (when ready={true} and mid-play)
  • Press Esc (when ready={true})
  • Click the external "Skip" button (always)
  • Hit any of these → onDismiss(score, reason) fires once

LoadingGame props (in addition to all GameCanvas props)

| Prop | Default | Effect | |---|---|---| | skipButton | true | Show the external skip button | | skipLabel | "Skip" | Button text | | skipPosition | 'bottom' | 'top', 'bottom', or 'right' | | skipButtonStyle | {} | Inline style override for the button | | wrapperStyle | {} | Inline style override for the wrapping flex div |

Raw canvas (compose your own UI)

import { GameCanvas } from '@load-games/react'
import { SnakeEngine } from '@load-games/snake'

export function Loader() {
  return (
    <GameCanvas
      engine={SnakeEngine}
      width={320}
      height={320}
      speed={5}
      theme={{ bg: '#0a0a0a', primary: '#fff', accent: '#22c55e', text: '#fff' }}
      onScore={(n) => console.log('score', n)}
      onGameOver={(n) => console.log('over', n)}
    />
  )
}

Pass the engine class (not an instance) via the engine prop. The component instantiates it on mount and calls destroy() on unmount.

Imperative control + ready/dismiss

import { useRef, useState } from 'react'
import { GameCanvas, type GameHandle } from '@load-games/react'
import { SnakeEngine } from '@load-games/snake'

function Loader({ contentReady }: { contentReady: boolean }) {
  const ref = useRef<GameHandle>(null)
  const [done, setDone] = useState(false)
  if (done) return <YourContent />
  return (
    <GameCanvas
      ref={ref}
      engine={SnakeEngine}
      ready={contentReady}                  // declarative: shows READY badge, swaps gameover prompt
      onDismiss={() => setDone(true)}
    />
  )
}

GameHandle: pause(), resume(), signalReady(), dismiss(), getScore(), getState(), isReady().

Behavior contract

  • Engine config is captured on mount. Changing width / height / speed / theme props after mount does not reinitialise the running game (would interrupt play). To apply new config, force a remount via React key.
  • Inline callback props are safe. The component captures the latest callbacks via ref — passing onScore={n => setScore(n)} does not recreate the engine each render.
  • Only engine prop change remounts. Swap from engine={SnakeEngine} to engine={FlappyEngine} and the component reinitialises.

Mobile

The canvas comes with touch-action: none, user-select: none, -webkit-tap-highlight-color: transparent, -webkit-touch-callout: none, outline: none, and max-width: 100%. Swipes never scroll the page, no iOS context menu on long-press, no blue tap-highlight flash, and the canvas shrinks on narrow viewports.

SSR (Next.js / Remix)

<GameCanvas/> is client-only ('use client'). In Next.js App Router import it directly from a client component. If you import from a server component, mark the importer with 'use client' or use a dynamic import:

import dynamic from 'next/dynamic'
const Loader = dynamic(() => import('./Loader'), { ssr: false })

License

MIT