Skip to content

SSR guide - stateful singleton (history) in router example? #1219

Closed
@Liwoj

Description

@Liwoj

In the Routing with vue-router chapter the first example looks like this:

const history = isServer ? createMemoryHistory() : createWebHistory()

const routes = [{ path: '/user', component: MyUser }]

export default function() {
  return createRouter({ routes, history })
}

The code exports router factory which creates new router instance every time. But all instances created by this factory share the same instance of history. Assuming the history created by createMemoryHistory() is stateful, isn't it wrong (Avoid Stateful Singletons) ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions