how to use : router.push('/home') #1142
Answered
by
posva
adityafawzan
asked this question in
Help and Questions
-
how to use : router.push('/home') in pinia store and also, how to access custom properties : |
Beta Was this translation helpful? Give feedback.
Answered by
posva
Mar 14, 2022
Replies: 1 comment 4 replies
-
You can add the router to stores: https://pinia.vuejs.org/core-concepts/plugins.html#adding-new-external-properties and then use them with for setup stores, you can just call defineStore('auth', () => {
const router = useRouter()
// ...
}) |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
posva
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can add the router to stores: https://pinia.vuejs.org/core-concepts/plugins.html#adding-new-external-properties and then use them with
this.router
inside actions.for setup stores, you can just call
useRouter()
as long as they are used inside of components (normal usage):