Add beforeNavigate hook