# Add Lighthouse CI to a SolidJS App

Yes. An agent adds a Lighthouse CI config and a workflow job to your SolidJS app that audit the built bundle on every PR with floors it measured, and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/add-lighthouse-ci/solidjs/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads how the app is built and served before it audits it. In an app laid out like solidjs/solid-realworld, `package.json` builds with `rollup -c --environment production` and serves locally with `serve public -l 5000 -s`; `rollup.config.js` takes `src/index.js`, writes ES modules into `public`, deletes everything in `public` except `index.html` first through `rollup-plugin-delete`, and runs `terser` only when `production` is set. `public/index.html` loads the Conduit stylesheet from `demo.productionready.io`, Ionicons and four Google Fonts families from CDNs, preconnects to `api.realworld.io`, and loads `./index.js` as a module. Routing is hash-based: `src/store/createRouteHandler.js` reads `window.location.hash.slice(2)`, and `src/App.js` matches `login`, `register`, `editor`, `settings`, `article/:slug`, `@user` and the home page, with `Settings` and `Auth` loaded lazily. `.github/workflows/gh-pages.yml` runs on push to `main` and on pull requests, installs with `npm install` on Node 14 through `actions/setup-node@v2`, runs `npm run build` and publishes `./public` with `peaceiris/actions-gh-pages@v3` on `main` only. The `test` script is the placeholder `test`.

The agent adds `lighthouserc.js` at the root, a CommonJS file since `package.json` sets no `type`. Under `ci.collect` it sets `staticDistDir: './public'`, which makes Lighthouse CI serve the build itself, `url` entries for `/`, `/#/login` and `/#/register`, which render from the bundle, and `numberOfRuns: 3`, because the home page fetches its article list from `api.realworld.io` at load and a single run would swing with that API. `ci.upload` uses `temporary-public-storage`, so each run prints a report link in the job log with no account to create. The agent does not use the `lighthouse:recommended` preset: with a stylesheet, icons and fonts loaded from third-party hosts, the page fails several of its audits today, and a job that is red on its first run is one people disable.

Instead `ci.assert.assertions` names categories. The agent runs `npx @lhci/cli autorun` in its sandbox against its own build three times, reads the median scores for `performance`, `accessibility`, `best-practices` and `seo`, and writes `categories:accessibility`, `categories:best-practices` and `categories:seo` as `error` with a `minScore` just under what it measured, and `categories:performance` as `warn`, since that score depends on the remote API and the CDN assets. The measured numbers go in the pull request so a reviewer can tighten them. A short `.lighthouseci` entry goes in `.gitignore`, because the CLI writes its reports there.

The workflow gains a `lighthouse` job in `gh-pages.yml` beside `deploy`, triggered by the same `pull_request` and `push` events: `actions/checkout`, `actions/setup-node` on Node 20 because `@lhci/cli` needs a current runtime where the existing job pins 14, `npm ci` from the committed `package-lock.json`, `npm run build`, and `npx @lhci/cli@0.14 autorun`. `LHCI_GITHUB_APP_TOKEN` is passed from secrets when present so results post as a status check, and the job still passes without it, printing the report links. The deploy job is untouched. The agent runs the new job's commands end to end in its sandbox and keeps the output.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add Lighthouse CI to this SolidJS app. Read package.json, package-lock.json, rollup.config.js, public/index.html, src/index.js, src/App.js, src/store/createRouteHandler.js and .github/workflows/gh-pages.yml first. Write lighthouserc.js with staticDistDir ./public, the urls /, /#/login and /#/register, three runs, temporary-public-storage upload, and category assertions rather than a preset. Build the app, run npx @lhci/cli autorun in the sandbox, and set minScore for accessibility, best-practices and seo as errors just under the median you measured, with performance as a warning; put the measured scores in the pull request. Add a lighthouse job to gh-pages.yml on Node 20 with npm ci, npm run build and npx @lhci/cli autorun, passing LHCI_GITHUB_APP_TOKEN from secrets when present, without changing the deploy job. Add .lighthouseci to .gitignore. Quote the autorun output. Open a pull request.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

