Skip to content

Router Selectors

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';

(Array|[]): The current router stack. If the stack is empty, it returns [].

[{
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,
}]

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';

  • 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.

(Object|null): The route object. If nothing was found, it returns null.

{
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,
}

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';

  • 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.

(Object|null): The params object. If nothing was found, it returns null.


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';

  • 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.

(string|null): The pathname. If nothing was found, it returns null.


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';

  • 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.

(Object|null): The query. If nothing was found, it returns null.


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';

  • 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.

(string|null): The search query. If nothing was found, it returns null.


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';

  • 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.

(Object|null): The route state. If nothing was found, it returns null.