# Site CLI

A Récit site (its pages, its `recit.config.ts` and its `styles.css`) is run and built by the
`recit-site` command. It reads the site of the current folder. The `recit` command of `@recit/cli`
works on stories: its reference is the [CLI](/documentation/reference/cli) page.

```bash
recit-site dev       # the site on a local server, rebuilt on every change
recit-site build     # the static site in dist/
recit-site preview   # dist/ served as a host would
recit-site check     # the links, anchors and data files of dist/
```

Every command accepts `--help`, which lists its options, and `--version`. A boolean option whose
default is on is turned off by its `--no-` form (`--no-ssr`).

## recit-site dev

Runs the site on a local server, renders the pages on request and reloads them on every change of a
page, of the config or of a story.

| Option   | Default                       | What it does                                                                      |
| -------- | ----------------------------- | --------------------------------------------------------------------------------- |
| `--port` | `port` of the config, or 3000 | The port of the local server; a busy port moves to the next free one and says so. |
| `--open` | off                           | Opens the browser on the site once the server listens.                            |
| `--ssr`  | on                            | Renders each page on the server; `--no-ssr` serves the client application alone.  |

## recit-site build

Builds the static site in `dist/` (`.vercel/output/static` on Vercel): one HTML page per page, its
assets, the search index and the sitemap.

| Option               | Default | What it does                                                                                                                                                 |
| -------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `--preview`          | off     | Serves the build once it is written, as `recit-site preview` does; `--preview 4100` picks the port (4000 otherwise).                                         |
| `--strict`           | off     | Fails the build on a recoverable problem of the config (a `folder` directory that does not exist) instead of a warning.                                      |
| `--pdf`              | off     | Then exports the site's PDFs into the build (`recit export --to pdf --site`); needs `@recit/cli` and Chromium, and does not apply to `--experimental-ssr`.   |
| `--pdf-store`        | on      | Copies the prebuilt PDF store (`recit-pdf/`) into the build; `--no-pdf-store` leaves it out. See [Prebuilt PDFs](/documentation/configuration/pdf-prebuilt). |
| `--strict-pdf`       | off     | Fails when a PDF of the prebuilt store is older than its sources, instead of a warning.                                                                      |
| `--experimental-ssr` | off     | Builds for rendering on a server instead of static pages (experimental).                                                                                     |
| `--adapter`          | `node`  | With `--experimental-ssr`, the server the build targets: `node`, `cloudflare`, `vercel` or `lambda`.                                                         |

## recit-site preview

Serves `dist/` on a local server as a host would: the `404.html` page with the status 404 for an
unknown address, the security headers and the `trailingSlash` redirect of the config.

| Option   | Default | What it does                  |
| -------- | ------- | ----------------------------- |
| `--port` | 4000    | The port of the local server. |

## recit-site check

Reads the built site and reports every broken link, missing anchor and missing data file, and the
axe violations with `--a11y`; it exits with the code 1 on a problem. The whole guide is
[Check a built site](/documentation/configuration/site-check).

| Option        | Default                             | What it does                                                                       |
| ------------- | ----------------------------------- | ---------------------------------------------------------------------------------- |
| `--out`       | `dist/`, or `.vercel/output/static` | The build folder to read.                                                          |
| `--base-path` | `basePath` of the config            | The site's `basePath`, stripped from root addresses (`/docs`).                     |
| `--links`     | on                                  | Checks that every page, asset and data file pointed to exists; `--no-links` skips. |
| `--anchors`   | on                                  | Checks that every `#fragment` names an `id` of its page; `--no-anchors` skips.     |
| `--a11y`      | off                                 | Runs axe on every page; Playwright and `axe-core` must be installed in the site.   |
| `--json`      | off                                 | Prints the report as JSON on the standard output.                                  |

## recit-site hash-password

Asks for a password and prints the hash to write in `access.password`, so that the password itself
never sits in the config. The whole guide is [Password](/documentation/configuration/password).

| Option   | Default                | What it does                                                                                                                      |
| -------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `--salt` | a salt drawn at random | Prints the older form `sha256:<hex>`, salted by this value (set `access.salt` to it); without it the salt is written in the hash. |
