Installation
Scaffold a new app or add Puzzle to a project, and get the dev server running.
One package, @magic-spells/puzzle, gives you both the client runtime (import { PuzzleView } from '@magic-spells/puzzle') and the puzzle CLI.
Scaffold a new project
The fastest way to a working app is to install the CLI globally and run puzzle init, which writes a project you can run immediately:
npm install -g @magic-spells/puzzle puzzle init my-app cd my-app npm install npm run dev
In a terminal, init asks for anything you didn't pass as a flag: the app name, the starter template, and whether to add TypeScript. In scripts and CI it never prompts: the app name is required and omitted flags use their defaults. Pick the options up front with flags:
puzzle init my-app --template default # a minimal app puzzle init my-app --template todos # the todos example, Tailwind wired up puzzle init my-app --typescript # TypeScript components, .ts modules, strict config + check script
The generated app depends on @magic-spells/puzzle locally, so collaborators who clone it only need npm install, not the global CLI.
Add Puzzle to a project
Install it as a dev dependency:
npm install -D @magic-spells/puzzle
The CLI is a prebuilt Go binary delivered through per-platform optional dependencies, with no compiler toolchain and no postinstall step. Prebuilt binaries ship for macOS (arm64, x64), Linux (x64, arm64), and Windows (x64), and npm downloads only the one matching your machine. Windows on ARM runs the x64 binary under emulation. Once installed, puzzle is available to your npm scripts:
// package.json
{
"scripts": {
"dev": "puzzle dev",
"build": "puzzle build"
}
}If a build complains that the runtime is missing (a fresh checkout run with a global CLI, for example), it prints the install command for your lockfile.
Editor setup for the @/ alias
Puzzle resolves any import starting @/ to your app/ directory; see Components. The build handles this on its own, but your editor needs a matching path mapping to follow those imports.
puzzle init writes it for you: into tsconfig.json with --typescript, or an editor-only jsconfig.json for a plain-JS app. It writes exactly one of the two, since editors ignore a jsconfig.json sitting next to a tsconfig.json.
Adding the alias to an existing app is three lines by hand, and the build never reads either file:
// jsconfig.json
{
"compilerOptions": {
"paths": { "@/*": ["./app/*"] }
}
}Other platforms and building from source
The prebuilt binaries cover macOS, Linux, and Windows. On any other platform, or if you'd rather build the CLI yourself, install it from source with Go:
git clone --branch v0.9.0 --depth 1 https://github.com/magic-spells/puzzle.git cd puzzle/packages/puzzle go install ./compiler/cmd/puzzle
Styling with Tailwind
Puzzle's supported style pipeline is Tailwind (v4). Declare it in puzzle.config.js and the CLI runs Tailwind for you on every dev and build, folding its output into the served or built styles.css:
// puzzle.config.js
export default {
styles: {
use: ['tailwindcss'],
},
};Or let the CLI wire it up for you:
puzzle add tailwind
You can also skip Tailwind entirely and write plain CSS in each component's <style> block; see Components.
Verify your setup
If something isn't behaving, run the built-in diagnostics:
puzzle doctor
Next: build your first page in the Quick Start.