← Back to Vue.js Course | Chapter 8: State Management | Lesson 2 of 6

Pinia Install करना

npm से Pinia install करें, एक Pinia instance बनाएँ और इसे अपनी app को दें।
Syntax
markup
import { createApp } from 'vue';
import { createPinia } from 'pinia';

const app = createApp(App);
app.use(createPinia());
app.mount('#app');

Pinia Install करना

npm install pinia चलाएँ, फिर createPinia() call करें और इसे app.use से register करें। Stores defineStore से बने ordinary modules हैं और किसी भी component में इस्तेमाल होते हैं। एक CDN से आपको vue-demi भी चाहिए, जिस पर Pinia depend करता है।

Note: create-vue scaffolding के दौरान आपके लिए Pinia add कर सकता है।

उदाहरण: Installing Pinia

bash
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>
<body>
$ npm install pinia

// main.js
import { createApp } from "vue";
import { createPinia } from "pinia";
import App from "./App.vue";

createApp(App).use(createPinia()).mount("#app");
</body>
</html>

⚠️ Run this in your own terminal or Node.js environment.

Live Example
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. app.use(pinia) भूल जाना
  2. Pinia install होने से पहले एक store call करना
  3. CDN builds के साथ vue-demi missing होना
चैप्टर सारांश
  • npm install pinia से install करें
  • createPinia() instance बनाता है
  • app.use(pinia) इसे install करता है
  • CDN builds को vue-demi चाहिए
🔒

Chapter Quiz — Complete all 6 topics to unlock

0/6 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.