Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save james2doyle/b8d1723778691055c87d627dbba39f03 to your computer and use it in GitHub Desktop.
Save james2doyle/b8d1723778691055c87d627dbba39f03 to your computer and use it in GitHub Desktop.
Fix issue with external library that calls window in Nuxt/Vue when being server rendered by dynamically swapping it in the client
<template>
<component :is="component" />
</template>
<script>
export default {
name: 'DynamicComponentForBrowser',
data() {
return {
component: 'div',
};
},
async fetch() {
// the component uses `window` so we only want to
// render the real component when in the browser
this.component = (await import('@some-person/special-input')).SpecialInput;
},
fetchOnServer: false,
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment