-
Install @puzzmo/sdk:
Install `@puzzmo/sdk` using the project's package manager (e.g. npm, yarn, pnpm).
-
In the main game entry file, import and initialize the SDK:
import { createPuzzmoSDK } from "@puzzmo/sdk"
const sdk = createPuzzmoSDK()
-
Replace the game's initialization flow with the SDK lifecycle:
const { puzzleString, inputString, theme, completed } = await sdk.gameReady()
const puzzle = JSON.parse(puzzleString)
initializeGame(puzzle)
if (inputString) restoreState(inputString)
if (theme) applyTheme(theme)
sdk.gameLoaded()
-
Handle the start event to trigger the game start:
sdk.on("start", () => {
startGame()
})
-
Wire up other lifecycle events if there is relevant game logic for pause/resume/retry:
sdk.on("pause", () => {
})
sdk.on("resume", () => {
})
sdk.on("retry", () => {
})
-
Wire up state saving - call sdk.updateGameState(stateString) whenever the game state changes so the host can save progress.
-
Create puzzle fixture files for local testing. Make a fixtures/puzzles/ directory and add a few different puzzle JSON files that exercise different aspects of the game:
fixtures/puzzles/
easy/
small-grid.json
basic.json
hard/
large-grid.json
tricky.json
Each JSON file should contain puzzle data in the format the game expects. Try to create at least 2-3 puzzles with different characteristics (e.g. varying difficulty, size, or edge cases) so the game can be tested against realistic variety.
If the original game already has a few puzzles hardcoded, use those as a starting point for creating the fixture files. Then delete the buttons which may have been used to load them, since the simulator will handle loading puzzles from the fixtures.
-
Set up the dev simulator for local testing. Add the Vite plugin to vite.config.ts:
import { defineConfig } from "vite"
import { puzzmoSimulator } from "@puzzmo/sdk/vite"
export default defineConfig({
plugins: [
puzzmoSimulator({
fixturesGlob: "/fixtures/puzzles/**/*.json",
}),
],
})
The plugin automatically:
- Injects the simulator UI in dev mode only (tree-shaken from production builds)
- Loads fixtures from the glob pattern, organized by folder as categories
- Handles OAuth callback routing for authenticated API features
For non-Vite setups, load the SDK and simulator from jsDelivr:
<script>
window.SIMULATOR_CONFIG = { slug: "my-game" }
</script>
<script src="https://cdn.jsdelivr.net/npm/@puzzmo/sdk/dist/simulator/standalone.js"></script>