API Reference

Exported Constants & Types

import {
// Game IDs Enum
GAME_IDS,
// Default Settings
DEFAULT_GAME_SETTINGS,
// Games List & Mapping
GAMES_LIST,
GAMES_MAPPING,
// TypeScript Types
type GameSettings,
type GameProps,
type GameDefinition,
type GameComponent,
// All Game Components
Arrows, BalloonBlaster, BikeRacing, BlockBlast, BlockBreaker,
BubbleShooter, CandyCrush, CarRacing, ColorSwitch,
ColorsSort, ConnectEmAll, DinoJump, DotsAndBoxes,
FindDifferentNumber, FlappyBird, FruitMerger, FruitNinja,
Game2048, KnifeHit, LudoKing, MazeRunner, MineSweeper,
NumberSearch, NutsAndBolts, PacMan, PerfectCircle,
PipeConnect, PopitFidget, SlidingNumbers, Snake3D,
SnakesAndLadders, SpaceFighter, SpiderSolitaire, StackTower,
Sudoku, Tank1990, TicTacToe, TileHome, WhackAMole, WordSearch
} from '@nayan-ui/games';

GAME_IDS Enum

All available game identifiers:

GAME_IDS.ARROWS // 'arrows'
GAME_IDS.BALLOON_BLASTER // 'balloon-blaster'
GAME_IDS.BIKE_RACING // 'bike-racing'
GAME_IDS.BLOCK_BLAST // 'block-blast'
GAME_IDS.BLOCK_BREAKER // 'block-breaker'
GAME_IDS.BUBBLE_SHOOTER // 'bubble-shooter'
GAME_IDS.CANDY_CRUSH // 'candy-crush'
GAME_IDS.CAR_RACING // 'car-racing'
GAME_IDS.COLOR_SWITCH // 'color-switch'
GAME_IDS.COLORS_SORT // 'colors-sort'
GAME_IDS.CONNECT_EM_ALL // 'connect-em-all'
GAME_IDS.DINO_JUMP // 'dino-jump'
GAME_IDS.DOTS_AND_BOXES // 'dots-and-boxes'
GAME_IDS.FIND_DIFFERENT_NUMBER // 'find-different-number'
GAME_IDS.FLAPPY_BIRD // 'flappy-bird'
GAME_IDS.FRUIT_MERGER // 'fruit-merger'
GAME_IDS.FRUIT_NINJA // 'fruit-ninja'
GAME_IDS.GAME_2048 // 'game-2048'
GAME_IDS.KNIFE_HIT // 'knife-hit'
GAME_IDS.LUDO_KING // 'ludo-king'
GAME_IDS.MAZE_RUNNER // 'maze-runner'
GAME_IDS.MINE_SWEEPER // 'mine-sweeper'
GAME_IDS.NUMBER_SEARCH // 'number-search'
GAME_IDS.NUTS_AND_BOLTS // 'nuts-and-bolts'
GAME_IDS.PAC_MAN // 'pac-man'
GAME_IDS.PERFECT_CIRCLE // 'perfect-circle'
GAME_IDS.PIPE_CONNECT // 'pipe-connect'
GAME_IDS.POPIT_FIDGET // 'popit-fidget'
GAME_IDS.SLIDING_NUMBERS // 'sliding-numbers'
GAME_IDS.SNAKE_3D // 'snake-3d'
GAME_IDS.SNAKES_AND_LADDERS // 'snakes-and-ladders'
GAME_IDS.SPACE_FIGHTER // 'space-fighter'
GAME_IDS.SPIDER_SOLITAIRE // 'spider-solitaire'
GAME_IDS.STACK_TOWER // 'stack-tower'
GAME_IDS.SUDOKU // 'sudoku'
GAME_IDS.TANK_1990 // 'tank-1990'
GAME_IDS.TIC_TAC_TOE // 'tic-tac-toe'
GAME_IDS.TILE_HOME // 'tile-home'
GAME_IDS.WHACK_A_MOLE // 'whack-a-mole'
GAME_IDS.WORD_SEARCH // 'word-search'

DEFAULT_GAME_SETTINGS

Default configuration for all games:

const DEFAULT_GAME_SETTINGS = {
isVisible: false, // Settings modal visibility
enableSounds: true, // Audio feedback enabled
enableHaptics: true, // Haptic feedback enabled
enableMusic: true, // Background music enabled
offset: 0, // Top offset for notch/status bar
};
// Example: Custom settings with offset
const customSettings = {
...DEFAULT_GAME_SETTINGS,
offset: 50, // Moves game elements 50px down from top
};

GAMES_LIST

Array of all game definitions with metadata:

// GAMES_LIST is an array of GameDefinition objects
GAMES_LIST.forEach(game => {
console.log(game.id); // GAME_IDS enum value
console.log(game.title); // Display title
console.log(game.description); // Game description
console.log(game.component); // React component
});
// Example: Find a specific game
const fruitNinja = GAMES_LIST.find(g => g.id === GAME_IDS.FRUIT_NINJA);

GAMES_MAPPING

Object mapping game IDs to their components:

// Access game component by ID
const GameComponent = GAMES_MAPPING[GAME_IDS.FRUIT_NINJA];
// Render dynamically
<GameComponent settings={settings} onSettingsChange={handleChange} />

TypeScript Types

// Game settings interface
interface GameSettings {
isVisible: boolean; // Settings modal visibility
enableSounds: boolean; // Audio feedback
enableHaptics: boolean; // Haptic feedback
enableMusic: boolean; // Background music
offset?: number; // Optional padding from top (default: 0)
}
// Game completion metrics
interface GameCompletionMetrics {
status: 'win' | 'lose' | 'cancel';
score: string;
additionalData?: Record<string, any>;
}
// Game component props
interface GameProps {
settings: GameSettings;
onSettingsChange?: (settings: GameSettings) => void;
onEndGame?: (metrics: GameCompletionMetrics) => void;
onReplayGame?: () => void;
onShare?: () => void;
onShowLeaderboard?: () => void;
bannerAd?: ReactNode;
}