codejump

Pinia Basics

Preview — 3 of 10 questions

What is Pinia and what does it replace in the Vue ecosystem?

APinia is a UI component library that replaces Vuetify
BPinia is the official Vue state management library that replaces Vuex, offering a simpler API and first-class TypeScript support
CPinia is a Vue plugin for server-side rendering that replaces Nuxt
DPinia is a testing utility that replaces Vue Test Utils

How do you install and set up Pinia in a Vue 3 application?

Aimport { createPinia } from 'pinia'; app.use(createPinia())
Bimport Pinia from 'pinia'; Vue.use(Pinia)
Cimport { usePinia } from 'pinia'; usePinia(app)
Dimport pinia from 'pinia'; app.mount('#app', { pinia })

What is the correct way to define a Pinia store?

Aconst store = new PiniaStore('counter', { state: { count: 0 } })
Bconst useCounterStore = reactive({ id: 'counter', count: 0 })
Cconst store = createStore({ id: 'counter', state: { count: 0 } })
Dconst useCounterStore = defineStore('counter', { state: () => ({ count: 0 }) })

Sign up free to play

Answer all 10 questions (7 more), see explanations for every answer, and track your score.