Skip to content

About

Jeu de piste mobile / Scavenger hunt mobile game

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Scavenger Hunt

A mobile-first web application for creating location-based scavenger hunts with interactive clues and challenges.

📖 Overview

This application lets you create and play scavenger hunts that guide players through various locations. Players solve clues, complete challenges, and collect keywords to progress through the game.

Built with: Next.js 16 (App Router + Turbopack), TypeScript, React Leaflet, and OpenStreetMap.

Why this project

  • 📱 Nothing to install — it's a mobile-only website, not a native app. Just open the URL on your phone.
  • 🕶️ No account, no sign-up — the game is public and fully anonymous.
  • 💸 Free for everyone — no paywall, no in-app purchases.
  • 🔒 No backend, no tracking — progress lives entirely in your phone's localStorage, nothing leaves the device.
  • 🛠️ Open source — fork the repo and build your own hunts, under the terms of the CC BY-NC-SA 4.0 license.

Under the hood

  • 🗺️ Free, key-less mapping via Leaflet + OpenStreetMap tiles
  • 🌍 Built-in i18n (French / English) with per-hunt language selection
  • 🧭 Onboarding tour powered by driver.js on first launch
  • 🧩 8 interactive item types (3D, scratch card, magnifier, page-flip, ...)
  • 📦 Static export — deploys anywhere (GitHub Pages, Netlify, S3/CloudFront, ...)

📸 Preview

Hunts list
1. Hunts list
Onboarding tour
2. Onboarding tour
Manuscript
3. Manuscript
Map and place details
4. Map & place details
Magnifier puzzle
5. Magnifier puzzle
Keyword found
6. Keyword found
Phrase reconstructed
7. Phrase reconstructed

🚀 Getting Started

Prerequisites

  • Node.js 18+ and npm
  • A mobile device or mobile browser emulator (the app is mobile-only)

Installation

  1. Clone the repository

    git clone <your-repo-url>
    cd scavenger-hunt
  2. Install dependencies

    npm install
  3. Run the development server

    npm run dev
  4. Open the application

    Navigate to http://localhost:3000 on your mobile device or browser.

📱 Testing on a real mobile device

To test on your phone while running the dev server on your computer:

  1. Make sure your phone and computer are on the same network
  2. Find your computer's local IP address:
    # On Linux/Mac
    ip addr show | grep inet
    # or
    ifconfig | grep inet
  3. On your phone, navigate to http://YOUR_IP_ADDRESS:3000

🎮 Creating Your Hunt

Quick Start

Edit the config.json file to create your scavenger hunt:

{
  "hunts": [
    {
      "slug": "my-first-hunt",
      "name": "My First Hunt",
      "lang": "en",
      "description": "A short description of your hunt",
      "duration": "~1h",
      "coordinates": { "lat": 48.8566, "lng": 2.3522 },
      "manuscript": "<p>Your hunt story goes here...</p>",
      "phrase": "The complete phrase players need to discover",
      "defaultKeywords": ["Some", "starting", "words"],
      "places": [
        {
          "name": "First Location",
          "description": "<p>Description of this location</p>",
          "coordinates": { "lat": 48.8584, "lng": 2.2945 },
          "item": {
            "type": "keyword",
            "options": { "keyword": "hidden" }
          }
        }
      ]
    }
  ]
}

Configuration Structure

Hunt Properties
Property Type Required Description
slug string ✅ Unique identifier for the hunt (used in URLs)
name string ✅ Display name of the hunt
lang string ✅ Hunt content language code (fr, en, ...). Determines the badge shown in the hunts list.
description string ✅ Short description shown in the hunt list
duration string ❌ Estimated duration (e.g., ~2h)
coordinates object ✅ Starting point coordinates {lat, lng}
manuscript string ✅ Hunt story/intro (supports HTML)
phrase string ✅ Complete phrase to discover
defaultKeywords array ✅ Starting keywords given to players
places array ✅ List of locations in the hunt
Place Properties
Property Type Required Description
name string ✅ Location name
description string ✅ Location description (supports HTML)
coordinates object ✅ Location coordinates {lat, lng}
coordinateMargin number ❌ Proximity margin in degrees (default: 0.001 ≈ 111m)
link string ❌ External link for more information
item object ✅ Interactive item/clue at this location

Getting Coordinates:

  • Use OpenStreetMap - right-click on the map and select "Show address"
  • Use Google Maps - right-click and select coordinates to copy
  • Format: {"lat": 48.8566, "lng": 2.3522}

Validating Your Configuration

Automatic validation happens during:

  • Build time: npm run build
  • Runtime: App won't start with invalid config

