Our application uses a lot of pre-cooked HTML for certain pages; since these are not standard React components they cannot utilise Next.js Link component or Routing. Due to this, we cannot use Next.js to its fullest extent. We need to find a way to replace regular hyperlink tags "" with Link components before the HTML is inserted into the page or React components. This has to be done on the server-side as well as on the client-side. I need to find a mechanism that allows hyperlinks in pre-cooked HTML to be handled by Next.js' Routing.
Asked
Active
Viewed 1,164 times
2
-
Are you copy pasting the html into react, or is the html coming in as string data? – Tamir Daniely Dec 30 '20 at 11:50
-
This html is coming as string data populated by a CMS. – Saif Ahmad Dec 30 '20 at 12:36
-
1Then I think the answer is to search the string for a tags and add onClick attribute on them that progrematically navigates, with one of the solutions here https://stackoverflow.com/a/42121109/1704733 – Tamir Daniely Dec 30 '20 at 14:26