Get started with pinia CDN
MIT licensed
Pinia is a state management library for Vue 3 applications.
Tags:- vue
- vuex
- store
- pinia
- piña
- pigna
- composition
- api
- setup
- typed
- typescript
- ts
- type
- safe
Stable version
Copied!
How to start using pinia CDN
<!DOCTYPE html>
<html>
<head>
<title>Get started with pinia CDN - cdnhub.io</title>
<script src="https://cdn.jsdelivr.net/npm/pinia@2.1.7/pinia.min.js"></script>
<script src="https://cdn.cdnhub.io/pinia/2.1.7/pinia.iife.js"></script>
</head>
<body>
<button id="increment">Increment</button>
<button id="decrement">Decrement</button>
<script>
import { createStore, ref } from 'pinia';
const useCounterStore = createStore({
id: 'counter',
state: () => ({ count: ref(0) }),
actions: {
increment() {
this.count.value++;
},
decrement() {
this.count.value--;
},
},
});
const counterStore = useCounterStore();
document.getElementById('increment').addEventListener('click', () => {
counterStore.increment();
});
document.getElementById('decrement').addEventListener('click', () => {
counterStore.decrement();
});
</script>
</body>
</html>
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
All versions
2.0.10
2.0.11
2.0.12
2.0.13
2.0.14
2.0.15
2.0.16
2.0.17
2.0.18
2.0.19
2.0.2
2.0.20
2.0.21
2.0.22
2.0.23
2.0.24
2.0.25
2.0.26
2.0.27
2.0.28
2.0.29
2.0.3
2.0.30
2.0.31
2.0.32
2.0.33
2.0.34
2.0.35
2.0.36
2.0.4
2.0.5
2.0.6
2.0.7
2.0.8
2.0.9
2.1.0
2.1.1
2.1.2
2.1.3
2.1.4
2.1.5
2.1.6
2.1.7
2.1.8-beta.0
2.2.0
2.2.1
*** 2.2.2