Using react-unity-webgl with Next JS #291
-
Hi, I tried to use inside a useEffect block but I got weird errors. Can you tell me the right way to use your library in a React/Next JS project? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 6 replies
-
Hi! Thanks for your message. I checked it out and noticed there is a scenario where this error can occur. I'll deploy a hot fix right away! I'll keep you posted on this thread. |
Beta Was this translation helpful? Give feedback.
-
Now I got another error in the console use-unity-loader.js?b082:35 GET http://localhost:3000/Build/deploy.loader.js net::ERR_ABORTED 404 (Not Found) But I think is my fault... let me double check a couple of things |
Beta Was this translation helpful? Give feedback.
-
Well... forget about it... this stuff are errors related to how Next JS works. I simply moved all files to the 'public' folder of Next JS and disble compression at unity. IT WORKS!!!!!! THANKS!!!! |
Beta Was this translation helpful? Give feedback.
-
So, let me explain the process carefully to allow others use your lib with NEXT JS
DONE!!! Some other advises...
` const [isLoaded, setIsLoaded] = useState(false); useEffect(function () { |
Beta Was this translation helpful? Give feedback.
So, let me explain the process carefully to allow others use your lib with NEXT JS
const unityContext = new UnityContext({
loaderUrl: "Build/deploy.loader.js",
dataUrl: "Build/deploy.data",
frameworkUrl: "Build/deploy.framework.js",
codeUrl: "Build/deploy.wasm",
});
DONE!!!
Some other advises...