diff --git a/lib/templates/plugin.client.js b/lib/templates/plugin.client.js index 5bd9ce1b..206f0c31 100644 --- a/lib/templates/plugin.client.js +++ b/lib/templates/plugin.client.js @@ -9,8 +9,17 @@ const cookieOptions = JSON.parse('<%= JSON.stringify(options.cookie.options) %>' const colorMode = window['<%= options.globalName %>'] export default function (ctx, inject) { + let data = ctx.nuxtState.colorMode + // For SPA mode or fallback + if (!data) { + data = { + preference: colorMode.preference, + value: colorMode.value, + unknown: colorMode.preference === 'system' + } + } const $colorMode = new Vue({ - data: ctx.nuxtState.colorMode, + data, watch: { preference (preference) { if (preference === 'system') {