Routing Overview
The VENCOL Front Template uses React Router v6 for client-side routing, providing a seamless single-page application experience.Router Configuration
Main Router Setup
The application usesBrowserRouter as the main router component in App.tsx:
App.tsx
Route Definitions
Static Routes
Static routes map directly to specific page components:Dynamic Routes
Dynamic routes use URL parameters to load specific content:Solution Details
/soluciones/refrigeracion-comercial/soluciones/sistemas-hvac
SolutionDetail.tsx
Blog Post Details
/blog/post-title-here
WordPress Pages (Catch-all)
PageDetail.tsx
Navigation Components
Navbar Navigation
TheNavbar component uses NavLink for active route highlighting:
Navbar.tsx
NavLink automatically receives an isActive boolean in its className function, enabling active state styling.Solutions Dropdown
The navbar includes a dynamic dropdown for solutions:Navbar.tsx
Programmatic Navigation
Use theLink component for navigation:
Scroll Behavior
Scroll to Top on Route Change
The application implements automatic scroll-to-top on navigation:App.tsx
Router to access routing context:
Mobile Navigation
Mobile Menu State
The navbar manages mobile menu state with automatic closing on route change:Navbar.tsx
Mobile Dropdown
The mobile menu includes an expandable solutions section:Navbar.tsx
Loading States
Dynamic pages implement loading states during data fetching:PageDetail.tsx
404 Handling
WordPress Page Not Found
ThePageDetail component handles missing pages:
PageDetail.tsx
Navigation Best Practices
Dynamic Route Parameters
Dynamic Route Parameters
Extract route parameters using Always provide TypeScript types for parameters.
useParams hook:Route Order Matters
Route Order Matters
Place catch-all routes last in the Routes configuration to prevent them from intercepting more specific routes.
Active State Styling
Active State Styling
Use
NavLink instead of Link when you need to style the active route:Related Topics
Architecture
Learn about the overall application structure
WordPress Integration
Understand how dynamic pages are loaded from WordPress