Handles history pushstate/popstate with async option.