Skip to main content

Prerequisites

Before you begin, ensure you have the following installed on your system:
  • Node.js 20.x or higher
  • npm (comes with Node.js) or your preferred package manager
  • Git for version control
  • A code editor (VS Code recommended)

Quick Start

Get BeeHex running locally in minutes:
1

Clone the Repository

Clone the BeeHex repository to your local machine:
2

Install Dependencies

Install all required npm packages:
This will install:
  • Next.js 14.2.20 (React framework)
  • Socket.IO Client 4.7.5 (real-time communication)
  • TypeScript 5.x (type safety)
  • Styled Components 6.1.13 (styling)
  • ECharts 5.6.0 (data visualization)
  • And other dependencies
3

Configure Environment

Create your environment configuration file:
Add your environment configuration:
src/env/env.ts
The IP_HOST variable points to your game server. For local development, use 127.0.0.1 or localhost.
4

Start Development Server

Launch the Next.js development server:
Your app will be available at http://localhost:3000

Environment Configuration

Environment Variables

BeeHex uses a custom environment configuration system located in src/env/env.ts:
The src/env/env.ts file is excluded from version control (.gitignore) to prevent exposing sensitive configuration. Never commit this file.

Required Configuration

Using Environment Variables

Import the configuration in your components:

Project Structure

Understanding the BeeHex codebase organization:

Available Scripts

BeeHex includes several npm scripts for development and production:

Script Details

TypeScript Configuration

BeeHex uses TypeScript with strict mode enabled for type safety:

Main Configuration (tsconfig.json)

The @/* path alias allows you to import from src/ without relative paths:

Web Worker Configuration (tsconfig.worker.json)

BeeHex uses Web Workers for game algorithm calculations:
Workers are compiled to public/workers/ for client-side execution.

Next.js Configuration

Configuration File (next.config.mjs)

React Strict Mode is disabled to prevent double-rendering issues with WebSocket connections and game state management.

Key Features

  • App Router: BeeHex uses Next.js 14’s App Router for file-based routing
  • Dynamic Routes: Game pages use dynamic routes (hex/[gameId])
  • Server Components: Leverages React Server Components for optimal performance
  • Font Optimization: Automatic optimization for Nunito and Noto Sans fonts

Development Workflow

1

Start the Dev Server

2

Make Changes

Edit files in src/app/ or src/components/Changes hot-reload automatically in your browser
3

Check Type Safety

TypeScript checks types in real-time
4

Lint Your Code

5

Test Your Changes

Open http://localhost:3000 and verify your changes

Common Issues

Port Already in Use

If port 3000 is already in use:

Module Not Found

If you see module resolution errors:

WebSocket Connection Failed

If WebSocket connections fail:
  1. Verify IP_HOST in src/env/env.ts is correct
  2. Ensure the game server is running on port 3002
  3. Check browser console for connection errors

TypeScript Errors

If you encounter TypeScript errors:

IDE Setup

Recommended extensions:
  • ES7+ React/Redux/React-Native snippets: Code snippets
  • TypeScript Vue Plugin (Volar): Enhanced TypeScript support
  • ESLint: Real-time linting
  • Prettier: Code formatting
  • Error Lens: Inline error display

VS Code Settings

Create .vscode/settings.json:

Next Steps

Architecture Overview

Learn about BeeHex’s technical architecture

Contributing

Start contributing to the project

Deployment

Deploy BeeHex to production

Game Engine

Explore the game engine implementation