Basic information
About epic-routing
Guide on routing with React Router and react-router-auto-routes for Epic Stack
epic-routing is an agent skill listed in the AddMCP.net directory, published by epicweb-dev. Runtime: TypeScript. License: MIT. The repository has 5,544 GitHub stars. Source code is hosted on github.com. Related topics: epic-stack, remix-stack, remix-stacks.
Overview
What is epic-routing?
name: epic-routing description: Guide on routing with React Router and react-router-auto-routes for Epic Stack categories:
- routing
- react-router
- file-based-routing
Epic Stack: Routing
When to use this skill
Use this skill when you need to:
- Create new routes or pages in an Epic Stack application
- Implement nested layouts
- Configure resource routes (routes without UI)
- Work with route parameters and search params
- Understand Epic Stack's file-based routing conventions
- Implement loaders and actions in routes
Patterns and conventions
{loaderData.owner.name}'s Notes
{/* Child routes render here */} ) } ``` Child routes (`$noteId.tsx`, `index.tsx`, etc.) will render where `` is. ### Resource Routes (Routes without UI) Resource routes don't render UI; they only return data or perform actions. **Characteristics:** - Don't export a `default` component - Export `loader` or `action` or both - Useful for APIs, downloads, webhooks, etc. **Example:** ```typescript // app/routes/resources/healthcheck.tsx export async function loader({ request }: Route.LoaderArgs) { // Check application health const host = request.headers.get('X-Forwarded-Host') ?? request.headers.get('host') try { await Promise.all([ prisma.user.count(), // Check DB fetch(`${new URL(request.url).protocol}${host}`, { method: 'HEAD', headers: { 'X-Healthcheck': 'true' }, }), ]) return new Response('OK') } catch (error) { return new Response('ERROR', { status: 500 }) } } ``` ### Loaders and Actions **Loaders** - Load data before rendering (GET requests) **Actions** - Handle data mutations (POST, PUT, DELETE) **Loader pattern:** ```typescript export async function loader({ request, params }: Route.LoaderArgs) { const userId = await requireUserId(request) const data = await prisma.something.findMany({ where: { userId }, }) return { data } } export default function RouteComponent({ loaderData }: Route.ComponentProps) { returnCommon examples
{loaderData.product.name}
{loaderData.product.description}
Product "{params.slug}" not found
), }} /> ) } ``` ### Example 3: Resource route for download ```typescript // app/routes/resources/download-report.tsx export async function loader({ request }: Route.LoaderArgs) { const userId = await requireUserId(request) const report = await generateReport(userId) return new Response(report, { headers: { 'Content-Type': 'application/pdf', 'Content-Disposition': 'attachment; filename="report.pdf"', }, }) } ``` ### Example 4: Route with multiple nested parameters ```typescript // app/routes/users/$username/posts/$postId/comments/$commentId.tsx export async function loader({ params }: Route.LoaderArgs) { // params contains: { username, postId, commentId } const comment = await prisma.comment.findUnique({ where: { id: params.commentId }, include: { post: { include: { author: true }, }, }, }) return { comment } } ```Common mistakes to avoid
- ❌ Over-engineering route structure: Keep routes simple - don't create
complex nested structures unless you actually need them
- ❌ Creating abstractions prematurely: Start with simple routes, add
complexity only when there's a clear benefit
- ❌ Using React Router's standard convention: Epic Stack uses
react-router-auto-routes, not the standard convention
- ❌ Exporting default component in resource routes: Resource routes should
not export components
- ❌ Not using nested layouts when needed: Use
_layout.tsxwhen you have
shared UI, but don't create layouts unnecessarily
- ❌ Forgetting
<Outlet />in layouts: Without<Outlet />, child routes
won't render
- ❌ Using incorrect names for parameters: Should be
$param.tsx, not
:param.tsx or [param].tsx
- ❌ Mixing route groups with URLs: Groups (
_auth/) don't appear in the
URL
- ❌ Not validating params: Always validate that parameters exist before
using them
- ❌ Duplicating route logic: Use layouts and shared components, but only
when it reduces duplication
References
- [Epic Stack Routing Docs](../epic-stack/docs/routing.md)
- Epic Web Principles
- React Router Auto Routes
app/routes.ts- Auto-routes configurationapp/routes/users/$username/notes/_layout.tsx- Example of nested layoutapp/routes/resources/healthcheck.tsx- Example of resource routeapp/routes/_auth/login.tsx- Example of route in route group
Comments
No comments yet
Be the first to share feedback about this listing. Sign in to leave a comment.
Sign In