JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 302
  • Score
    100M100P100Q96561F
  • License MIT

Universal JS router for E-Com Plus storefront

Package Exports

  • @ecomplus/storefront-router

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@ecomplus/storefront-router) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

storefront-router

CodeFactor npm version license mit

SPA/SSR router for E-Com Plus storefront

Changelog

Usage

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.

Example

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)
    }
  })

Dependencies

It requires and may not include:

Node.js

npm i --save @ecomplus/utils @ecomplus/storefront-router

Webpack

npm i --save core-js @ecomplus/utils @ecomplus/storefront-router

CDN

<script src="https://cdn.jsdelivr.net/npm/@ecomplus/storefront-router/dist/ecom-router.var.min.js"></script>

ecomUtils and ecomClient libraries must be included separately and available on window scope.