2

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?

Comments
  • 0
  • 0
    routing in SPA let you route to a section to app easily
  • 1
    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.
  • 1
    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.
  • 0
    how much time you have spent on vuejs ?
  • 1
    @jalebiBhai this is my second week with Vuejs. Just starting to get the hang of it.
  • 0
    interested to work on a project ?
  • 0
    Routing 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.
  • 2
    @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.
  • 0
    @Nilo-jxn You're welcome, if you still have some questions, hit me up with a comment/tag ;)
Add Comment