Catalog npm
Back to packageRELEASE DETAILS

0.1.0

npm

404-games

A lightweight 404-page game library with JavaScript, Web Component, and React APIs.

Published16 Oct 2026
Direct dependencies8
Transitive dependenciesNot calculated

README

Current package documentation

Error 404 Game Library

A small runner game for 404 pages, available as a framework-independent JavaScript API, a Web Component, or a thin React component.

Installation

npm install 404-games

404-games is the intended package name. npm publication is pending, and the name may change before release.

The package is ESM-only and includes TypeScript declarations. The examples below assume an ESM-aware app/bundler, such as Vite. React 19 is required only for 404-games/react; the base API and Web Component do not require React.

Quick Start

Vanilla JavaScript / TypeScript

Add a container to your page:

<div id="game" style="max-width: 900px"></div>

Run this after the container exists:

import {create404Game} from '404-games';

const container = document.getElementById('game');
if (!container) throw new Error('Game container not found');

const game = create404Game({
  container,
  accentColor: '#ff0000',
});

The game starts automatically. Keep the returned controller to manage its lifecycle:

game.pause();
game.resume();
game.restart();

// When the game is no longer needed:
game.destroy();

Web Component

<error-404-game accent-color="#414141"></error-404-game>

Register explicitly in your app's browser entry:

import {
  registerError404Game,
  type Error404GameElement,
} from '404-games/web-component';

registerError404Game();

const game = document.querySelector<Error404GameElement>('error-404-game');
game?.pause();
game?.resume();
game?.restart();

Importing the entry does not register the element. Registration is safe to repeat. Connection automatically creates a game; removal destroys it; reconnection creates a fresh game. There is no Shadow DOM.

Changing accent-color while connected recreates the game and starts a fresh run. Removing the attribute restores the library default. Changes while disconnected take effect on the next connection. Empty or blank values are rejected.

The element has no destroy() method: remove it from the DOM to clean up.

React

import {useRef} from 'react';
import {Error404Game, type Error404GameHandle} from '404-games/react';

export function Game() {
  const gameRef = useRef<Error404GameHandle>(null);

  return (
    <section>
      <Error404Game
        ref={gameRef}
        accentColor="#414141"
        className="game"
        style={{maxWidth: 900}}
      />
      <button onClick={() => gameRef.current?.pause()}>Pause</button>
      <button onClick={() => gameRef.current?.resume()}>Resume</button>
      <button onClick={() => gameRef.current?.restart()}>Restart</button>
    </section>
  );
}

The component owns its container and cleans up on unmount. Changing accentColor destroys the previous game and creates a fresh one; omitting it uses the library default. React Strict Mode is supported. The ref exposes controls only, with no destroy() method.

API Reference

create404Game(options): GameController

Exported from 404-games, along with the GameOptions and GameController types. Creates and attaches a canvas to the supplied container, starts the game, and returns its controller. The caller owns the container; the library owns and removes its canvas.

type GameOptions = {
  container: HTMLElement;
  accentColor?: string;
};

type GameController = {
  pause(): void;
  resume(): void;
  restart(): void;
  destroy(): void;
};

container must be a real HTMLElement. accentColor is optional; an empty or blank value throws. Omit it to use the library default.

MethodBehavior
pause()Manually pauses the game. Switching tabs does not clear a manual pause.
resume()Resumes a manually paused game.
restart()Resets the run and resumes it.
destroy()Permanently ends the instance, cleans up owned resources, and removes its canvas.

Repeated destruction and lifecycle calls after destruction are safe no-ops.

Web Component API

404-games/web-component exports Error404GameElement and registerError404Game().

Attribute / methodBehavior
accent-colorOptional; maps directly to accentColor. A changed value recreates the connected game.
pause()Pauses the active game.
resume()Resumes the active game.
restart()Resets and resumes the active game.

Control calls safely do nothing when no game exists. DOM removal owns destruction.

React API

404-games/react exports Error404Game, Error404GameProps, and Error404GameHandle.

import type {CSSProperties} from 'react';

type Error404GameProps = {
  accentColor?: string;
  className?: string;
  style?: CSSProperties;
};

type Error404GameHandle = {
  pause(): void;
  resume(): void;
  restart(): void;
};

className and style apply to the wrapper div. Styling changes do not recreate the game. Arbitrary DOM props are not forwarded. Handle methods target the current game and safely do nothing when no active game exists.

Assets

Sprites and audio ship with the package. Your app's bundler resolves and emits them automatically, including when the app is served below the site root. Do not copy assets into a public folder or supply manual asset paths. No asset-path configuration is needed.

Browser Support

Designed for modern browsers with Canvas 2D, Pointer Events, ResizeObserver, and Web Components when using the custom element. Gameplay runs in the browser; import and register the Web Component in a browser environment.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 9

Native requirements
8 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
vite
Environment
{
  "local_name": "vite",
  "alias": false,
  "peer_metadata": null
}
^8.3.0development
jsdom
Environment
{
  "local_name": "jsdom",
  "alias": false,
  "peer_metadata": null
}
^29.1.1development
react
Environment
{
  "local_name": "react",
  "alias": false,
  "peer_metadata": null
}
^19.3.1development
vitest
Environment
{
  "local_name": "vitest",
  "alias": false,
  "peer_metadata": null
}
^5.0.3development
react-dom
Environment
{
  "local_name": "react-dom",
  "alias": false,
  "peer_metadata": null
}
^19.3.1development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
~6.0.2development
@types/react
Environment
{
  "local_name": "@types/react",
  "alias": false,
  "peer_metadata": null
}
^19.3.0development
@types/react-dom
Environment
{
  "local_name": "@types/react-dom",
  "alias": false,
  "peer_metadata": null
}
^19.3.0development
react
Environment
{
  "local_name": "react",
  "alias": false,
  "peer_metadata": {
    "optional": true
  }
}
^19.0.0peer

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "68f0ba9c6fd8121e8acfa3dad94f95765c0be997",
  "tarball": "https://registry.npmjs.org/404-games/-/404-games-0.1.0.tgz",
  "fileCount": 54,
  "integrity": "sha512-PizVG8nKVWj4dpv7IYncE2yfm2RnZ//YxenpkvhrYlW6/z/cu0SMHI/QYjuFN0GglGPJRJurXF63fkqn+qHh2g==",
  "signatures": [
    {
      "sig": "MEQCIEmjzAM2GH1SceYLl3pcXXyshfQz5p5lkC2QuiPXcBLZAiBxALBEYrb/wHKZqyMTbtLsGYGBrGzy8TqIrxpfdzQ0CA==",
      "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
    },
    {
      "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U",
      "sig": "MEQCIDi3w9C84GXWzRplFi5hTMR2LHkQYaq51F9Uqh1tzEVaAiBVDTU+MMVKeCjoogzY2GEP1BU8Y4FdueEYVBs1ijxVrA=="
    }
  ],
  "unpackedSize": 2342115
}

Repository

PENDING
lostkodama/404-games

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 19:58 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:c04896a384382b02ff63d8cc51ecfbe9c5ffa6338a58f96c7f34d77b8fddca1a

Other collected versions

0.0.0-stage16 OctView all collected versions →