Universal JS router for E-Com Plus storefront
npm install @ecomplus/storefront-router 


SPA/SSR router for E-Com Plus storefront
The @ecomplus/storefront-router package may be used for:
- List all products, brands, categories and collections pages
(URL paths) for prerenderization/SSR;
- Based on URL path, get document body (product, brand, category, collection)
on browser or server side to render the page markup;
It's available for both Node.js and browser environments.
- Get started
- Class reference
``js`
const router = new EcomRouter()
// Simple example resolving all routes
router.list()
.then(routes => {
routes.forEach(route => {
console.log(route.resource)
router.resolve(route)
.then(context => {
console.log(context.body)
})
.catch(error => { throw error })
})
})
.catch(error => {
console.error(error)
if (error.response) {
console.log(error.response)
}
})
It _may_ require and doesn't include core-js (optional) and @ecomplus/utils (peer dependency).
#### Webpack
`bash`
npm i --save core-js @ecomplus/utils @ecomplus/storefront-router
#### Node.js
`bash`
npm i --save @ecomplus/utils @ecomplus/storefront-router
#### CDN
`html`
When importing from CDN, ecomUtils and ecomClient` libraries must be included separately and available on window scope.