Linter checks to prevent 500 errors (eg. using window.location in a non-client component)
Unanswered
Greek Shepherd posted this in #help-forum
Greek ShepherdOP
There's a class of errors that can happen in Next.js applications at the moment that I'm only able to catch at runtime, and not during development, and I'm trying to stomp down on those as much as possible.
One example is using a client property on the server, eg. using
As an example, this is not allowed, but still passes
Have folks found any good solutions to this?
One example is using a client property on the server, eg. using
window outside of useEffect on a page. When this gets server-side rendered, the window property isn't available which leads to 500 errors. I'm looking for ways to detect more of this class of errors before actually running the application, but ideally in a fairly generalized way without writing my own checks.As an example, this is not allowed, but still passes
eslint, tsc!export default function MyPage() {
const params = new URLSearchParams(window.location.search);
...Have folks found any good solutions to this?