React navigate to hash (anchor) on same page


I’m trying to navigate to hash/anchors on my home page from the menu. I have tried downloading the react-router-hash-link package, but it does not seem to work.

Further investigation shows that it requires the BrowserRouter routing mode in order for it to work.

What does Cuba use? BrowserRouter or HashRouter?

If HashRouter, is there an “official” way to set up anchor navigation from the menus?

By default CUBA’s react front uses HashRouter to work without any additional server setup (as BrowserRouter requires url rewriting). However, it’s exposed in generated index.tsx

          <Route component={App} />

so you can change HashRouter to BrowserRouter just right here (as I said it will require additional web server setup).

Thanks. I did get it to work by doing this. Since I am deploying as an uberJar behind an nginx reverse proxy, I have not found any other configuration necessary (yet).