Closed fsyntax closed 11 months ago
Hi @fsyntax this is because you are doing SSR with Nuxt, so you need to wrap your components with
<ClientOnly />
I suggest you to use the official module that does this for you https://tresjs.org/guide/nuxt.html
Well as far as I can tell I did. Have you had a look at the reproduction?
@fsyntax Hi, I encountered the same problem, and after trying many times, I found that if I use the Suspense wrapper code directly in app.vue or /pages/xxx.vue, the error will occur!
You need to encapsulate it into a component and use
Describe the bug
Using the TresJS nuxt module on Nuxt 3.8.1. When trying to use
useTexture
directly in a script setup, I'm getting a "500 - document is not defined" error upon loading the page!So this:
Is throwing the error when directly calling the correspondig route.
What is working is wrapping
useTexture
inside a onBeforeMount hook:I've provided a very basic reproduction below!
Reproduction
https://stackblitz.com/edit/nuxt-starter-fn4snl?file=app.vue
Steps to reproduce
Simply navigate to the reproduction link
System Info
Used Package Manager
pnpm
Code of Conduct