UNPKG

nuxt

Version:

Nuxt is a free and open-source framework with an intuitive and extendable way to create type-safe, performant and production-grade full-stack web applications and websites with Vue.js.

18 lines (17 loc) 524 B
import { defineNuxtPlugin, useNuxtApp } from "../nuxt.js"; //#region src/app/plugins/restore-state.client.ts const plugin = /* @__PURE__ */ defineNuxtPlugin({ name: "nuxt:restore-state", hooks: { "app:mounted"() { const nuxtApp = useNuxtApp(); try { const state = sessionStorage.getItem("nuxt:reload:state"); if (state) { sessionStorage.removeItem("nuxt:reload:state"); Object.assign(nuxtApp.payload.state, JSON.parse(state)?.state); } } catch {} } } }); //#endregion export { plugin as default };