> ## Documentation Index
> Fetch the complete documentation index at: https://momentic.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Web

> Set up Momentic for a web app and run your first test in under 5 minutes.

Get from zero to a passing web test in a few minutes. The wizard handles
sign-in, install, a sample run, and editor setup; the manual steps below cover
the same setup if you'd rather do it yourself.

## Install via the wizard

Run the onboarding wizard in your terminal. It signs you in through the browser,
then gets you to a passing test in about two minutes: install, sample test run,
and editor MCP setup, all in one flow.

```bash theme={null}
npx @momentic/wizard@latest
```

### Have a coding agent set it up

A coding agent can't complete the browser sign-in, so the agent path uses an API
key and runs the wizard non-interactively. Copy the prompt below into Cursor,
Claude, or another agent:

<Prompt description="Set up Momentic for a web project end to end via the onboarding wizard, non-interactively." actions={["copy", "cursor", "claude"]}>
  Set up Momentic for web testing in this project by running the onboarding
  wizard non-interactively.

  First, get an API key. Check whether one is already available:

  * If `MOMENTIC_API_KEY` is set in the environment, or `~/.momentic/auth.json`
    exists from a previous sign-in, reuse it and skip ahead to running the wizard.
  * Otherwise, you cannot sign in through the browser yourself. Ask me to sign up
    at [https://app.momentic.ai](https://app.momentic.ai), create an API key at
    [https://app.momentic.ai/settings/api-keys](https://app.momentic.ai/settings/api-keys), and paste it back. Wait for the
    key, then export it:

  ```bash theme={null}
  export MOMENTIC_API_KEY=<the key I give you>
  ```

  Then run the wizard non-interactively. `npx --yes` auto-confirms the one-time
  package download, and the wizard's own `-y` flag resolves every prompt from
  flags, env, and defaults (reading the API key from `MOMENTIC_API_KEY`), so the
  command never blocks on input:

  ```bash theme={null}
  npx --yes @momentic/wizard@latest -y --platform web --editor-tools skills
  ```

  This installs `momentic` as a dev dependency, scaffolds `momentic.config.yaml`
  plus a sample test under `web/`, installs Chromium, and runs the sample test end
  to end. `--editor-tools` controls coding-agent setup: pass a comma-separated
  list to register the Momentic MCP server and install skills (for example
  `cursor,skills` or `claude-code,skills`), `all` to configure every detected
  agent, or `none` to skip. Omit the flag to auto-detect installed agents.

  When it finishes, confirm the sample test passed and that `momentic.config.yaml`
  (plus the sample `web/add-to-cart.test.yaml`) was created in the project.
</Prompt>

Or, to install manually, continue with the rest of this guide.

## 1. Prerequisites

* **Node.js** 22.12.0+ or 24.0.0+
* A `package.json` in your project (run `npm init -y` if you don't have one)
* A Momentic account, [sign up](https://app.momentic.ai) to generate an API key

```bash theme={null}
node -v  # need 22.12.0+ or 24.0.0+
```

## 2. Install

```bash theme={null}
npm install --save-dev momentic
```

## 3. Authenticate

**Option A**: sign in with your browser (recommended):

```bash theme={null}
npx @momentic/wizard login
```

This opens a browser-based login flow and saves credentials to
`~/.momentic/auth.json`. Both CLIs automatically use this file when
`MOMENTIC_API_KEY` is not set.

**Option B**: use an API key:

Create an API key in the [dashboard](https://app.momentic.ai/settings/api-keys),
then export it:

```bash theme={null}
export MOMENTIC_API_KEY=your-api-key-here
```

<Info>
  Persist the key by appending the `export` line to `~/.zshrc` (macOS) or
  `~/.bashrc` (Linux). In CI, set `MOMENTIC_API_KEY` as a secret environment
  variable.
</Info>

## 4. Initialize

```bash theme={null}
npx momentic init
```

This writes `momentic.config.yaml` to your project root. `init` does not
scaffold any tests; author your first one in the editor below. (For
pre-scaffolded sample tests, use the
[onboarding wizard](#install-via-the-wizard) instead.)

## 5. Install browsers

Momentic runs your tests against a headless browser. Install Chromium:

```bash theme={null}
npx momentic install-browsers chromium
```

## 6. Write and run your first test

Open the local editor:

```bash theme={null}
npx momentic app
```

Create a test with base URL
`https://practicetestautomation.com/practice-test-login/` and author a single
natural-language step (for example,
`Log in with username "student" and password "Password123", then confirm the success page loads.`).
Save it (the editor writes the `.test.yaml` to your project), run it from the
editor to verify, then run it from the CLI by name:

```bash theme={null}
npx momentic run <your-test-name>
```

## 7. Verify

* Check the `.test.yaml` you just authored exists in your project root
* Open the [dashboard](https://app.momentic.ai) and check **Runs** for the
  result

## 8. Next steps

<CardGroup cols={3}>
  <Card title="Core concepts" icon="book" href="/core-concepts/finding-elements">
    Finding elements, writing assertions, modules, variables
  </Card>

  <Card title="CI/CD" icon="play" href="/running-tests/ci/github-actions">
    Run Momentic on every pull request
  </Card>

  <Card title="Best practices" icon="lightbulb" href="/best-practices/maintainable-tests">
    Write tests that hold up over time
  </Card>
</CardGroup>

Need a full working example? Clone
[momentic-ai/examples](https://github.com/momentic-ai/examples/tree/main/web).
