Skip to main content

Overview

The @hyperscape/client package is the web game client:
  • Vite for fast builds with HMR
  • React 19 UI framework
  • Three.js 3D rendering (WebGPU with WebGL fallback)
  • Privy authentication
  • Farcaster miniapp SDK
  • Tauri desktop app support
  • Solana wallet integration

Rendering

WebGPU with WebGL Fallback

The client uses THREE.WebGPURenderer with automatic fallback to WebGL for compatibility: WebGPU (Preferred):
  • Modern high-performance rendering
  • TSL post-processing effects
  • Cascaded shadow maps (CSM)
  • Requires Chrome 113+, Edge 113+, or Safari 17+
WebGL (Fallback):
  • Graceful degradation for older browsers and WebViews
  • Single directional shadow maps (no CSM)
  • Disabled TSL post-processing
  • Works in WKWebView (Tauri), older Safari, and browsers without WebGPU
Backend Detection:
The settings panel displays the active renderer type to users.

Package Location

Screens

Located in src/screens/:

UI System Architecture

UI System (src/ui/)

Complete UI system with components, hooks, stores, and theming:

Game Components (src/game/components/)

Domain-organized game UI components:

HUD Components (src/game/hud/)

Anchor-Based Positioning

Windows use Unity/Unreal-style anchors for responsive scaling:
  • 9 anchor points: corners, edges, center
  • Offset-based: Windows store offset from anchor, not absolute position
  • Responsive: Preserves anchor relationships on resize
  • Default anchors:
    • Chat, Skills/Prayer: bottom-left
    • Minimap: top-right
    • Inventory, Menubar: bottom-right
    • Action bar: bottom-center

Drag-and-Drop System

Powered by @dnd-kit with custom enhancements:
  • Inventory items: Drag to move, combine, or drop
  • Action bar: Drag skills, prayers, combat styles
  • Tabs: Drag to reorder or combine windows
  • Windows: Drag headers to move
  • Context menus: Right-click for OSRS-style menus

Environment Variables

Development

Production (Cloudflare Pages)

PUBLIC_PRIVY_APP_ID must match the PRIVY_APP_ID set in the server environment. Mismatched IDs will cause authentication failures.
All PUBLIC_* variables are exposed to the browser. Never put secrets in client environment variables.

Running

Development

Opens at http://localhost:3333

Production Build

Dependencies

Deployment

Cloudflare Pages (Production)

The client deploys to Cloudflare Pages with automatic GitHub integration: Configuration:
  • Build command: cd packages/client && bun install && bun run build
  • Build output: packages/client/dist
  • Root directory: / (monorepo root)
  • Node version: 22
Environment Variables (Cloudflare Pages):
Deployment Process:
  1. Push to main branch
  2. Cloudflare Pages detects changes to packages/client/**
  3. Builds client with Vite
  4. Deploys to hyperscape.pages.dev and hyperscape.club
  5. Creates preview deployments for pull requests
Preview Deployments:
  • URL pattern: https://<branch>-<hash>.hyperscape.pages.dev
  • Automatic for every PR
  • Uses production environment variables
  • CORS automatically allows *.hyperscape.pages.dev origins

Vite Configuration

Only PUBLIC_* prefixed environment variables are exposed to the client. Never put secrets in client environment variables.

Key Files