Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions docs/content/3.plugins/2.axios/1.guide/1.setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,39 @@ or you use `pinaOrmPluginAxios`. It depends if you want to pass options on initi
```
::

## Usage with Nuxt

With Nuxt you register the plugin in a Nuxt plugin file, e.g. `plugins/pinia-orm-axios.ts`. The plugin has to be applied to the pinia instance after the `pinia` plugin has been set up:

```ts
import { defineNuxtPlugin, usePinia } from '#imports'
import { createPiniaOrmAxios } from '@pinia-orm/axios'
import axios from 'axios'
import { setActivePinia } from 'pinia'
import { createORM } from 'pinia-orm'

export default defineNuxtPlugin({
name: 'pinia-orm-axios',
dependsOn: ['pinia'],
setup () {
const pinia = usePinia()

pinia.use(createORM({
plugins: [
createPiniaOrmAxios({
axios,
// baseURL: 'https://example.com/api',
}),
],
}))

setActivePinia(pinia)
},
})
```

::alert{type="info"}
When you register `createORM` yourself in a plugin like this, you don't need the `@pinia-orm/nuxt` module — the plugin above replaces it.
::