From: Schalk Neethling Date: Thu, 16 Jun 2022 07:20:03 +0000 (+0200) Subject: docs: create a pinia example (#1374) [skip ci] X-Git-Tag: @pinia/nuxt@0.2.0~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=655fbb6f882d39d9127dee2120293cc817610469;p=thirdparty%2Fvuejs%2Fpinia.git docs: create a pinia example (#1374) [skip ci] Co-authored-by: Eduardo San Martin Morote --- diff --git a/packages/docs/getting-started.md b/packages/docs/getting-started.md index 02c18150..54e91d9d 100644 --- a/packages/docs/getting-started.md +++ b/packages/docs/getting-started.md @@ -14,12 +14,18 @@ If your app is using Vue 2, you also need to install the composition api: `@vue/ If you are using the Vue CLI, you can instead give this [**unofficial plugin**](https://github.com/wobsoriano/vue-cli-plugin-pinia) a try. -Create a pinia (the root store) and pass it to the app: +Create a pinia instance (the root store) and pass it to the app as a plugin: -```js +```js{2,5-6,8} +import { createApp } from 'vue' import { createPinia } from 'pinia' +import App from './App.vue' + +const pinia = createPinia() +const app = createApp(App) -app.use(createPinia()) +app.use(pinia) +app.mount('#app') ``` If you are using Vue 2, you also need to install a plugin and inject the created `pinia` at the root of the app: