SPFx and modern SharePoint search page for searching the current location

Modern SharePoint sites on standard release will soon receive an update to add a search box to the top Office 365 bar. This allows you to search by default in the current location, like a site or a document library. You can then configure the site to redirect user's search queries to a custom search page and you can use the amazing PnP Modern Search web parts to create a great search experience. But what if you want to pass the context of the current location to the custom search page and keep searching only on that location by default?