# React Router App taste of a full-stack developer who wants routes to own their data
- Use React Router v7 in framework mode with Vite and TypeScript for new apps, not the old data-router setup by hand. Confidence: 0.90
- Define routes in apphttps://www.aitopic.com/routes.ts with explicit route() and layout() calls instead of relying only on file-name magic. Confidence: 0.75
- Load data in route loaders and mutate in route actions; never fetch page data in useEffect. Confidence: 0.95
- Use the generated Route types (.https://www.aitopic.com/+typeshttps://www.aitopic.com/route-name) for loaderData, actionData and params in every route module. Confidence: 0.90
- Render on the server by default and switch a route to prerender or SPA mode only when there is a clear reason. Confidence: 0.80
- Use <Form> and useFetcher for mutations so the app works before JavaScript loads and revalidates automatically. Confidence: 0.90
- Validate form data and params in actions with Zod and return field errors with data(..., { status: 400 }). Confidence: 0.85
- Throw redirect() after a successful POST to avoid double submits on refresh. Confidence: 0.90
- Keep server-only code in .server.ts files so secrets and database clients never reach the client bundle. Confidence: 0.95
- Read the session in a shared helper used by loaders and actions; protect routes with a parent layout loader that redirects. Confidence: 0.80
- Export an ErrorBoundary from the root and from risky routes, and throw data() responses for 404 and 403. Confidence: 0.85
- Use URL search params as state for filters, sorting and pagination so views are shareable and back-button safe. Confidence: 0.90
- Show pending UI with useNavigation and fetcher.state, and add optimistic UI for quick actions like toggles. Confidence: 0.80
- Return promises from loaders for slow, non-critical data and render them with Suspense and Await. Confidence: 0.70
- Set cache headers per route with the headers export instead of one global policy. Confidence: 0.75
- Define meta and links exports per route for titles, descriptions and preloaded assets. Confidence: 0.75
- Keep a thin route module and move business logic into plain functions in apphttps://www.aitopic.com/lib that are easy to unit test. Confidence: 0.85
- Do not add a client data cache library by default; the router's revalidation is enough for most apps. Confidence: 0.70
- Use nested routes and <Outlet https://www.aitopic.com/> for shared layouts instead of repeating headers and sidebars. Confidence: 0.85
- Prefetch likely next pages with <Link prefetch="intent">. Confidence: 0.75
- Test loaders and actions as functions with Vitest, and cover the main flows with Playwright against a built server. Confidence: 0.80
- Deploy with an official adapter for the target (Node, Vercel, Cloudflare) and keep environment access behind one typed config module. Confidence: 0.75
Comments & Questions (0)
No comments yet
Be the first to comment!