Routing with javascript
Hello everyone, i want to make a simple web app that renders views based on the routes in the url using javascript, i want to know how to detect changes in url and reder corresponding views, and if someone gives me a simple example of doing this, this will be better.
1/4/2021 7:43:26 PM
Salih Benlalla
3 Answers
New Answerhttps://medium.com/altcampus/implementing-simple-spa-routing-using-vanilla-javascript-53abe399bf3c
JaScript i mean like in reactjs there is already a package (BrowserRouter) that you can install with npm and import it in your code to get this fonctionnality, i want to do smoething similar with vanilla javascript, you can think of it as i want to know how this fonctionnality work behind the scenes, and recreate it with vanilla javascript. and if you never worked with react, i want to create a single page web app that changes views depending on url routes without refreshing the page or fetching new html document using anchor tag <a>
You have completed the HTML tutorial here. So you should know that if you are entering a new link in your webbrowser it will route to this website of above mentioned urlClientUser. And this is for you not enought and if I right understood you want to use javascript and route to another url e.g. urlMyJavaScript? Can you please explain it more detailed with an example, how do you image this function / feature?