Router Selectors
- getRouterStack
- getCurrentRoute
- getCurrentParams
- getCurrentPathname
- getCurrentQuery
- getCurrentSearchQuery
- getCurrentState
getRouterStack
Section titled “getRouterStack”Retrieves the router stack from the store.
import { getRouterStack } from '@shopgate/engage/core';Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7:
import { getRouterStack } from '@shopgate/pwa-common/selectors/router';
Returns
Section titled “Returns”(Array|[]): The current router stack. If the stack is empty, it returns [].
Example Result
Section titled “Example Result”[{ id: 'juicb', pattern: '/', pathname: '/', location: '/', params: {}, query: {}, hash: null, state: {}, created: 1562587961638, updated: 1562588028967,}, { id: 'sb5tk', pattern: '/category/:categoryId', pathname: '/category/3637', location: '/category/3637?sort=priceAsc#some-hash', params: { categoryId: '3637' }, query: { sort: 'priceAsc' }, state: { title: 'My Page Title' }, hash: 'some-hash', created: 1562587961738, updated: 1562588029967,}]getCurrentRoute
Section titled “getCurrentRoute”Retrieves the current visible route from the store.
import { getCurrentRoute } from '@shopgate/engage/core';Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7:
import { getCurrentRoute } from '@shopgate/pwa-common/selectors/router';
Parameters
Section titled “Parameters”state(Object) required: The application state.props(Object) : An object containing props.routeId(string): Can be passed to select a specific route from the stack.
Returns
Section titled “Returns”(Object|null): The route object. If nothing was found, it returns null.
Example Data
Section titled “Example Data”{ id: 'sb5tk', pattern: '/category/:categoryId', pathname: '/category/3637', location: '/category/3637?sort=priceAsc#some-hash', params: { categoryId: '3637' }, query: { sort: 'priceAsc' }, state: { title: 'My Page Title' }, hash: 'some-hash', created: 1562587961738, updated: 1562588029967,}getCurrentParams
Section titled “getCurrentParams”Retrieves the params of the current visible route from the store.
import { getCurrentParams } from '@shopgate/engage/core';Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7:
import { getCurrentParams } from '@shopgate/pwa-common/selectors/router';
Parameters
Section titled “Parameters”state(Object) required: The application state.props(Object) : An object containing props.routeId(string): Can be passed to select a specific route from the stack.
Returns
Section titled “Returns”(Object|null): The params object. If nothing was found, it returns null.
getCurrentPathname
Section titled “getCurrentPathname”Retrieves the pathname of the current visible route from the store.
import { getCurrentPathname } from '@shopgate/engage/core';Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7:
import { getCurrentPathname } from '@shopgate/pwa-common/selectors/router';
Parameters
Section titled “Parameters”state(Object) required: The application state.props(Object) : An object containing props.routeId(string): Can be passed to select a specific route from the stack.
Returns
Section titled “Returns”(string|null): The pathname. If nothing was found, it returns null.
getCurrentQuery
Section titled “getCurrentQuery”Retrieves the query of the current visible route from the store.
import { getCurrentQuery } from '@shopgate/engage/core';Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7:
import { getCurrentQuery } from '@shopgate/pwa-common/selectors/router';
Parameters
Section titled “Parameters”state(Object) required: The application state.props(Object) : An object containing props.routeId(string): Can be passed to select a specific route from the stack.
Returns
Section titled “Returns”(Object|null): The query. If nothing was found, it returns null.
getCurrentSearchQuery
Section titled “getCurrentSearchQuery”Retrieves the search query (query parameter “s”) of the current visible route from the store.
import { getCurrentSearchQuery } from '@shopgate/engage/core';Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7:
import { getCurrentSearchQuery } from '@shopgate/pwa-common/selectors/router';
Parameters
Section titled “Parameters”state(Object) required: The application state.props(Object) : An object containing props.routeId(string): Can be passed to select a specific route from the stack.
Returns
Section titled “Returns”(string|null): The search query. If nothing was found, it returns null.
getCurrentState
Section titled “getCurrentState”Retrieves the state of the current visible route from the store. A route state can be set via the update helper which is provided by the useNavigation hook.
import { getCurrentState } from '@shopgate/engage/core';Attention: The path to the old modules is deprecated and will be removed in ENGAGE v7:
import { getCurrentState } from '@shopgate/pwa-common/selectors/router';
Parameters
Section titled “Parameters”state(Object) required: The application state.props(Object) : An object containing props.routeId(string): Can be passed to select a specific route from the stack.
Returns
Section titled “Returns”(Object|null): The route state. If nothing was found, it returns null.

