All jobs

Add a 404 Page to a SolidJS App

Yes. An agent gives your SolidJS route switch a lazy-loaded fallback page for unknown URLs and checks it in a browser before opening a pull request.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent clones the repository into its own cloud sandbox and reads how routing works before adding a page. In an app like solidjs/solid-realworld, there is no router library: src/store/createRouteHandler.js is thirty lines that keep a location signal from window.location.hash.slice(2), update it on hashchange inside useTransition, and expose match(name, regex) and getParams(). src/App.js renders a <Switch> with seven <Match> entries whose when calls match with a regular expression: editor, settings, login, register, article/(.*), @username with an optional favorites segment, and the empty hash for the home page. Settings and Auth are loaded with lazy; Home lazy-loads its own view. Links come from src/components/NavLink.js, which writes href="#/route" and marks itself active by comparing getParams()?.routeName with its route prop.

The <Switch> has no fallback. A visit to #/nothing-here, or a link to a typo, renders the navbar over an empty page: no message, no way back, and getParams() keeps returning the last route that did match. That is the gap the agent fills. It writes src/pages/NotFound.js with the theme's container page markup, a heading, the path the visitor asked for read from the router's location() signal rather than from getParams(), and a NavLink back to the home route. It adds the page as lazy(() => import("./pages/NotFound")) next to Settings and Auth in App.js and passes it as <Switch fallback={<NotFound />}>, which Solid renders only when every <Match> is false, so the order of the existing routes does not change.

Two details come from reading the regular expressions. The editor route is /^editor\/?(.*)/, so anything that starts with editor still goes to the editor, which is the current behaviour and stays. The profile route /^@([^/]*)\/?(favorites)?/ matches any hash starting with @, so an unknown username is not a 404 at the router level; the agent leaves that to the profile store and notes it in the pull request rather than guessing at the API's error shape. It also makes the fallback scroll to the top the way NavLink does on click.

The build is rollup -c with babel-preset-solid and @rollup/plugin-babel, and the GitHub Pages workflow installs with Node 14 and runs npm run build, so the new file uses the same syntax the rest of src uses. The agent runs npm install and npm run build, then serves public with the serve package the project already lists, opens the sandbox's browser at #/does-not-exist and at a valid article, and takes screenshots of both: the 404 page on the first, the article on the second, with no console errors. The screenshots go into the pull request.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Add a 404 page to this SolidJS app. Read src/App.js and src/store/createRouteHandler.js first to see how routes are matched. Add a lazy-loaded NotFound page that shows the requested path and a link home, render it as the fallback of the route switch so no existing route order changes, and keep the syntax compatible with the current Rollup and Babel setup. Build the app, serve it, open an unknown hash route and a valid one in the browser, and attach screenshots of both. 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

What comes back is a pull request on its own branch adding src/pages/NotFound.js and changing src/App.js by two lines: the lazy import and the fallback prop on <Switch>. The description shows the two screenshots from the sandbox's browser, the rollup build output, and a short note on the profile route matching every @ prefix, with the suggestion to handle an unknown username inside the profile store.

The run's record keeps the install, the build and every browser step, so a reviewer can see which URL was opened and what rendered without checking the branch out. Nothing else in the app changes: the store, the agent that calls the API and the other pages are untouched.

Before merging, a reviewer looks at the wording and the markup of the new page against the theme, decides whether a wrong article slug should also land on it, and whether the GitHub Pages deployment needs anything else; because the app routes on the hash, an unknown path never reaches the server, so no 404.html is involved.

Run it on every app you hand off

Start it from a terminal with POST /o/{org}/sessions, this body and the repository in resources, and go do something else; the run continues in its sandbox and the pull request appears when it is done. A follow-up through POST /o/{org}/sessions/{id}/messages wakes the parked sandbox: ask for the article page to show the same 404 when the API returns nothing for a slug, or for a search box on the page.

For a team with several Solid front ends, one request per repository starts one sandbox each, with its own pull request and screenshots. A request_id, a UUID per repository, makes a rerun of the same script return the run it already started.

The use case this job follows, with its automation and trigger: Hand off a long task.

Why run it on Rush?

A missing route fallback is the kind of gap nobody notices on a laptop because nobody types a wrong URL on purpose. The agent reads the hand-written router, finds the case it does not cover, and adds the one Solid primitive that handles it without rewriting routing or pulling in a router package.

The sandbox has a computer and a browser, so the agent does what a reviewer would do by hand: builds the app, opens the bad URL and the good one, and keeps the screenshots. Several apps can be done at once, each in its own sandbox, and each pull request shows its own proof.

Frequently asked questions

Will it move my app to @solidjs/router?

No. The app's own hash router stays as it is and the fallback is a prop on the existing <Switch>. Moving to the router package is a separate job with its own page, and the two do not conflict: a fallback works the same way on a router's route list.

How does a 404 work on GitHub Pages if the app uses hash routing?

The part after # never reaches the server, so GitHub Pages always serves index.html and the app decides what to render. The fallback page is that decision. A 404.html on the host would only matter for paths before the hash, which this app does not use.

What does the page show?

A heading, the hash path the visitor asked for, taken from the router's location signal, and a link back to the home route built with the same NavLink component the navbar uses, so it looks like the rest of the app. The exact wording is in the pull request and easy to change.

Does it catch an article or a profile that does not exist?

Not at the router level, because article/anything and @anyone are valid routes whose data comes from the API. The agent explains this in the pull request and can handle the article case in a follow-up by checking the store's load result, once you say how the API answers for a missing slug.

More SolidJS jobs

The same job on other stacks

Keep reading