Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
when i was using vanilla JS, i was listening to '/', to send static files to client.
Application was divided internally into parts parts, but was not made to work with paths. So whatever section of app user is in, if he/she reload the application, he/she will be back to home.
I could have used history api of browser to change path as user browses section of application, but doing reverse was tricky. -
with routers, it had become extremely easy to not just load section of app depending on path, but also organize your source code. Just mention the component you want to render with specific path.
With redirect you are forcing user and server to load/transfer same static files again and again. -
Pointer32377yRouting in a SPA it's done on the browser because, well, the name pretty quites describes itself. You only load "a page" once, then all you have is interaction between your backend and the "app" running in the client's browser.
Handling routes on the frontend it's meant so that the app itself can handle "deep linking" and not redirecting the user to the same old page everytime it loads the page.
Obviously you have to configure the backend so it redirects unknown URL's (to the server) to the root of the app itself, letting the app handle the routing.
About SEO, Google and other SE have some support for SPA's (afaik), but it's always preferable to have the files on the server and the meta on the tags so that it can be better indexed.
There are projects that help handle this, such as "Nuxt.js" (Vue) that "generates" your SPA into real files and paths, so that it can help with SSR and SEO. -
Nilo-jxn6837y@Pointer thanks for the insight. This is what I was looking for.
I’ve heard of Nuxt.js but I haven’t looked into it.
Thanks again for the rundown. -
Pointer32377y@Nilo-jxn You're welcome, if you still have some questions, hit me up with a comment/tag ;)
Just starting to learn front-end js frameworks ( vue ), and I'm curious. What are the advantages or disadvantages of routing in an SPA vs traditionally redirecting the user? Besides the fact that you don't have to create routes in the backend.
Are there any effects on SEO?
Are there any substantial performance differences?
undefined
biscuits&gravy
saturday
javascript
curious
routing