Manual validation:

npm run validate:config

This checks:

  • ✅ All required fields are present
  • ✅ Data types are correct
  • ✅ Item types are valid
  • ✅ Structure matches the schema
Example error output
❌ Error validating config.json file:

1. hunts → 0 → coordinates → lat
   Invalid input: expected number, received string

Total: 1 error(s) detected

💡 Check the structure and types in config.json

🎨 Available Item Types

Items are interactive elements that players encounter at each location. Choose from these types:

1. Keyword

A simple clickable keyword to collect.

{
  "type": "keyword",
  "options": {
    "keyword": "treasure"
  }
}
2. Image

A static image without interactions.

{
  "type": "image",
  "options": {
    "image": "/assets/my-hunt/image.png"
  }
}
3. Clickable Image

An image with clickable hotspots that trigger actions.

{
  "type": "clickable-image",
  "options": {
    "image": "/assets/my-hunt/image.png",
    "debug": false,
    "clickableAreas": [
      {
        "top": "10%",
        "left": "10%",
        "width": "20%",
        "height": "15%",
        "action": {
          "type": "keyword",
          "options": { "keyword": "hidden" }
        }
      }
    ]
  }
}

Position properties: Use top/bottom and left/right with percentage values.

Actions: Can be any other item type (keyword, magnifier, image, etc.)

4. Scratch Card

An image with scratchable areas that reveal text or keywords.

{
  "type": "scratch-card",
  "options": {
    "image": "/assets/my-hunt/scratch.png",
    "width": 340,
    "height": 380,
    "scratchableAreas": [
      {
        "top": "45%",
        "right": "15%",
        "width": "10%",
        "height": "20%",
        "text": "Secret word",
        "keyword": true
      }
    ]
  }
}

keyword: true marks the text as a collectible keyword.

5. Magnifier

An image with a magnifying glass to reveal hidden details.

{
  "type": "magnifier",
  "options": {
    "image": "/assets/my-hunt/image.jpg",
    "keyword": "hidden",
    "keywordPosition": { "x": 130, "y": 440 }
  }
}

Position: Pixel coordinates where the keyword is hidden.

6. Card Flip

A card that flips to reveal another image.

{
  "type": "card-flip",
  "options": {
    "front": "/assets/my-hunt/front.png",
    "back": "/assets/my-hunt/back.jpg"
  }
}
7. Page Flip

A book with flippable pages containing text and keywords.

{
  "type": "page-flip",
  "options": {
    "image": "/assets/my-hunt/book.png",
    "pages": [
      {
        "text": "<p>Page content here...</p>"
      },
      {
        "text": "<p>Click {keyword}this{/keyword} to collect it!</p>"
      }
    ]
  }
}

Keyword syntax: {keyword}word{/keyword} creates a clickable keyword.

8. Three Fiber (3D Box)

A rotatable 3D box with textures on each face.

{
  "type": "three-fiber",
  "options": {
    "image": "/assets/my-hunt/box.png",
    "textures": [
      "/assets/my-hunt/right.png",
      "/assets/my-hunt/left.png",
      "/assets/my-hunt/top.png",
      "/assets/my-hunt/bottom.png",
      "/assets/my-hunt/front.png",
      "/assets/my-hunt/back.png"
    ],
    "keyword": "treasure"
  }
}

Texture order: right, left, top, bottom, front, back


🌍 Internationalization (i18n)

The app interface ships in French (default) and English. Hunt content is authored independently — each hunt declares its own lang.

  • Provider: I18nProvider in src/components/Providers/Providers.tsx
  • Hook: useTranslation() returns { language, setLanguage, t }
  • Strings: declared in src/i18n/translations.ts (type-safe via the TranslationKey union)
Adding a new UI string
  1. Add the key to both fr and en objects in src/i18n/translations.ts.
  2. Use it in any component:
    import { useTranslation } from '@/i18n';
    
    const { t } = useTranslation();
    return <span>{t('myNewKey')}</span>;
Adding a hunt in another language

Add a new entry in config.json with the desired lang:

{
  "slug": "the-secret-of-old-lille",
  "name": "The Secret of Old Lille",
  "lang": "en",
  "description": "Explore Old Lille and solve the puzzles...",
  "manuscript": "<p>...</p>",
  "phrase": "...",
  "places": [ /* ... */ ]
}

The hunts list automatically displays the language badge (FR, EN, ...).


🛠️ Development

Project Structure

