We can use native javascript window.location.href property to get the current url anywhere like component in react js. Here in this tutorial, we are going to explain how you can use this method to get the current url in reactjs. You can also use our online editor to edit and run the code online.
ReactJs get Current Url JavaScript Example
You can use window.location.href in react js simply as below-
Output of above example-