routes.json Overview
The routes.json
file is a crucial configuration file in our application that defines the structure and behavior of routes and their associated components. This file provides metadata for each route, including path, authority, loaders, and component paths.
Purpose
The main purposes of routes.json
are:
- Define the application's route structure
- Specify component paths for each route
- Configure authentication and authorization requirements
- Set up data loading mechanisms (server-side and client-side)
- Define GraphQL queries associated with routes
- Specify additional permissions and configurations
Basic Structure
Each entry in routes.json
represents a route and is structured as follows:
{
"/path": {
"key": "unique.key",
"name": "Human Readable Name",
"path": "/path",
"componentPath": "path/to/component.js",
"auth": true,
"authority": ["required.permission"],
"hasLoader": true,
// ... other configurations
}
}
Key Benefits
- Centralized Configuration: All route-related information is in one place.
- Automatic Wrapping: The application can automatically apply necessary wrappers based on the configuration.
- Separation of Concerns: Clearly separates routing logic from component implementation.
- Easy Maintenance: Simplifies the process of adding, modifying, or removing routes.
Back to Index | Previous: Best Practices | Next: Field Descriptions