Public
Word Snake — trace hidden snake-path words on a grid
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.

🐍 Word Snake

A word-search game where hidden words are placed on a grid as snake-paths (each word winds through king-adjacent cells — horizontal, vertical, or diagonal). Some cells are left empty. Your only clues are how many words are hidden and their lengths.

Drag your finger/mouse from letter to letter to trace a path. A guess is accepted only if it matches where a word was actually placed — spelling a word that merely exists in the dictionary, or exists elsewhere on the grid, doesn't count. This is enforced server-side: the browser never sees the solution.

How it works

Rendering mermaid diagram...
  • backend/generatePuzzle.ts — picks random words from the words dictionary table and lays each one as a self-avoiding snake-path via backtracking DFS. Words never share cells; unused cells stay empty.
  • backend/store.ts — persists each generated puzzle (including the exact placed paths) in SQLite so the server can validate guesses. The client only receives letters + clues.
  • index.ts — Hono HTTP server. Routes:
    • POST /api/puzzle → new puzzle (grid + word-length clues, no solution)
    • POST /api/check{ id, path }; accepted only if path exactly matches a placed word's cells (forward or reversed)
    • GET /api/solution/:id → full solution (used by "Give up")
  • frontend/ — client-side React (via Twind/Tailwind). Grid.tsx handles the pointer/touch drag; Clues.tsx shows the length clues that fill in as you solve; App.tsx orchestrates difficulty, state, and win detection.

Difficulty

LevelGridWordsLengths
Easy6×634–6
Medium7×754–7
Hard8×875–8

Dictionary

Words come from the words table (CREATE TABLE words (word TEXT)). Add more rows to expand the vocabulary — nothing else needs to change.