The pull request adds `lighthouserc.js`, changes `.github/workflows/gh-pages.yml` (the new job) and `.gitignore`, and adds a section to `readme.md` on reading the report link. Its description quotes the `autorun` output from the agent's run, lists the median category scores it measured and the `minScore` it set from each, and names the third-party assets that hold the performance score down.

A reviewer opens the report link from the job log, checks the three audited routes are the ones they care about, and decides whether `performance` should move from `warn` to `error` once the CDN stylesheet is self-hosted. They also check that the job runs on pull requests from the same repository and that the deploy job still publishes only from `main`.

Nothing in `src` changes. The audit measures the app as it is; the pull request only adds the measurement and the floor, and says which audits a later change could lift.

## Run it on every new front-end repository

A team that wants every front end audited starts this from its own server: a handler lists its repositories and, for each one with a build script and no `lighthouserc` file, sends this body to `POST /o/{org}/sessions` with that repository in `resources`. A `request_id` that is a UUID v5 of the repository's full name keeps a retried call from starting a second run, since the same `request_id` and body return the run already started.

A Rush automation with a `github` trigger on `pull_request.opened` can comment with a read of the Lighthouse report once the job is in place; its runs are read-only, so they comment and do not push. Adding the job itself is the run above.

## Why run it on Rush?

A threshold nobody measured is either ignored or red. The agent builds the app in its own sandbox, runs Lighthouse CI three times against that build, and sets the floor from the numbers it saw, keeping the full output with the pull request, so the reviewer can see the scores behind each `minScore` rather than trust a round figure.

A team with several front ends on Solid, React or Vue starts the same request across all of them at once. Each run reads its own build output and routes, so a hash-routed app gets hash URLs and a static site gets its pages, and each pull request names the assets that hold its scores down.

## Frequently asked questions

### Why staticDistDir instead of a running server?

The app is static files in `public` after `npm run build`, and Lighthouse CI serves a `staticDistDir` itself, so the job needs no `serve` process and no port. The `serve` dependency in `package.json` stays for local development.

### Why audit hash URLs?

Because `createRouteHandler` routes on `window.location.hash`, `/login` as a path would show the home page. `/#/login` and `/#/register` are the addresses a user sees, and both render from the bundle without the remote API.

### Why is performance only a warning?

The home page fetches articles from `api.realworld.io` on load and the page loads its stylesheet, icons and fonts from third-party hosts, so the score varies run to run and no change in `src` lifts it. The pull request records the measured median and suggests self-hosting the stylesheet as the first step toward making it an error.

### Does it change the deploy job or the Node version it uses?

No. The new job sets up its own Node 20 for `@lhci/cli`; the `deploy` job keeps Node 14 and its `npm install`, so publishing to GitHub Pages behaves as before. Moving the deploy job to `npm ci` and a current Node is suggested in the description as a separate change.

### Do I need the Lighthouse GitHub App?

No. With `temporary-public-storage` the report link is in the job log. Installing the app and adding `LHCI_GITHUB_APP_TOKEN` as a secret turns the same results into a status check on the pull request, which the job already passes through when the secret exists.

## More SolidJS jobs

- [Add a 404 Page to a SolidJS App](https://getrush.ai/run/add-not-found-page/solidjs/)
- [Set a Document Title per Page in a SolidJS App](https://getrush.ai/run/add-page-titles/solidjs/)
- [Add PWA Support to a SolidJS App](https://getrush.ai/run/add-pwa-support/solidjs/)

## The same job on other stacks

- [Add Lighthouse CI to a Vite React App](https://getrush.ai/run/add-lighthouse-ci/vite-react/)
- [Add Lighthouse CI to a VitePress Docs Site](https://getrush.ai/run/add-lighthouse-ci/vitepress/)
- [Add Lighthouse CI to a Vue App](https://getrush.ai/run/add-lighthouse-ci/vue/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
