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.

19 lines (18 loc) 494 B
import destr from "destr"; import { defineNuxtPlugin, useNuxtApp } from "../nuxt.js"; export default 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, destr(state)?.state); } } catch { } } } });