A golf-based hex board game prototype built as a web application. Players navigate a hexagonal grid course, aiming to sink their piece into the "hole" in as few moves as possible.
- React 18 + TypeScript — UI and type safety
- Vite — Fast build tooling and dev server
- React Router v6 — Client-side routing
- Redux Toolkit + RTK Query — State management and future multiplayer API
- Zustand — Lightweight local canvas state
- Material UI (MUI) — Component library and theming
- Vitest + React Testing Library — Unit and integration testing
- Node.js 20+
- npm 9+
npm installnpm run devnpm testnpm run test:coveragenpm run buildThe src/components/tiles exports are reusable React-Konva pieces for a
Layer. Each takes an axial origin and an optional clockwise rotation in
degrees. Use multiples of 60° when the rotated hexes must align with the board
grid; other angles are visual rotations and do not align to that grid.
FairwayPieceoffersstraight(6×20),short(6×10),long(6×12),dogleg-left,dogleg-right, andsplitshapes. Pieces can be placed together, with hazards drawn afterward to overlay them.GreenPieceoffersround(default),square,oval,long,bean, andflower. Each includes a pin at the origin and a one-hex fairway fringe.BunkerPieceandWaterPieceacceptrectangle,flower, orbeanshapes. Rectangle and bean sizes use positive integerwidthandheightin hexes; flower is a fixed seven-hex shape. Omitting these props preserves their original small shapes. Specifying a shape or size defaults to 2×2 for bunkers and 6×2 for water. Invalid dimensions use those defaults.TeePieceis a rectangular tee. The existing fairway and tree pieces remain available individually.
For example:
<Layer>
<FairwayPiece origin={{ q: 15, r: 12 }} shape="straight" />
<GreenPiece origin={{ q: 27, r: 12 }} shape="oval" />
<WaterPiece origin={{ q: 20, r: 12 }} width={8} height={2} />
<BunkerPiece origin={{ q: 28, r: 15 }} shape="flower" />
</Layer>The board loads src/data/hole1.json by default. A hole blueprint has an
id, par, numeric default_wind, and a tiles array. Each tile has a
type, an axial { "q", "r" } origin, and a clockwise rotation in degrees.
The supported types are defined in src/types/hole.ts; the corresponding
pieces use their default shapes, except fairway-short, which uses the short
fairway shape. Tiles are drawn in array order, so later
pieces overlay earlier ones. Use multiples of 60° to keep hexes aligned.
The ball starts at the first tee's origin whenever a hole is loaded.
These are rendering components; placing them does not yet update gameplay
terrain. The blueprint's par and default_wind are data only for now.
The app uses two separate stores that manage different concerns:
Manages game-level state that needs to persist across sessions and is shared across multiple UI components:
| What | Where | Why Redux |
|---|---|---|
| Active game (golfer, clubs, holes, score) | store/game/slice.ts |
Persisted to localStorage via a listener middleware; consumed by the app shell, scorecard, and routing guards |
| Future multiplayer API calls | store/apiSlice.ts |
RTK Query is ready to wire up a backend once needed |
Redux is the right choice here because the game session is serialised state — it survives page reloads, is read by many components at once, and will eventually travel over the wire to a server.
Manages transient canvas state that only the board rendering layer needs to know about:
| What | Where | Why Zustand |
|---|---|---|
Ball hex coordinates (q, r) |
hexStore.ts |
Updated on every move; only consumed by HexBoard; never needs to persist or be serialised |
Zustand is the right choice here because ball position is high-frequency, render-local state — it changes on every shot and only drives a single canvas component. Using the heavier Redux machinery for this would add unnecessary boilerplate and dispatch overhead.
Rule of thumb: if the state needs to be saved, shared across routes, or sent to a server → Redux. If it only drives the canvas and can be discarded on refresh → Zustand.
src/
├── main.tsx # App entry point (Redux + Router providers)
├── App.tsx # Route definitions
├── App.test.tsx # App smoke test
├── store/
│ ├── index.ts # Redux store configuration
│ ├── apiSlice.ts # RTK Query API slice (multiplayer-ready)
│ ├── hexStore.ts # Zustand store — transient ball position (q, r)
│ └── game/
│ ├── slice.ts # Redux game reducer (startGame / clearGame)
│ ├── listeners.ts # localStorage persistence middleware
│ └── index.ts # Barrel export
├── pages/
│ ├── HomePage.tsx # Landing / game board page
│ └── NotFoundPage.tsx # 404 page
└── components/
├── Layout.tsx # App shell with navigation
└── HexBoard.tsx # react-konva hex grid canvas (80×60)
Hex Hole Heroes is a trademark of the game creator. The game design, rules, and name are proprietary.
The source code is licensed under CC BY-NC 4.0. You may share and adapt the code for non-commercial purposes with attribution.