Avoid Stateful Singletons

As per Vue offcial SSR guide, we need to create a fresh Vue instance for each requestes to avoid sharing states across requests.

For example, in Ream you should create a vue-router instance within the exported function in your entry file:

📝 index.js:

import Router from 'vue-router'

export default () => {
  const router = new Router({
    mode: 'history',
    routes: [/*...*/]
  })
  return {
    router
  }
}

Or moving the logic of creating router instance into another file:

📝 router.js:

import Router from 'vue-router'

export default () => {
  return new Router({
    // ...
  })
}

📝 index.js:

import createRouter from './router'

export default () => {
  return {
    router: createRouter()
  }
}