Persisting state with Server Side Rendering

A lot of our projects in the last couple of years have focused on Vue.js. We have used a number of scaffolding solutions and most recently we have had success with Nuxt.js. One thing we have struggled with however, is state management and persistence. When using a ‘universal’ approach it’s immediately clear that having state traverse between client-side and server-side isn’t that easy. There’s a great plugin that allows you to persist your state into local storage or cookies. Server-Side-Rendering (SSR) doesn’t have access to your local storage, so if you want to harness the power of SSR and state management you have to use cookies. We have been using the vuex-persistedstate plugin with great success. It works well with nuxt.js and if you create a plugin to handle your storage method, you can create custom hooks for getItem and […]