Skip to content

Unable to access Pinia inside Routes.js file #13779

Discussion options

You must be logged in to vote

@AhmedHamdy-B
make your routes.js a function to receive the store context from src/router/index.js as param.
ie.

// src/router/routes.js
export default function (store) {
  const userStore = useUserStore(store)
  const routes = [
     ... userStore.something
   ...
  return routes
}

// src/router/index.js
export default route(function ({ store } ...
 ...
  const Router = createRouter ...
    routes: routes(store),
...

https://stackblitz.com/edit/quasarframework-oagn9v

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@AhmedHamdy-B
Comment options

Comment options

You must be logged in to vote
4 replies
@ReaganM02
Comment options

@metalsadman
Comment options

@AhmedHamdy-B
Comment options

@adgower
Comment options

Answer selected by metalsadman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
5 participants
Converted from issue

This discussion was converted from issue #13774 on June 24, 2022 14:55.