Classes: PageRenderer

PageRenderer

Helper class that pre-renders markup for a given route.


new PageRenderer()

Source:

Methods


<static> getQueryRoutingConfigs(renderProps)

Looks up all configs on the currently matched routes.

Parameters:
Name Type Description
renderProps Object

The main route matching result

Source:
Returns:

An object of query routing configurations mapped by query parameter name

Type
Object

<async> handleRequest(req, res, next, options [, debugMode])

Handles incoming request from the express app. Will use renderPage() to do the actual page rendering. Catches any errors that occur and calls express' res.redirect() or next() accordingly.

Parameters:
Name Type Argument Default Description
req Object

The express request object

res Object

The express response object

next function

The express next callback

options Object

Options object

Properties
Name Type Argument Default Description
authHelper AuthenticationHelper <optional>
null

If authentication is enabled for this server, an instance of AuthenticationHelper will be passed so authentication can be performed on routes that require login

afterStoreHook function <optional>
null

Optional hook function that is called after the store is created, so it can dispatch actions or subscribe to changes from outside this function. The store will be passed as the first and only parameter to the hook function.

debugMode boolean <optional>
false

If debug mode is enabled, will run respond with a json with additional metadata instead of the response content as HTML.

Source:

<async> matchRoutes(req, res)

Performs a react-router match() call against the incoming express request. Will execute a redirect if a redirect is returned from the match.

Parameters:
Name Type Description
req Object

The express request object

res Object

The express response object

Source:
Returns:

A Promise that resolves with the renderProps properties if the route was matched. Returns null otherwise.

Type
Promise

<async> renderPage(req, res, options [, debugProps])

Handles incoming request from the express app. Will match the requested route using react-router and if a match has been found, render the markup for that route and respond it back to the client.

Parameters:
Name Type Argument Default Description
req Object

The express request object

res Object

The express response object

options Object

Options object

Properties
Name Type Argument Default Description
authHelper AuthenticationHelper <optional>
null

If authentication is enabled for this server, an instance of AuthenticationHelper will be passed so authentication can be performed on routes that require login

afterStoreHook function <optional>
null

Optional hook function that is called after the store is created, so it can dispatch actions or subscribe to changes from outside this function. The store will be passed as the first and only parameter to the hook function.

debugProps Object <optional>
null

If debug mode is enabled, this will be an object where additional diagnostics will be pushed onto

Source: