Wouldn't it be much smoother when router.push had a payload?

imagine ur on component-A, on comp-A there is for example table with a list of users which just simple came from an API u fetched on a created() block before.

now u have a this table and a click.row handler which handels the the click on a user from our list.
u get the params.userId to lead to a component-B, which is a user profile page.

on component-B i just need to call the API again just to get the userData.

wouldn’t it be better if i could add a little payload to my router.push()?

this.$router.push(`user-profile/${userId}`, userDataFromTheActualTableJustToDisplayItFasterOnComponentB)

That would somewhat defeat the purpose of using a router. The idea behind a router is that everything is encoded into the URL. You shouldn’t be using it to pass data between pages apart from what’s in the URL.

The motivation is that it should be possible for the page to refresh, or be opened directly from a bookmark or shared URL, and everything will just work as it doesn’t rely on anything being passed from the previous page. If you don’t care about URLs working like that then there’s no need to use the router at all.

If you want to improve performance by skipping an unnecessary load then that sounds like a text-book example of what the store is for. The idea would be for the store to hold an object that maps the userId to the corresponding userData. If the relevant userData is missing then you’d trigger a load.

1 Like