Overview
SIGEAC uses Next.js 14 App Router for file-based routing with support for layouts, loading states, and error boundaries.Route Structure
Theapp directory defines all routes:
Dynamic Routes
Company Parameter
The[company] dynamic segment enables multi-tenant functionality:
app/[company]/dashboard/page.tsx
app/[company]/dashboard/page.tsx:1
Multiple Dynamic Segments
Nested dynamic routes for detail pages:app/[company]/mantenimiento/ordenes/[id]/page.tsx
Layouts
Layouts wrap pages and persist across navigation.Root Layout
The root layout wraps the entire application:app/layout.tsx
app/layout.tsx:1
Nested Layouts
Company-specific layout adds the dashboard UI:app/[company]/layout.tsx
app/[company]/layout.tsx:1
Layout Hierarchy
Navigation
Link Component
Use Next.jsLink for client-side navigation:
Programmatic Navigation
Use theuseRouter hook:
Navigation Methods
- push
- replace
- back
- refresh
Navigate to a new route (adds to history):
Route Parameters
Reading Parameters
UseuseParams and useSearchParams:
Setting Parameters
Update query parameters without full navigation:Route Protection
Middleware protects routes requiring authentication:middleware.ts
middleware.ts:1
Adding Protected Routes
To protect a new route:Loading States
Createloading.tsx files for automatic loading UI:
app/[company]/dashboard/loading.tsx
app/[company]/loading.tsx:1
Error Boundaries
Createerror.tsx files for error handling:
app/[company]/error.tsx
Not Found Pages
Create custom 404 pages:app/not-found.tsx
app/not-found.tsx:1
Route Groups
Use parentheses to organize routes without affecting the URL:Parallel Routes
Render multiple pages in the same layout:app/dashboard/layout.tsx
Intercepting Routes
Intercept routes to show modals:Best Practices
Use Link for navigation
Use Link for navigation
Prefetch links
Prefetch links
Next.js automatically prefetches
Link components in the viewport. Disable if needed:Type route parameters
Type route parameters
Always type your route parameters:
Handle loading and error states
Handle loading and error states
Add
loading.tsx and error.tsx files for better UX:Common Routing Patterns
Next Steps
Data Fetching
Learn how to fetch data in routes
Adding Modules
Create new modules and routes