scavenger-hunt/
├── config.json              # Hunt configuration (validated by Zod)
├── docs/screenshots/        # README screenshots
├── public/
│   └── assets/              # Hunt images, 3D textures, icons
├── scripts/
│   └── validate-config.ts   # Standalone config validator
├── src/
│   ├── app/                 # Next.js App Router (pages, layout, [slug])
│   ├── components/          # React components
│   │   ├── Items/           # Interactive item implementations
│   │   ├── Map/             # Leaflet integration (Map, MarkerWithPopup, ...)
│   │   ├── Hunt/            # Hunt screen (manuscript + map tabs)
│   │   ├── HuntsList/       # Landing page hunts grid
│   │   ├── Manuscript/      # Phrase reconstruction view
│   │   ├── CompletionCard/  # End-game card
│   │   └── UI/              # Shared primitives (Icon, ParchmentCard, ...)
│   ├── contexts/            # React Context providers (Phrase, Toast, Moment)
│   ├── hooks/               # useGeolocation, useWakeLock, useOnboarding, ...
│   ├── i18n/                # Translations (fr/en) + I18nContext
│   ├── lib/                 # Storage, hunts, assets, config schema
│   └── types/               # Hunt, Place, Item TypeScript types
└── tests/                   # Playwright E2E tests

Adding New Item Types

To create a new item type:

  1. Create the component

    Create a new file in src/components/Items/YourItem/:

    // src/components/Items/YourItem/YourItem.tsx
    import { YourItemOptions } from '@/types/Item';
    
    interface YourItemProps {
      options: YourItemOptions;
      onKeywordFound?: (keyword: string) => void;
    }
    
    export default function YourItem({ options, onKeywordFound }: YourItemProps) {
      // Your implementation
      return <div>Your item content</div>;
    }
  2. Add TypeScript types

    Update src/types/Item.ts:

    export interface YourItemOptions {
      // Your options
    }
    
    export type ItemOptions = 
      | KeywordOptions 
      | ImageOptions
      // ... other types
      | YourItemOptions;
  3. Update the schema

    Add validation in src/lib/config-schema.ts:

    const yourItemSchema = z.object({
      type: z.literal('your-item'),
      options: z.object({
        // Define your schema
      })
    });
  4. Register in ItemFactory

    Update src/components/Items/ItemFactory.tsx:

    import YourItem from './YourItem/YourItem';
    
    // Add to the switch statement
    case 'your-item':
      return <YourItem options={options} onKeywordFound={onKeywordFound} />;
  5. Add tests

    Create tests/your-item.spec.ts with Playwright tests.

Running Tests

# Run all E2E tests
npx playwright test

# Run a specific test file
npx playwright test tests/keyword.spec.ts

# Run in UI mode
npx playwright test --ui

# Run a single project (matrix)
npx playwright test --project="Mobile Chrome"
Test devices

Tests run on:

  • Mobile Chrome (Galaxy S24)
  • Mobile Firefox (Galaxy S24)
  • Mobile Safari (iPhone 15 & iPhone SE 3rd gen)

Code Quality

# Lint code
npm run lint

# Validate configuration
npm run validate:config

🚀 Deployment

GitHub Pages (Default)

  1. Enable GitHub Pages

    • Go to your repository → Settings → Pages
    • Source: GitHub Actions
  2. Deploy

    • Go to the "Actions" tab
    • Run the workflow: "Deploy Next.js site to Pages"
    • Your site will be available at https://<username>.github.io/<repo>/
Automatic deployment on push

The workflow is configured to deploy automatically on pushes to the main branch. Check .github/workflows/nextjs.yml to customize.

Other Static Hosting (Netlify, Vercel, etc.)

The app exports as a static site. To build:

npm run build

This creates an out/ directory with static files.

Netlify
  1. Connect your repository
  2. Build command: npm run build
  3. Publish directory: out

Or use the Netlify CLI:

npm install -g netlify-cli
netlify deploy --prod --dir=out
Vercel
npm install -g vercel
vercel --prod

Or connect your repository through the Vercel dashboard.

Custom CDN/Server

After building, upload the out/ directory to your server or CDN:

# Build
npm run build

# Upload to your server
rsync -avz out/ user@server:/path/to/webroot/

# Or use your CDN's CLI
aws s3 sync out/ s3://your-bucket/ --delete

Make sure your server is configured to:

  • Serve index.html for directory requests
  • Handle 404s by serving the custom 404 page

📄 License

This application is licensed under the Creative Commons BY-NC-SA 4.0 License.


🙏 Credits

Core Technologies

Maps & Location

UI Components

Fonts (via Fontsource)

Development Tools

Author

All other credits belong to Vincent CHALAMON for the original idea, design and development of the application.

About

Jeu de piste mobile / Scavenger hunt mobile game

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages