I'm building a Nuxt project with TypeScript and need to access window.__NUXT__
because I want to load Algolia on SSR.
beforeMount() {
const results =
(this.$nuxt.context && this.$nuxt.context.nuxtState.algoliaState) ||
window.__NUXT__.algoliaState
this.instantsearch.hydrate(results)
// Remove the SSR state so it can't be applied again by mistake
delete this.$nuxt.context.nuxtState.algoliaState
delete window.__NUXT__.algoliaState
},
TypeScript is complaining:
Property '__NUXT__' does not exist on type 'Window & typeof globalThis'.
Is there a way to tell TypeScript about __NUXT__
?