๐ Intuitive, type safe, light and flexible Store for Vue using the composition api with DevTools support
by vuejsTypeScript
Last 12 weeks ยท 49 commits
6 of 6 standards met
Problem Closes #1247 Plugins can add custom options through (module augmentation) and read them in the plugin callback via , but there is no way to type properties returned by the plugin from those options. only receives , , , โ the options type is never threaded into the store type, so (or any other option-derived property) can only be typed with the widest / types. Solution Add a dedicated interface intersected into , mirroring the existing pattern: The resolved options of each store flow into without any change to user-facing signatures: returns (and the setup overload passes ), and forward , and intersects . defaults to , so existing code that writes or is unaffected. The plugin from the issue then works with full typing: is updated so keeps the options type through its inference (previously the 4-parameter would have silently dropped , losing the plugin properties on mapped stores). Tests Added recreating the #1247 plugin scenario: custom / options declared through augmentation are resolved on the store instance, with and without the custom options. Full suite passes: , , and (260 tests). Notes This is type-only: no runtime changes. The earlier attempt at #3042 (closed) added a runtime field; this approach keeps everything at the type level, matching how already works.
What problem is this solving I wrote a plugin to solve #625. This is basically working, but the types of the stores defined in the new stores option in are not accessible inside . Proposed solution If the store options would be accessible inside , the actual types of the concrete stores could be accessed with . Describe alternatives you've considered _No response_
Reproduction N/A Steps to reproduce the bug There is a related issue https://github.com/vuejs/devtools/issues/672 The reproduction steps are there. Expected behavior Call immediately instead of calling it after . otherwise devtools cannot read at mounted. Actual behavior Call after someone calls Additional information _No response_
Reproduction https://stackblitz.com/edit/github-jm6ehxba?file=package.json Steps to reproduce the bug Hi ๐ After updating to @pinia/nuxt 1.0 from version 0.11 and also from pinia 3 to 4 I saw that started to fail on pre-rendered pages. The reproduction repo has: Nuxt 4.5 Pinia 4 + @pinia/nuxt 1.0 Nitro pre-rendering on "/" page To reproduce 1. Run with + 2. Run , it fails with access to undefined state 3. Downgrade to + 4. Run to see the build passing fine If you remove the prerendering from the route on everything works like in Expected behavior While running on Pinia 3, Nitro pre-rendering worked fine on Build, this is expected on Pinia 4 too Actual behavior While building a pre-rendered route using Pinia 4 the build process fails with a mention on: Additional information _No response_
Reproduction https://github.com/andreyshivas/pinia4-nitro-ssr-repro Steps to reproduce the bug Minimal Nuxt 4 app โ is the only module and no store is defined, since runs on every request regardless. Expected behavior works in a Node SSR server regardless of , as it did on Pinia 3. Actual behavior Every SSR render fails once : Pinia 4 publishes only a bundler build. contains: and the exports map is a single unconditional entry: still references the Vue compile-time flag (5 occurrences). Nitro externalises pinia for the Node server build, so the file is copied to and loaded as-is โ nothing ever substitutes the flag. Pinia 3 shipped with the flags already substituted, so the same app works on 3.0.4. This looks like an unintended packaging regression in 4. Additional information Why it only appears in production. The reference sits behind a short-circuit: Any other than makes the left operand true, so the missing global is never evaluated. A local run looks perfectly healthy and the app only fails once deployed. The reported error is misleading. Nuxt catches the failing plugin chain, hands the error to , sets and carries on rendering. 's hook then runs against a that was never provided, and only that secondary error reaches the logs: It mentions neither , nor , nor Pinia at all. Recovering the real cause required registering a custom hook. Results. Workaround. Force Pinia through the bundler so the flag gets defined: Possible fixes. Ship a Node production build again behind conditional exports, as 3.x did. Or guard the reference โ โ so an unsubstituted flag degrades instead of throwing. Environment. pinia 4.0.2, @pinia/nuxt 1.0.1, nuxt 4.5.2, vue 3.5.41, Node 24.19.0 (also reproduced on the Linux deploy that surfaced it). Verified against the published npm tarball for โ same listing and the same 5 references to the flag, so this is not an install artefact.
Repository: vuejs/pinia. Description: ๐ Intuitive, type safe, light and flexible Store for Vue using the composition api with DevTools support Stars: 14707, Forks: 1198. Primary language: TypeScript. Languages: TypeScript (76.9%), Vue (18.7%), JavaScript (2%), CSS (1.8%), HTML (0.5%). License: MIT. Homepage: https://pinia.vuejs.org Topics: composition-api, ssr, store, vue, vuex. Latest release: @pinia/nuxt@1.0.2 (2w ago). Open PRs: 10, open issues: 15. Last activity: 2w ago. Community health: 100%. Top contributors: posva, dependabot[bot], dependabot-preview[bot], renovate-bot, pi0, renovate[bot], nicodevs, danielroe, idorenyinudoh, skirtles-code and others.