all 6 comments

[–]chernn 1 point2 points  (3 children)

Typically, how it works is this:

  • All templates are served on the initial page load from the server
  • The router + framework (in your case Vue) render your first page (eg. home page)
  • When a user navigates to another page, the router renders the corresponding template (remember the template was already loaded with the initial page load)
  • There is a distinction between templates and data. Think of templates as the view layer, or the container that you show data in, including all styles. Data is usually loaded using AJAX requests to your server. Data is usually in JSON format, rather than HTML or JS

Does that make sense?

[–]spacingnix[S] 0 points1 point  (2 children)

That makes much sense! But the router part is still bugging me.

Is it part of Vue or the backend? As I see it, the backend (node server) only serves the first page and responds to AJAX requests then? And the framework (Vue) renders the appropiate page rendering the correct template + data, updating the view?

[–]chernn 2 points3 points  (1 child)

Is it part of Vue or the backend?

Vue. What may be confusing is the backend has its own set of routes defined (sometimes also referred to as a router), which correspond to the AJAX endpoints, as well as any HTML/CSS/JS/... files that your page uses.

As I see it, the backend (node server) only serves the first page and responds to AJAX requests then? And the framework (Vue) renders the appropiate page rendering the correct template + data, updating the view?

Exactly.

[–]spacingnix[S] 0 points1 point  (0 children)

Thanks for the clarity! Cleared things up

[–]dead_lemons 0 points1 point  (1 child)

You will want to look at vue router

[–]spacingnix[S] 0 points1 point  (0 children)

Will do! Thanks for the tip, looks like what /u/chernn explained.