'How to implement react router with raw javascript?(backend .net core mvc) [closed]

A web application is already built with CSS,HTML,raw javascript, jquery, ajax, and .net core MVC. The problem with that is there is a _Layout page where there is a renderBody() in which every page gets rendered. For this, whenever I click to visit another page/nav option, the whole website reloads the page comes. As with React, there is react-router by using which the reloading can be prevented. But to implement the same feature with raw JavaScript/ Jquery?Is there any? TIA



Solution 1:[1]

You can read this article https://medium.com/@fro_g/routing-in-javascript-d552ff4d2921 Or this article https://www.section.io/engineering-education/how-to-build-a-simple-router-in-javascript/

Or You can do the same job of react router be doing this steps Create page and put layout in it and in the center of this layout add div with id main and then create all other page in different file and create function that on document ready read the page url and then load in the element main the file for this link And for navigation create function that replace the existing element with other element from file respective for the nav item clicked It is long process but in the end you will get the same effect as react router

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mohamad Al Zohbie