.cursor/skills/routing/SKILL.md
React Router v7 routing patterns and environment variable configuration. Use whenever you touch React Router–related code (routes, links, params, loaders, actions, route config, or env in route context).
npx skillsauth add firtoz/cf-multiworker-boilerplate routingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This project uses React Router v7 with file-based routing configured in apps/web/app/routes.ts.
WHENEVER you edit apps/web/app/routes.ts, you MUST run typegen from the workspace root:
bun run typegen
Run from repo root (turbo routes to the web app). Without this, TypeScript imports will fail. The typegen command generates the +types files that route components need.
Create the route file in the appropriate directory under apps/web/app/routes/:
routes/home.tsx, routes/queue.tsxroutes/dashboard.tsx)// Example: Adding a new route
route("dashboard", "routes/dashboard.tsx"),
This step is REQUIRED, not optional!
bun run typegen
Run from workspace root.
Use the generated types:
// After typegen, this import will work:
import type { Route } from "./+types/dashboard";
export async function action({ request }: Route.ActionArgs) {
// ...
}
RoutePath)Every route module should export its URL so @firtoz/router-toolkit (e.g. formAction, useDynamicSubmitter) stays type-safe. The string must match the path registered in routes.ts:
import { type RoutePath } from "@firtoz/router-toolkit";
export const route: RoutePath<"/dashboard"> = "/dashboard";
Omitting this is a common mistake after cloning; forms and typed submitters depend on it. See .cursor/skills/form-submissions/SKILL.md.
Promise<MaybeError<...>>Use @firtoz/maybe-error (success / fail, type MaybeError) — also re-exported from @firtoz/router-toolkit — so return types are a discriminated union and TypeScript can narrow.
Loaders
Promise<MaybeError<YourData>>.success({ ...fields }) or fail("message") (or a typed error as the second generic).loaderData.success before reading loaderData.result; handle loaderData.error on failure.Deferred values (promises for <Await>) can live inside the success payload: success({ items: itemsPromise }).
Actions
formAction({ ... }) — the handler already returns Promise<MaybeError<...>> with validation errors folded in.formAction, still return success / fail the same way for consistent typing with useFetcher / toolkit helpers.href from react-router)Import href from react-router and use it for all <Link to> values. Do not hardcode paths or concatenate strings.
import { Link, href } from "react-router";
href("/"), href("/collection"):param and an object of param values:<Link to={href("/")} />
<Link to={href("/collection")} />
<Link to={href("/charts/:id", { id: c.id.toString() })} />
Creating a route file without registering it in routes.ts will result in a 404. Always register new routes!
When adding new environment variables (see root AGENTS.md):
.env.example in the package with documentation.env.local (with a real or placeholder value for local dev)bun run typegen from workspace root to regenerate TypeScript types for envbun run typegen
The env object from cloudflare:workers is auto-generated based on what's in your wrangler config and env files.
Do not read bindings from React Router loader/action context (e.g. context.cloudflare.env). In this project, use:
import { env } from "cloudflare:workers";
development
Repo-root commands, typegen and typecheck cadence, lint, deploy, adding packages with bun, and Alchemy app layout. Use at the start of a task, before PR, or when choosing turbo/typegen commands.
development
Fork and template gotchas (env import, routes, typegen, forms, D1, Turbo, HMR, new DO packages). Use when working on apps/web or durable-objects, or when behavior diverges from this stack’s conventions.
testing
Turborepo task configuration patterns for monorepo management. Use when configuring turbo.json tasks, setting up task dependencies, managing cache inputs/outputs, or working with cross-package dependencies in the monorepo.
development
React Router v7 routing patterns and environment variable configuration. Use whenever you touch React Router–related code (routes, links, params, loaders, actions, route config, or env in route context).