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

word-search-puzzle-generator

v1.0.1

Published

A React component library for generating and playing word search puzzles.

Readme

Word Search Puzzle Generator

A React component library for generating and playing interactive word search puzzles. Perfect for educational applications, games, and puzzle websites.

Used here: Word Search Games

Word Search Demo TypeScript React

Features

🎯 Complete Puzzle Generation

  • Smart word placement algorithm
  • Configurable grid sizes (5x5 to 25x25)
  • Multiple direction support (horizontal, vertical, diagonal)
  • Reverse word placement
  • Random letter filling

🎮 Interactive Game Components

  • Pre-built React components ready to use
  • Mouse and touch support
  • Visual feedback for selections and found words
  • Customizable styling with CSS classes

⚙️ Highly Configurable

  • Full TypeScript support
  • Flexible API
  • Custom styling options
  • Zero dependencies (peer React only)

Screenshots

Interactive Game Grid

Play the word search by clicking and dragging to find words:

Puzzle Grid

Installation

npm install word-search-puzzle-generator

Quick Start

import React, { useState } from 'react';
import { 
  PuzzleCreator, 
  WordSearchGrid, 
  generateGrid, 
  GridConfig, 
  PlacedWord 
} from 'word-search-puzzle-generator';

function App() {
  const [config, setConfig] = useState<GridConfig>({
    rows: 10,
    cols: 10,
    allowReverse: true,
    allowDiagonal: true,
    allowOverlap: false,
    fillBlanks: true
  });

  const [grid, setGrid] = useState<string[][]>([]);
  const [placedWords, setPlacedWords] = useState<PlacedWord[]>([]);

  const handleGenerate = (words: string[]) => {
    const result = generateGrid(words, config);
    setGrid(result.grid);
    setPlacedWords(result.placedWords);
  };

  const handleWordFound = (word: string) => {
    setPlacedWords(prev => 
      prev.map(pw => pw.word === word ? { ...pw, found: true } : pw)
    );
  };

  return (
    <div>
      <PuzzleCreator
        config={config}
        onConfigChange={setConfig}
        onGenerate={handleGenerate}
        initialWords={['REACT', 'TYPESCRIPT', 'PUZZLE']}
      />
      
      <WordSearchGrid
        grid={grid}
        placedWords={placedWords}
        onWordFound={handleWordFound}
      />
    </div>
  );
}

API Reference

generateGrid(words, config)

Generates a word search puzzle grid.

Parameters:

  • words: string[] - Array of words to place in the grid
  • config: GridConfig - Configuration options

Returns:

{
  grid: string[][];        // 2D array of letters
  placedWords: PlacedWord[] // Array of successfully placed words
}

Example:

const result = generateGrid(['HELLO', 'WORLD'], {
  rows: 10,
  cols: 10,
  allowReverse: true,
  allowDiagonal: true,
  allowOverlap: false,
  fillBlanks: true
});

<PuzzleCreator />

A form component for configuring and generating puzzles.

Props:

interface PuzzleCreatorProps {
  config: GridConfig;
  onConfigChange: (config: GridConfig) => void;
  onGenerate: (words: string[]) => void;
  initialWords?: string[];
  classNames?: {
    container?: string;
    section?: string;
    label?: string;
    input?: string;
    checkbox?: string;
    button?: string;
    error?: string;
  };
}

Example:

<PuzzleCreator
  config={config}
  onConfigChange={setConfig}
  onGenerate={handleGenerate}
  initialWords={['WORD', 'LIST']}
  classNames={{
    container: 'my-creator',
    button: 'my-button'
  }}
/>

<WordSearchGrid />

An interactive grid component for playing the word search game.

Props:

interface WordSearchGridProps {
  grid: string[][];
  placedWords: PlacedWord[];
  onWordFound: (word: string) => void;
  classNames?: {
    container?: string;
    grid?: string;
    row?: string;
    cell?: string;
    cellSelected?: string;
    cellFound?: string;
  };
}

Example:

<WordSearchGrid
  grid={grid}
  placedWords={placedWords}
  onWordFound={(word) => console.log(`Found: ${word}`)}
  classNames={{
    cell: 'my-cell',
    cellFound: 'my-cell-found'
  }}
/>

Type Definitions

GridConfig

interface GridConfig {
  rows: number;           // Number of rows (5-25)
  cols: number;           // Number of columns (5-25)
  allowReverse: boolean;  // Allow words to be placed backwards
  allowDiagonal: boolean; // Allow diagonal word placement
  allowOverlap: boolean;  // Allow words to share letters
  fillBlanks: boolean;    // Fill empty cells with random letters
}

PlacedWord

interface PlacedWord {
  word: string;           // The word that was placed
  path: Coordinate[];     // Array of grid coordinates
  found: boolean;         // Whether the word has been found
  color?: string;         // Optional color for the word
}

Coordinate

interface Coordinate {
  row: number;
  col: number;
}

Styling

The components use CSS classes that you can customize. Here's a basic example:

/* Grid cells */
.grid-cell {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  border: 1px solid #ddd;
  cursor: pointer;
}

/* Selected cells */
.grid-cell-selected {
  background-color: rgba(100, 108, 255, 0.5);
}

/* Found words */
.grid-cell-found {
  background-color: rgba(76, 175, 80, 0.5);
}

Example Application

Check out the /example directory for a complete working application with:

  • Full game implementation
  • Beautiful dark theme
  • Mobile-friendly design
  • Custom styling examples

To run the example:

cd example
npm install
npm run dev

Advanced Usage

Custom Word Validation

const handleWordFound = (word: string) => {
  // Custom logic before marking as found
  if (isValidWord(word)) {
    setPlacedWords(prev => 
      prev.map(pw => pw.word === word ? { ...pw, found: true } : pw)
    );
    
    // Award points, play sound, etc.
    awardPoints(word.length * 10);
  }
};

Generating Without UI

import { generateGrid } from 'word-search-puzzle-generator';

// Generate puzzle programmatically
const words = ['ALGORITHM', 'BINARY', 'CODE', 'DEBUG'];
const { grid, placedWords } = generateGrid(words, {
  rows: 15,
  cols: 15,
  allowReverse: true,
  allowDiagonal: true,
  allowOverlap: false,
  fillBlanks: true
});

// Use the grid however you need
console.log(grid);
console.log(placedWords);

Browser Support

  • Chrome/Edge (latest)
  • Firefox (latest)
  • Safari (latest)
  • Mobile browsers with touch support

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT