Upgrading pinia 2 to 3
Breaking2.3.1 → 3.0.4Breaking4
BreakingUpgrade verdict
4 breaking changes.
In plain terms
- The old plugin type name is gone, so rename it to the new one in your code.
- You can no longer pass an object with an id to defineStore; pass the id string directly.
- If you use TypeScript, you need version 4.5 or later to use this version of Pinia.
- Pinia is now an ES module package, but CommonJS builds are still included.
Must act Top 3 of 4 that need code or config changes
pinia publishes an official migration guide for version 3. It covers more than the release notes do.
Migration guide ↗Drops vue-demi.
Installs 11 packages in all (was 2).
Also installs @vue/devtools-kit, @vue/devtools-shared, birpc, copy-anything, hookable, mitt, perfect-debounce, rfdc, speakingurl, superjson.
Moves @vue/devtools-api 6.6.4 → 7.7.10. Your build may pick other versions.
What you must change
Breaking4
Removes PiniaStorePlugin; use PiniaPlugin instead.
PiniaStorePluginPiniaPluginRemoves the object form of defineStore with an id property; use defineStore('id') instead.
defineStoreRequires TypeScript 4.5 or newer because Pinia now uses the native Awaited type.
AwaitedPublishes Pinia as a type: module package while still providing CJS dist files.
API changes
Generated by DepDelta from published .d.ts files. Not mixed with prose notes.
- removed:
const PiniaVuePlugin: Plugin_2 - removed:
function defineStore<Id extends string, S extends StateTree = {}, G extends _GettersTree<S> = {}, A = {}>(options: DefineStoreOptions<Id, S, G, A>): StoreDefinition<Id, S, G, A> - removed:
type PiniaStorePlugin = PiniaPlugin - removed:
type _Awaited<T> = T extends null | undefined ? T : T extends object & { then(onfulfilled: infer F): any } ? F extends (value: infer V, ...args: any) => any ? _Awaited<V> : never… - changed:
property _StoreOnActionListenerContext.after: (callback: A extends Record<ActionName, _Method> ? (resolvedReturn: _Awaited<ReturnType<A[ActionName]>>) => void : () => void) => void → property _StoreOnActionListenerContext.after: (callback: A extends Record<ActionName, _Method> ? (resolvedReturn: Awaited<ReturnType<A[ActionName]>>) => void : () => void) => void