what

Getting Started

Install What, verify which executable you are using, and make your first edit.

Installation

Install the What CLI from crates.io (it needs Rust 1.89 or newer; rustup update brings an older toolchain up to date):

cargo install run-what --version 2.1.0 --locked

These instructions target 2.1.0. Confirm run-what 2.1.0 is printed. If you see an older version, check command -v run-what on macOS/Linux or Get-Command run-what -All in PowerShell and correct PATH:

run-what --version

Create a Project

Create a new project:

run-what new my-site

It never prompts and never overwrites files: if the folder already exists, choose another name. Every project starts from the same minimal starter: what.toml, site/index.html, site/application.what, components/layout.html, static/styles.css, static/app.js, and an empty data/ folder.

Coming from 1.x? The tutorial, example and demo templates are retired, and selecting one with --template stops with these same steps. The course starts from this minimal project.

Start the Dev Server

Navigate into your project and start the development server:

cd my-site
run-what dev

Open http://127.0.0.1:8085 in your browser. The server watches your files and automatically reloads when you make changes.

You can specify a different port if needed:

run-what dev --port 3000

Your First Page

Pages live in the site/ directory. Create a new file:

site/hello.html
<h1>Hello, world!</h1>
<p>This is my first What page.</p>

Visit http://127.0.0.1:8085/hello and you'll see it rendered with your project's layout. That's it: no imports, no configuration, no routing setup. The file path is the route.

Tip: If your project has a layout defined in application.what, every page in that directory inherits it automatically. Add layout: none in a page's <what> block to opt out.

Adding Interactivity

Let's make the page interactive with a session-backed counter. No JavaScript required.

site/hello.html
<h1>Hello, world!</h1>
<p>You've visited this page #session.visits# times.</p>

<button w-set="session.visits += 1">Count visit</button>
<button w-set="session.visits = 0">Reset</button>

Here's what's happening:

  • #session.visits# renders the current value of the session variable. It starts empty.
  • w-set="session.visits += 1" increments the value on click via a server round-trip.
  • Every element displaying #session.visits# updates automatically: no manual wiring needed.

Session variables persist across page loads for each user. They're stored server-side, so they survive browser refreshes and work across multiple tabs.

Note: Session variables start as empty strings. Using += 1 on an empty value initializes it to 1. You don't need to set a default.

Next Steps

You now have a working project with a live dev server and an interactive page. From here: