An escape room you book, pay for and then actually play in the browser — tasks, hints, QR codes and inventory, all in one Next.js + Payload CMS app.

Teams of friends looking for a night out — and the operator who has to run the room without a developer on call.
A two-person team where I wrote almost all of the code — from the booking calendar to the game engine.
Selling a time slot is the easy part. Ztracený kód arény also had to run the game itself — tasks, hints, scanned props, a ticking clock — without a second system bolted on.
One Next.js + Payload CMS app. The game is modelled as content — rooms, tasks, hints, items, QR and access codes — so a new puzzle is an edit, not a deploy. A separate full-screen route group runs the play session: lobby, tasks, hints, results.
Marketing, booking, payment and the game itself run in a single application.
The operator adds rooms and rewrites puzzles in the CMS — no developer needed.
Tasks, hints and their time penalties are just a Payload collection. The solution field is locked to authenticated staff — players never get to read it.
// Illustrative — puzzles are content, so the operator edits them.
import type { CollectionConfig } from "payload";
export const Tasks: CollectionConfig = {
slug: "tasks",
admin: { useAsTitle: "title", group: "Game" },
fields: [
{ name: "game", type: "relationship", relationTo: "games", required: true },
{ name: "title", type: "text", required: true, localized: true },
{ name: "prompt", type: "richText", localized: true },
{ name: "order", type: "number", required: true },
{
name: "solution",
type: "text",
required: true,
// Never leaves the server — the client only ever sends guesses.
access: { read: ({ req }) => Boolean(req.user) },
},
{
name: "hints",
type: "array",
fields: [
{ name: "text", type: "textarea", localized: true },
{ name: "penaltySeconds", type: "number", defaultValue: 60 },
],
},
],
};Physical props carry QR codes. The phone sends a guess, the server compares, logs the attempt and returns a boolean. That's all the client ever learns.
// Illustrative — checking a scanned code on the server.
export async function POST(req: Request) {
const { sessionId, taskId, code } = schema.parse(await req.json());
const payload = await getPayload({ config });
const task = await payload.findByID({ collection: "tasks", id: taskId });
const correct = normalise(code) === normalise(task.solution);
await payload.create({
collection: "task-attempts",
data: { session: sessionId, task: taskId, correct },
});
return Response.json({ correct }); // the answer itself never ships
}Someone always reloads the page mid-game. A discriminated union keeps the states honest, and the client store just mirrors what the server says.
// Illustrative — a session that survives a refresh.
type SessionState =
| { status: "lobby"; teamId: string }
| { status: "playing"; teamId: string; taskIndex: number; startedAt: string }
| { status: "finished"; teamId: string; durationSeconds: number };
export const useGameSession = create<{ state: SessionState | null }>(() => ({
state: null,
}));
// The server is the source of truth; the store is just a fast mirror of it.
export async function resume(sessionId: string) {
const res = await fetch(`/api/game/session/${sessionId}`);
useGameSession.setState({ state: await res.json() });
}Puzzles get reworded after every few runs. As collections, the operator retunes the room in the admin instead of waiting for a deploy.
Codes are validated server-side, so a curious team with DevTools open finds guesses, not solutions.
The marketing site wants SEO and scrolling; the game wants full screen and state. Different jobs, different layouts.
Game state is merciless. A refresh mid-session has to land the team exactly where they were — treating the session as server state from day one saved a rewrite.