routeRenderer constant identifies Scully’s primary route rendering plugin. It orchestrates the entire rendering pipeline, executing render plugins and DOM transformations to generate static HTML.
Overview
routeRenderer is a special plugin identifier used to find and invoke Scully’s main rendering system. While you typically don’t call it directly, understanding how it works helps you integrate with Scully’s rendering pipeline.
The Rendering Pipeline
When Scully renders a route, it follows this sequence:- Pre-render hooks - Execute any
preRendererfunction defined in route config - Initial render - Use the configured render plugin (or default
routeRenderer) - DOM plugins - Execute
postProcessByDomplugins on the JSDOM - HTML plugins - Execute
postProcessByHtmlplugins on the HTML string - Write to disk - Save the final HTML to the output directory
Using routeRenderer
Finding the Renderer
Access the route renderer plugin usingfindPlugin:
Custom Render Plugins
You can specify an alternative render plugin per route:The renderRoute Function
TherenderRoute function implements the rendering pipeline. It’s registered as a system plugin and handles:
How renderRoute Works
Render Plugin Interface
A render plugin must accept aHandledRoute and return the rendered HTML:
Post-Render Plugins
Plugins execute in the order they’re defined in the route configuration:Execution Order
- Default post-renderers from
defaultPostRenderers - Route-specific post-renderers from
route.postRenderers - DOM plugins execute before HTML plugins
- Plugins execute in array order
Pre-Render Hooks
Control whether a route should be rendered using apreRenderer function:
Error Handling
The rendering system catches errors in plugins and logs them:Manual Rendering
For advanced use cases, you can manually invoke the rendering system:Performance Considerations
DOM vs HTML plugins
DOM vs HTML plugins
DOM plugins are slower because they parse HTML into JSDOM:
- Use
postProcessByHtmlfor simple string replacements - Use
postProcessByDomfor complex DOM manipulations
Plugin execution order matters
Plugin execution order matters
Plugins execute sequentially, so the order affects performance:
Avoid unnecessary plugins per route
Avoid unnecessary plugins per route
Only include plugins that are needed for each route:
Source Reference
- Constant definition:
libs/scully/src/lib/utils/config.ts:12 - Rendering implementation:
libs/scully/src/lib/renderPlugins/executePlugins.ts:13
Related
HandledRoute
Route object structure and properties
Render Plugins
Learn about creating render plugins
Post-Process Plugins
Transform HTML after rendering
Rendering Process
Understanding how Scully renders pages

