React-Enonic project use react routes

Enonic version: 7

I want to use react library inside the enonic-react application. but react route library does not work. I have two pages and I want to link them using react route and it is does not work. Is there any way to use routes in enonic-react app?

A bit more background info would be nice. By enonic react application, do you mean something based on react4xp (serverside react), or are we talking about front-end react here?

Server-side react in react4xp. I want to redirect to a page when a button clicks on another page. How to redirect to another page from serverside react using .jsx files

Not sure if I get the use-case? Users always click buttons in the front-end, and you should then handle it there. You can ofc create links or buttons serverside as well.

Hi, Cherysan19!

React4xp works by having Enonic XP serving XP-rendered HTML and JS assets that are react apps (“entries”) that run in the browser as regular react. Server-side rendered react apps should be no different; only that a representation of the react app is rendered with the HTML and then activated in the browser with React.hydrate. So in principle, this should work (although I’ve never tested with react router).

How does this error behave - ie. are you getting any messages in the browser console, or from XP in the server log?

Espen Norderud

1 Like