'Getting current URL without using Preact-Router

I'm building a widget.

I read it somewhere

"not to use preact-router, because it adds event listeners to all anchors on document level, which is not acceptable for a widget (remember not to mess with the hosting page)".

I want to just get the current URL and no other data is required. How can it be achieved?

P.S: I'm new to programming. Any help is appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source