I have implemented a custom context menu with Nextjs and https://reachtokish.github.io/rctx-contextmenu/ it works while implementing, but when I reload the browser or leave the page and come back the page gets an error
Server Error
ReferenceError: document is not defined
This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
we
file:///Users/xxxx/Desktop/nextjs/testnext/node_modules/rctx-contextmenu/dist/index.js (15:24583)
import { ContextMenuTrigger, ContextMenu, ContextMenuItem } from 'rctx-contextmenu';
export default function Test() {
return(
<>
<div className="w-5/6 m-auto">
<h1>Test</h1>
<div className="w-1/2">
<ContextMenuTrigger id="my-context-menu-1">
<img src="/assets/platzhalter_womo.png"></img>
</ContextMenuTrigger>
</div>
</div>
<ContextMenu id="my-context-menu-1">
<ContextMenuItem><img src="/assets/haken.svg" alt="Ico"/> als Shopbild</ContextMenuItem>
<ContextMenuItem>als Headerbild</ContextMenuItem>
<ContextMenuItem>Löschen</ContextMenuItem>
</ContextMenu>
</>
)
}
I can also remove <Contextmenu/> and reload, then the page loads, add it back save, the page hot reloads and it works.. it just stops working once I hard reload the page in the browser