StoicBuilder

HandbookII the ForumRouting

IIthe Forum, The shape of an app

Routing

1 min readUpdated 28 November

In plain words

Routing is the set of rules that maps each web address, like /notes or /notes/42, to the page or server code that should answer it.

Where you see it

In Next.js the folders are the routes: app/notes/[id]/page.tsx answers /notes/42 and receives 42 as the id. In a Lovable or Vite app, the routes usually sit together in one file, App.tsx, using React Router.

src/App.tsxbrowser
<Routes> <Route path="/" element={<Home />} /> <Route path="/notes" element={<NoteList />} /> <Route path="/notes/:id" element={<NoteEditor />} /> <Route path="*" element={<NotFound />} /></Routes>
Each line pairs an address with a screen. :id is a blank the address fills in, and * catches everything else.

What goes wrong

  1. A page that 404s when you refresh it

    Single-page apps need a rule telling the host to send every address to index.html. Without it, Netlify or Vercel looks for a real file at /notes/42 and finds nothing.

    GET /notes/42 404 (Not Found)
  2. Links still pointing at an old address

    The agent renames /settings to /account but leaves three links pointing at the old one. After any rename, ask for a list of every route and every link to it.

  3. Plain links between your own pages

    A regular <a> tag reloads the whole app, so anything in state, like a half-written note, disappears. Use the framework's Link component for pages inside your app.

    <a href="/notes">Back to notes</a>

What to tell your agent

Copy this into Lovable, Bolt, Cursor or any agent
List every route in this app with the file that handles it and whether it needs a signed-in user. If this is a single-page app, add the rewrite rule my host needs so refreshing any page doesn't return a 404.

Quick check

Sign in to earn +10 XP for it

Quill works when you click into a note, but refreshing /notes/42 on Netlify shows "Page not found". Why?

Got a prompt that touches routing?

Paste it. You get a better prompt first, then the cards that explain it.

Check your own prompt

Free, no sign-up.