SwitchUp SwitchUp Ranked Best Coding Bootcamps 2025

How to get active route name in Navigation layout with React Router

Altcademy Team wrote on 7 February 2018

Hello,
I have a navigation layout with a menu and the title of the current page. How can I get the current route name to show in the title?
Here is how the routing is organized:

<Router history={ browserHistory }> <Route path="/" component={ Layout }> <IndexRoute component={ Index } onEnter={ requireAuth } /> <Route path="/hello" component={ Hello } onEnter={ requireAuth } /> <Route path="/world" component={ World } onEnter={ requireAuth } /> <Route path="/login" component={ Login } /> </Route> </Router>

You should be able to see the current route in this.props.location

Trusted by

Students and instructors from world-class organizations

Join the upcoming Cohort #112

Enroll for April 6th, 2026