pinia/nuxt
correctly. See installation guidelines.yarn add pinia-orm @pinia-orm/nuxt
Nuxt 2
and also using the nanoid
package you gonna need to stick nanoid to version 3.3.4. This is related to ai/nanoid#365... "resolutions": { "nanoid": "3.3.4" }...
import { defineNuxtConfig } from 'nuxt3'export default defineNuxtConfig({ modules: [ '@pinia/nuxt', '@pinia-orm/nuxt' ]})
On Nuxt 2 with nuxt composition api there is a drawback with the usage. You
always gonna need to pass the pinia instance to useRepo
because otherwise on client side you will get an
error because the store is called outside the store.
In Nuxt 3 this problem somehow doesn't occur.
import { defineComponent, useContext } from '@nuxtjs/composition-api'import { useRepo } from 'pinia-orm'import User from '~/models/User'export default defineComponent({ name: 'IndexPage', setup() { const { $pinia } = useContext() const userRepo = useRepo(User, $pinia) ... },})