You can check if the current location is the initial entry in the history stack by checking if history.index === 0.