Next.js Discord

Discord Forum

Errors with deploy

Unanswered
Bahama Swallow posted this in #help-forum
Open in Discord
Bahama SwallowOP
I can't send my personal website to deploy on vercel without errors, I fix one, but more always appear. These are the ones of the moment. If anyone can help me, thank you very much.

8 Replies

you can mostly likely reproduce these errors in your machine with next build so you don't need to wait until you push to vercel to check if your apps build correctly. regarding the error it's probably because you are trying to read document during the pre-rendering step which runs in the server so this variable is not defined, you can only use this variable inside an useEffect or in a code path that doesn't run in the server
Bahama SwallowOP
Got it bro, I'll test it on my machine then. Regarding the error, I'll look for it in my application later and let you know if I can't solve it. Thank you very much.
Bahama SwallowOP
bro, i don't understand this error, don't exist 'document' in this file, i am confuse hahahhaha thank you very much
@Bahama Swallow bro, i don't understand this error, don't exist 'document' in this file, i am confuse hahahhaha thank you very much
you call new ClipboardJS('.btn') outside event handlers/useEffect. this ClipboardJS requires access to the DOM which it doesn't have
add it inside useEffect
useEffect(() => {
  new ClipboardJS('.btn')
}, [])
Bahama SwallowOP
ok bro, thanks
Bahama SwallowOP
it's worked, sorry for not say