Document not defined error
Answered
Canada Warbler posted this in #help-forum
Canada WarblerOP
Im using document getElementById in my function and every time I try to use it on the page I get the document is not defined error
Answered by LuisLl
document is a property of the window object, which is not available on the Server. Only client component can access the window object since it’s a browser API.
When you do:
essentially is shorter for:
When you do:
document.getElementById(“Id”);
essentially is shorter for:
window.document.getElementById(“Id”);
4 Replies
document is a property of the window object, which is not available on the Server. Only client component can access the window object since it’s a browser API.
When you do:
essentially is shorter for:
When you do:
document.getElementById(“Id”);
essentially is shorter for:
window.document.getElementById(“Id”);
Answer
Asian black bear
@Asian black bear https://nextjs-faq.com/browser-api-client-component
I need to read those to reference them when needed!