2.1.5 (2023-07-26)
2.1.4 (2023-06-14)
- devtools: group setup store sync actions mutations (683efe1)
2.1.3 (2023-05-18)
- types: revert declare module vue (3000161)
2.1.2 (2023-05-18)
- Force vue-demi version
2.1.1 (2023-05-17)
- expect Vue 3.3 (b8fb165)
2.1.0 (2023-05-17)
- types: use declare module vue (b7f97dd)
- allow app injections in setup stores (6a71019), closes #1784
- devtools: allow resetting setup stores from inspector (971dcdb), closes #2189
- Revert "chore: tmp upgrade to beta" (2337130)
2.0.36 (2023-05-08)
2.0.35 (2023-04-20)
- types: improve setActivePinia types (1650c6e)
2.0.34 (2023-04-07)
No changes in this release
2.0.33 (2023-03-06)
2.0.32 (2023-02-21)
2.0.31 (2023-02-20)
2.0.30 (2023-02-01)
2.0.29 (2023-01-15)
2.0.28 (2022-12-09)
2.0.27 (2022-11-27)
- api docs changes
2.0.26 (2022-11-23)
2.0.25 (2022-11-21)
2.0.24 (2022-11-17)
2.0.23 (2022-10-08)
2.0.22 (2022-09-06)
2.0.21 (2022-08-26)
2.0.20 (2022-08-19)
- build: support vue 2 devtools flag
2.0.19 (2022-08-18)
- devtools: use flag to include devtools (4e92c36)
2.0.18 (2022-08-10)
2.0.17 (2022-07-25)
- devtools: state formatting (b01f5c2), closes #1358
- setupStore getter types (#1430) (#1444) (6be93f2)
- devtools: allow resetting fromp pinia inspector (cee0e16)
2.0.16 (2022-07-12)
- add missing require in exports (96c0dbc)
2.0.15 (2022-07-11)
2.0.14 (2022-05-05)
- avoid multiple subscriptions with empty promises (6c17168), closes #1129
- correctly detect option stores (11b92fd), closes #1272
- devtools: remove in tests environment (4aeb0a5)
2.0.13 (2022-03-31)
- update devtools-api (5334222)
2.0.12 (2022-03-14)
- devtools: avoid error in getters (a64c19d), closes #1062
- types: exclude internal properties from store (f8f944f), closes #1013
- devtools: allow disable logs (43f690f)
- devtools: use api.now() (836ab86)
- up vue-devtools (e8e5f28)
- warn: avoid vue 2 bug storeToRefs() (f692fdf), closes #852
2.0.11 (2022-01-30)
2.0.10 (2022-01-27)
- check HTMLAnchorElement in saveAs for mini-program (#966) (#967) (85daefb)
- subscriptions: allow removing subscriptions inside them (#990) (465d222)
- types: custom Awaited for TS 4.x (7c51126), closes #957
2.0.9 (2021-12-24)
2.0.8 (2021-12-20)
2.0.7 (2021-12-20)
- allow using multiple
$onAction
, ignore returned value (4dc1f1b), closes #893 - subscribe: direct mutation should not trigger detached subscriptions (a9ef6b6), closes #908
- update devtools-api (ca26686)
2.0.6 (2021-12-04)
2.0.5 (2021-12-01)
- accept reactive with storeToRefs (3a2a334), closes #799
- shouldHydrate if not in skipHydrateMap (#846) (bcc44bc)
2.0.4 (2021-11-19)
- devtools: allow resetting directly from devtools (44fa896)
- devtools: display all getters in pinia root (ce8f1e5)
2.0.3 (2021-11-10)
- Updated peer deps for composition api and vue devtools
2.0.2 (2021-11-03)
2.0.1 (2021-11-03)
This release correctly removes the deprecated APIs as advertised in v2. The documentation contains a list of all the deprecations compared to v0.x.
- use assign instead of spread for older browsers (51cf9b6)
- warn: improve getActivePinia warn (6a0a209)
2.0.0 (2021-10-27)
🎉 🎉 🎉
- devtools: root store access #732 (90d2c35)
- plugins: ensure plugins are used only once (#745) (150fdfc)
- ssr: make skipHydrate compatible with @vue/composition-api (71448b0)
All deprecated API have been removed.
2.0.0-rc.15 (2021-10-25)
- types: remove unused option hydrate for setup stores (37d07fb)
- ssr: pass storeState instead of store to hydrate (c85edac)
- ssr: add skipHydrate to skip hydration on specific refs (55deedb)
- ssr: the
hydrate()
option for stores defined with the options api no longers passes the whole store instance. Instead, it passes thestoreState
so it can be directly modified. This is because it was currently necessary to hydrate the store by setting properties ontostore.$state
. This change makes it impossible to make the mistake anymore.
defineStore('main', {
state: () => ({
customRef: useLocalStorage('key', 0)
}),
- hydrate(store) {
- store.$state.customRef = useLocalStorage('key', 0)
+ hydrate(storeState) {
+ storeState.customRef = useLocalStorage('key', 0)
}
})
2.0.0-rc.14 (2021-10-19)
Readme update
2.0.0-rc.13 (2021-10-12)
- bump vue-devtools-api version
2.0.0-rc.12 (2021-10-07)
- proper check of computed requiring @vue/composition-api@1.2.3 (b099ef4)
- warn: log store id with class constructor warning (#702) (39eee6a)
2.0.0-rc.11 (2021-10-03)
- build: expose mjs correctly (2e9fe33)
- export the module version in mjs (cffc313)
- types: correctly type global extensions (cdbdba5), closes #630
- warn: avoid toRefs warning for Vue 2 (c174fe1), closes #648
2.0.0-rc.10 (2021-09-30)
- ssr: always call setActivePinia (83d7d2f), closes #665
- use assign to set $state (f3a732f), closes #682
- fix mjs, cjs versions for webpack based builds
2.0.0-rc.9 (2021-09-12)
- correct store in getters vue 2 (3d4080b)
- vue2: delay getters until stores are ready when cross using them (ed48b00)
- vue2: fix isComputed check for getters (307078b)
2.0.0-rc.8 (2021-09-06)
2.0.0-rc.7 (2021-09-03)
- ssr: properly hydrate setup stores (4fbacfc)
- add typedoc (b98e23d)
- allow stores to be cross used (cda3658)
- deprecate PiniaPlugin in favor of PiniaVuePlugin (c0495c0)
- support TS 4.4 (#656) (39b2e15)
2.0.0-rc.6 (2021-08-19)
Fix missing types.
2.0.0-rc.5 (2021-08-19)
- destroy a store with $dispose (#597) (a563e6a)
- expose getActivePinia (8b8d0c1)
- testing: add testing package (fc05376)
2.0.0-rc.4 (2021-08-09)
If you are using Vue 2, make sure your @vue/composition-api
version is at least 1.1.0
, which is currently under the npm dist tag next
, which means it has to be installed with npm install @vue/composition-api@next
.
2.0.0-rc.3 (2021-08-05)
2.0.0-rc.2 (2021-08-04)
This version supports Vue 2! Here is an example using Vue 2 and Vite for an optimal DX. Note this version requires Vue Devtools 6, and more specifically, they don't work with the current @vue/devtools-api
(6.0.0-beta.15
) because they require this unreleased fix. To get all the goodness pinia has to offer for Vue 2, you will need to clone vuejs/devtools
, run yarn && yarn run build
and then load an unpacked extension on a Chromium browser (after activating the developer mode in the extension panel). If you are using Vue 3, you can still use the Vue Devtools 6 regularly.
2.0.0-rc.1 (2021-07-30)
Posted #592 to help people installing or upgrading Pinia.
- collect reactive effects ran in plugins (54cee00)
- devtools: update when custom properties change (7dcb71e)
- store: keep original refs with $reset (a7dadff), closes #593
2.0.0-rc.0 (2021-07-28)
This release requires Vue 3.2.0, which is currently only available under the beta
dist tag (npm i vue@beta
or yarn add vue@beta
+ the corresponding packages like @vue/compiler-sfc@beta
).
Follow the instructions at #592 if you need help updating your package versions.
It contains major improvements:
- Performance: Pinia now uses
effectScope()
, effectively reducing memory consumption and removing the drawbacks mentioned in the Plugin section aboutuseStore()
creating multiple store instances (still sharing the state). - Devtools: Many improvements over the information displayed in devtools as well as a few bugfixes
- HMR (Hot Module Replacement): You can now modify your stores without reloading the page and losing the state, making development much easier. Until 3.2.0 (stable) is released, you can find an example in the playground. After that, you can read up to date instructions in the documentation.
- Setup syntax: You can now define stores with a function instead of options. This enables more complex patterns. See an example in the playground. Setup Stores are unable to group actions like Option Stores due to their very permissive syntax.
- Option syntax: we can now pass the
id
as the first parameter. This syntax is preferred over the object syntax to be consistent with the Setup syntax.
- avoid modifying options argument (59ac9b9)
- devtools: avoid grouping patches and mutations with finished actions (18a87fe)
- errors: allow async errors to propagate (17ee4e8), closes #576
- ssr: delay getters read (2f3bd53)
- types: actual generic store (e4c541f)
- types: stricter types for mapState (f702356)
- allow actions to be destructured (859d094)
- devtools: display pinia without stores (ca59257)
- devtools: show hot update in timeline (3b9ed17)
- types: add StorState, StoreGetters, and StoreActions helpers (47c0610)
- types: The existing
Store<Id, S, G, A>
types was trying to be generic when no types were specified but failing at it. Now,Store
without any type will default to an empty Store. This enables a stricter version ofdefineStore
when any of state, getters, and actions are missing. If you were usingStore
as a type, you should now useStoreGeneric
instead, which also replacesGenericStore
(marked as deprecated).
-function takeAnyStore(store: Store) {}
+function takeAnyStore(store: StoreGeneric) {}
- types The existing
DefineStoreOptions
is no longer the one that should be extended to add custom options unless you only want them to be applied to Option Stores. UseDefineStoreOptionsBase
instead.
2.0.0-beta.5 (2021-07-10)
- devtools: avoid infinite loop when cross using stores (55c651d), closes #541
- devtools: avoid warning (399a930)
- types: forbid non existant access in getters and actions (2ee058e)
- mark testing as internal (18c8ed6)
- testing: add createTestingPinia (120ac9d)
- testing: allow stubing $patch (10bef8a)
- testing: allows faking an app (0d00a27)
- testing: bypass useStore(pinia) (5a52fb3)
- use esm version of file-saver (49d1e38)
2.0.0-beta.3 (2021-06-18)
- devtools: display custom properties (fd901cd)
2.0.0-beta.2 (2021-06-03)
- devtools: register stores (5fcca78)
2.0.0-beta.1 (2021-06-03)
- types: fix extension for TS 4.3 (aff5c1e)
- remove deprecated APIs (239aec5)
- devtools: add root state (a75be78)
- devtools: import/export global state (b969f2a)
- devtools: load/save state (9b503d6)
2.0.0-alpha.19 (2021-05-20)
- devtools: use older js (e35da3b)
2.0.0-alpha.18 (2021-05-17)
2.0.0-alpha.17 (2021-05-17)
- types: forbid non existent keys on store (e747cba)
- types: patch should unwrap refs (b82eafc)
- types: unwrap refs passed to state (b2d3ac9), closes #491
- devtools: add more data to actions (e8f4b0e)
- devtools: allow editing state (0bbbd69)
- devtools: allow editing stores from components (b808fbc)
- devtools: display only relevant stores (58f0af6)
- devtools: group action and their changes (ecd993a)
- types: allow defining custom state properties (17fcbca)
- types: infer args and returned value for onAction (f3b3bcf)
- subscribe to actions with
$onAction
(c9ce6ea), closes #240
- devtools: avoid multiple subscriptions (ea62f1d)
-
The
type
property of the first parameter ofstore.$subscribe()
has slightly changed. In most scenarios this shouldn't affect you as the possible values fortype
were including emojis (a bad decision...) and they are now using an enum without emojis. Emojis are used only in devtools to give a mental hint regarding the nature and origin of different events in the timeline. -
In
store.$subscribe()
's first argument, thestoreName
property has been deprecated in favor ofstoreId
.
2.0.0-alpha.16 (2021-05-04)
- devtools: display getters in components (810b969)
2.0.0-alpha.15 (2021-05-04)
- devtools: fix devtools attach (017795a)
2.0.0-alpha.14 (2021-05-03)
- devtools: work with stores added before app.use (#444) (21f917f)
- devtools: add getters to devtools (c4bf761)
- mark getters as readonly (fcbeb95)
- plugins: allow chaining (3a49d34)
- mapHelpers: warn on array mapStores (d385bd9)
- pass options to context in plugins (c8ad19f)
- types: expose PiniaPluginContext (94d12e7)
- add plugin api wip (50bc807)
- plugins: allow void return (5ef7140)
- plugins: pass a context object to plugins instead of app (bcb4ec3)
- add plugin api wip (b5c928d)
- store: reuse store instances when possible (14f5a5f)
-
store: getters now receive the state as their first argument and it's properly typed so you can write getters with arrow functions:
defineStore({ state: () => ({ n: 0 }), getters: { double: (state) => state.n * 2, }, })
To access other getters, you must still use the syntax that uses
this
but it is now necessary to explicitly type the getter return type. The same limitation exists in Vue for computed properties and it's a known limitation in TypeScript:defineStore({ state: () => ({ n: 0 }), getters: { double: (state) => state.n * 2, // the `: number` is necessary when accessing `this` inside of // a getter doublePlusOne(state): number { return this.double + 1 }, }, })
For more information, refer to the updated documentation for getters.
-
plugins: To improve the plugin api capabilities,
pinia.use()
now receives a context object instead of justapp
:// replace pinia.use((app) => {}) // with pinia.use(({ app }) => {})
Check the new documentation for Plugins!
2.0.0-alpha.13 (2021-04-10)
- subscribe: remove subscription when unmounted (10e1c30)
- types: fail on async patch (c254a8a)
2.0.0-alpha.12 (2021-04-09)
2.0.0-alpha.11 (2021-04-09)
- types: enable autocomplete in object (b299ff0)
- mapWritableState (3218bdb)
- mapState: accept functions (e2f2b92)
- mapStores: allow custom suffix (c957fb9)
- types: allow extending mapStores suffix (f14c7b9)
- add mapActions (b5d27fb)
- add mapStores (d3d9327)
- mapState with array (0e05811)
- mapState with object (06805db)
- types: expose DefineStoreOptions (c727070)
2.0.0-alpha.10 (2021-04-01)
2.0.0-alpha.9 (2021-03-31)
- types: pass custom properties to stores (d26df6e)
2.0.0-alpha.8 (2021-03-29)
- devtools: logo and titles (0963fd0)
2.0.0-alpha.7 (2021-01-21)
2.0.0-alpha.6 (2020-12-31)
setActiveReq()
has been renamed tosetActivePinia()
. And now receives the application's pinia as the first parameter instead of an arbitrary object (like a Node http request). This affects particularly users doing SSR but also enables them to write universal code.
2.0.0-alpha.5 (2020-10-09)
- all store properties (
id
,state
,patch
,subscribe
, andreset
) are now prefixed with$
to allow properties defined with the same type and avoid types breaking. Tip: you can refactor your whole codebase with F2 (or right-click + Refactor) on each of the store's properties
2.0.0-alpha.4 (2020-09-29)
- detach stores creation from currentInstance (dc31736)
2.0.0-alpha.3 (2020-09-28)
- rename createStore to defineStore (a9ad160)
- renamed
createStore
todefineStore
.createStore
will be marked as deprecated during the alpha releases and then be dropped.
2.0.0-alpha.2 (2020-09-25)
- add devtools support (849cb3f)
2.0.0-alpha.1 (2020-09-22)
- access the state and getters through
this
(#190) (6df18ef) - merge all properties under this (d5eaac1)
state
properties no longer need to be accessed throughstore.state
getters
no longer receive parameters, access the store instance viathis
: directly callthis.myState
to read state and other getters. Update 2021-04-02:getters
receive the state again as the first parameter