router
Router provides methods to facilitate working with URLs in a client context.
Methods
router.getUrl(path [, queryStringParameters])
Returns a URL given a path. Provide queryStringParameters
as an object to include query string parameters. The URL will match configured paths in the server side context of your app.
router.getStandaloneUrl(path [, queryStringParameters])
Returns a URL that will execute a route standalone, i.e. it will not be part of page rendering. This is very useful when you only want to target your route without any side effects. Typical use cases are delivering a file from a route or redirecting when a form has been posted.
Example of a standalone URL being used to execute a route:
router.navigate(url [, options])
Updates the URL (History API) and triggers path and/or query changes. Defaults to pushState navigation. Set the replace option to true to perform a replaceState navigation. Pass a queryParams object in the options object to update query string parameters in the URL.
Pass an empty string as URL to update query string parameters while maintaining current path.
router.parseQueryString()
Returns current query string (location.search
) as an object. WebApp specific parameters (sv.target
and sv.<portletId>.router
) are omitted from the object.