A real-time multiplayer word association game built with PartyKit, React, and TypeScript. Features clean hexagonal architecture with shared game logic between client and server.
# Install dependencies
pnpm install
# Start all development servers (web app + PartyKit server)
pnpm devThen open http://localhost:3000 in multiple browser tabs/windows to play Spectrum with real-time multiplayer!
pnpm dev- Start all apps (web + server)pnpm dev:web-next- Start only the web apppnpm dev:server-partykit- Start only the PartyKit serverpnpm build- Build all appspnpm build:web-next- Build only the web apppnpm build:server-partykit- Deploy the PartyKit server
This monorepo follows hexagonal architecture principles.
| Package | Description |
|---|---|
@repo/game-protocol |
Shared types and events. |
@repo/game-ports |
Port interfaces + adapters (BroadcastTransport). |
@repo/game-core |
Pure logic: applyEvent, createInitialState. |
@repo/web-next |
Next.js 16 web app. |
Packages export TypeScript source directly — no build step needed. Next.js compiles everything via transpilePackages.
spectrum/
├── apps/
│ └── web-next/ # Next.js app
│ └── app/page.tsx # Counter UI
├── packages/
│ ├── game-protocol/ # Types & events
│ ├── game-ports/ # Port interfaces + adapters
│ └── game-core/ # Business logic
├── package.json
├── pnpm-workspace.yaml
└── tsconfig.base.json
| Command | Description |
|---|---|
pnpm dev |
Start Next.js development server |
pnpm build |
Build the web app for production |
pnpm lint |
Run ESLint across all packages |
pnpm format |
Format code with Prettier |
The app uses BroadcastTransport (browser's BroadcastChannel API) for real cross-tab communication:
- First tab becomes the "leader" (holds state, processes events)
- Other tabs are followers (send events to leader, receive state updates)
- No server needed — works entirely in the browser
This demonstrates the transport abstraction: swap BroadcastTransport for a WebSocketTransport to connect to a real server.
- Package Manager: pnpm 9+
- Language: TypeScript 5
- Framework: Next.js 16
- Styling: Tailwind CSS 4
- Validation: Add Zod for runtime validation at API boundaries
- Testing: Vitest, Playwright
- CI/CD: GitHub Actions, Changesets
- Backend: WebSocket server, real transport
- DX: Biome, Turborepo
MIT