Why am I getting ReferenceError: self is not defined when I import a client-side library?
The error occurs because the library requires Web APIs to work, which are not available when Next.js pre-renders the page on the server-side. In your case, xterm tries to access the window object which is not present on the server. To fix it, you have to dynamically import xterm so it only gets loaded on … Read more