Overview
The Router plugin:- Serves as the default router when no type is specified
- Handles static routes without parameters
- Returns routes as-is without transformation
- Requires no configuration
- Automatically registered in Scully
How It Works
The Router plugin is extremely simple. When invoked, it:- Receives a route string
- Returns the route wrapped in a
HandledRouteobject - Performs no data fetching or transformation
Usage
Automatic Usage
The Router plugin is used automatically for routes without a configured type:Explicit Usage
While not required, you can explicitly specify the default router:Configuration
The Router plugin requires no configuration options. It accepts only the route string and returns it immediately.This plugin is registered with the name
'default' in Scully’s plugin repository.When to Use
Use the Router plugin (implicitly or explicitly) when you have:- Static pages: Pages without dynamic parameters
- Simple routes: Routes like
/about,/contact,/faq - No data fetching: Pages that don’t need external data
- Fixed content: Content that doesn’t change based on parameters
Examples
Static Marketing Pages
Mixed Configuration
Combine static routes with dynamic ones:Implementation
The plugin’s implementation is minimal:Comparison with Other Router Plugins
vs. Content Folder Plugin
vs. Content Folder Plugin
Router Plugin (Default):
- No file system scanning
- No data extraction
- Single static route
- No configuration needed
- Scans directories
- Reads file content
- Generates multiple routes
- Requires folder configuration
vs. JSON Plugin
vs. JSON Plugin
Router Plugin (Default):
- No HTTP requests
- No external data
- Immediate return
- No async operations
- Fetches API data
- Handles responses
- Generates multiple routes
- Requires URL configuration
Best Practices
Use for static pages
Reserve the default router for truly static pages that never need dynamic content.
Explicit when needed
While implicit usage works, explicitly setting
type: 'default' can make your configuration clearer.Route Handling Flow
When Scully encounters a route:- Check for explicit type: If
typeis specified, use that plugin - Check for parameters: If the route has
:paramsegments, look for appropriate plugin - Fall back to default: If no type is specified and no parameters exist, use the Router plugin
Performance
The Router plugin is the fastest router option because:- No I/O operations
- No network requests
- No file system access
- Immediate synchronous return
Despite being async in signature, the plugin returns immediately without await points.
Related
Content Folder Plugin
Generate routes from local content files
JSON Plugin
Fetch data from JSON APIs

