vue-qrcode-reader
vue-qrcode-reader copied to clipboard
Fix Import to work with SSR
Describe the bug Every time I load this module on an ssr page with nuxt. My application throws an error as it is looking for browser globals. Please check for these globals so that it doesn't crash with an SSR load!
To Reproduce Create a nuxt with SSR enable and load the qrcode-stream element.
Screenshots
Desktop (please complete the following information): ALL
Smartphone (please complete the following information): ALL
It's difficult to eliminate these SSR errors. The library relies heavily on Web APIs. A workaround might be something like:
<template>
<client-only>
<qrcode-stream />
</client-only>
</template>
<script>
export default {
components: {
'qrcode-stream': async () => {
const { QrcodeStream } = await import("vue-qrcode-reader")
return QrcodeStream
}
}
}
</script>
This issue has been marked as stale. If there is no further activity it will be closed.