what

Getting Started

Install What, create a project, and have a working page in under two minutes.

Installation

Install the What CLI from crates.io (needs Rust 1.70+):

cargo install run-what

This gives you the run-what command globally. Confirm it worked:

run-what --version

Create a Project

Scaffold a new project with the built-in wizard:

run-what new my-app

You'll be asked to choose a template:

TemplateDescription
tutorialA guided project with a welcome page, components, and a 10-step tutorial. Recommended for first-time users.
minimumA minimal app with site/, static/, data/, and one page. Start from scratch.
Tip: Start with tutorial if this is your first project. Use run-what new my-app --template minimum when you want the smallest possible scaffold. You can also preview the same 10-step tutorial online before installing anything.

Start the Dev Server

Navigate into your project and start the development server:

cd my-app
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: