In my nuxt.js application, I have a script that imports an NPM package which is only compatible with browser contexts (it references document
, location
, window
, etc.)
Is there a way to exclude this from SSR?
import thing from "@vendor/thing"; // causes `document not defined` error
export default showThing(){
if (process.client) {
thing();
}
}
I can use the method with process.client
but this file is still imported in my components.