Nuxt 3 JWT authentication using $fetch and Pinia

i’m gonna share everything, even the parts you marked as done, for completeness sake. Firstly, you will need something to generate a JWT in the backend, you can do that plainly without any packages, but i would recommend this package for that. Also i’ll use objection.js for querying the database, should be easy to understand … Read more

How to set the type for the state object in pinia?

The type of this.previousPieceSelected is inferred from the initial state, and it’s currently initialized to undefined, so it thus has a type of undefined (meaning it can only be assigned a value of undefined). Use type assertion on the initial undefined value (i.e., the as keyword plus the desired type of Piece | undefined). Also … Read more

Why Pinia vs Vuex for Vue 3? [closed]

In short, Pinia’s API is much simpler and intuitive. It makes using stores a breeze, even for junior devs. It brings the benefits of Composition API, but has a structure which greatly resembles the Options API, which you’re probably familiar with: has a reactive state, equivalent of data function in Options API has getters, equivalent … Read more

vue component doesn’t update after state changes in pinia store

storeToRefs() You need to use storeToRefs() to extract properties from the store while keeping those properties reactive. import { storeToRefs } from ‘pinia’ const themeStore = useThemeStore(); const { isDark } = storeToRefs(themeStore); Computed property Thanks to @Fennec for suggesting the computed way of getting reactive state. Although I don’t recommend this method since there … Read more