JavaScript SDK store

Snipcart's JavaScript SDK uses Redux as a state management tool. Therefore, some Redux store methods are available.


The getState method returns the current state tree of the application. In this case, the return value is of type SnipcartState.;


The subscribe method triggers a callback every time an action is dispatched. It is often used to check if a change occurred in the state of the application. When invoked, the return function of the subscribe method will remove the change listener.

let currentValue;
const unsubscribe = store.subscribe(() => {
    let previousValue = currentValue;
    currentValue =;

    if (previousValue !== currentValue) {
        // Anything goes...

// unsubscribe();