Basic Grouping
Create a route group with a shared prefix:Group Middleware
Apply middleware to all routes in a group:Multiple Middleware
Nested Groups
Create hierarchical route structures:Deep Nesting
Group Configuration
Named Groups
Assign names to groups for organization:Group with Multiple Prefixes
Organizing by Resource
Structure routes around resources:Middleware Inheritance
Middleware cascades through nested groups:Route Function Pattern
Use theRoute function for cleaner organization:
With Names
Group Use Cases
API Versioning
Authentication Levels
Feature Modules
Mounting Sub-Applications
Mount a separate Fiber app as a sub-app:Sub-App with Middleware
Best Practices
Group related routes together
Group related routes together
Apply middleware at the right level
Apply middleware at the right level
Put common middleware on groups, specific middleware on routes.
Use consistent naming
Use consistent naming
Follow a naming convention for route names and groups.
Keep nesting shallow
Keep nesting shallow
Avoid excessive nesting - 2-3 levels is usually enough.
Complete Example
See Also
Routing
Define routes and parameters
Middleware
Apply middleware to routes and groups
Mounting
Mount sub-applications
Context
Work with request context