How to add routes to vue-router after the router and app have been initialized?

Viewed 174

Is there a way to add routes to vue-router after some async data has been fetched, and which works with SSR? Let's say I have some data in my database that defines these routes.

I got it mostly working with the example at https://ssr.vuejs.org/guide/data.html - though I cannot use the asyncData methods like in the example, because the fetching of the routes from the store needs to be made before the app is mounted because you cannot change the routes later with SSR and directly trying to browse to such a route URL (you'll get a 404 because the SSR doesn't know of the routes yet).

The problem then is that the client requests the same async data again, although they are already present in the server side rendered output.

Does anyone have a working example of that?

0 Answers
Related