Routing, Layouts, and Modules
Prevent routing and layout logic from becoming inconsistent across modules.
Recommended approach
Keep route, layout, and module structure aligned so teams can navigate and extend features without guesswork.
- Colocate route modules with feature modules.
- Use predictable naming for page, layout, and middleware files.
- Keep auth guards and redirects at routing boundaries.
- Keep shared UI and shared helpers outside feature-owned modules.
Suggested structure
Use a feature-first tree where each module owns its route entry points and feature-specific UI.
auth.page.tsx
auth.layout.tsx
auth-middleware.tsx
sign-in-form.tsx
offers.page.tsx
offers.layout.tsx
create-offer-form.tsx
create-offer-validations.tsx
main.tsx
Implementation checklist
- Document route group and module naming conventions.
- Define nested layout strategy and ownership boundaries.
- Keep API communication in
api/modules, not in presentational components. - Keep business logic out of shared UI primitives.
- Add route-level loading and error boundaries.
Common pitfalls
- Route names that encode implementation details instead of domain meaning.
- Reusing layouts that hide permission assumptions.
- Hiding feature logic in global
components/orlib/too early. - Mixing route files and feature files with no consistent convention.