Found an asnwer:
history package can still be used with react-router v.7 same as in the code in the question via unstable_HistoryRouter as follows:
import { unstable_HistoryRouter as Router, Routes, ... } from "react-router";
Key point is to add history listener before Router adds its listener, otherwise react-router throws an error disallowing more than 1 history listener.