# Errors in npm

Zipy npm module is used in the client’s browser and it uses browser features to capture the Frontend errors and the DOM. While working with NextJS, one of the most common issues that users observe is ‘ReferenceError: window is not defined’.&#x20;

The above error occurs as NextJS renders code using Server-Side Rendering(SSR) to compile the code that runs on the browser. This can cause the warnings to appear in the build logs. We recommend the following ways to ensure these errors don’t appear. This will ensure Zipy code is instantiated only when the environment in which the code runs is the browser.

1\. **Approach A - Use typeof**

```html
import zipy from "zipyai";
if (typeof window !== "undefined") {
  zipy.init("APIKEY");
}
```

2\. **Approach B - Use useEffect**&#x20;

In ReactJS, the useEffect component is triggered only when the component is rendered on the screen. This will ensure Zipy is instantiated only after the component loads on the screen.

```html
import React from "react";
import zipy from "zipyai";

React.useEffect(() => {
    zipy.init("APIKEY");
});
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zipy.ai/troubleshooting/errors-in-npm.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
