# Error (window is not defined) when using NextJS v14

**URL:** <https://forum.openreplay.com/t/error-window-is-not-defined-when-using-nextjs-v14/49>\
**Category:** Issues & Bugs\
**Tags:** nextjs\
**Created:** [March 20, 2024, 8:29pm UTC](https://forum.openreplay.com/t/error-window-is-not-defined-when-using-nextjs-v14/49 "2024-03-20T20:29:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dave-the-developer](https://avatars.discourse-cdn.com/v4/letter/d/7ab992/32.png) [@dave-the-developer](https://forum.openreplay.com/u/dave-the-developer)\
**Post date:** [March 20, 2024, 8:29pm UTC](https://forum.openreplay.com/t/error-window-is-not-defined-when-using-nextjs-v14/49/1 "2024-03-20T20:29:23Z")

</div>

Hello everybody!  
I have a problem in a NextJS v14+ App Router application.  
I’m following this document: [Using OpenReplay with Next.js - OpenReplay Documentation](https://docs.openreplay.com/en/using-or/next/)

I have the following error:  
ReferenceError: window is not defined

 ![Captura de tela de 2024-03-19 14-49-44](https://europe1.discourse-cdn.com/flex006/uploads/openreplay/original/1X/c9a3689882069ddcb2883289a1bb62dce06b289c.png)

---

<div class="post-metadata">

**Author:** ![mehdi](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.openreplay.com/mehdi/32/50_2.png) [@mehdi](https://forum.openreplay.com/u/mehdi)\
**Post date:** [March 20, 2024, 8:33pm UTC](https://forum.openreplay.com/t/error-window-is-not-defined-when-using-nextjs-v14/49/2 "2024-03-20T20:33:42Z")

</div>

The issue happens because you’re running browser code in server env. Convert the component into “use client” or use dynamic imports.

---

<div class="post-metadata">

**Author:** ![asexsela](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.openreplay.com/asexsela/32/73_2.png) [@asexsela](https://forum.openreplay.com/u/asexsela)\
**Post date:** [January 30, 2025, 12:35pm UTC](https://forum.openreplay.com/t/error-window-is-not-defined-when-using-nextjs-v14/49/3 "2025-01-30T12:35:26Z")

</div>

> [@mehdi](#):
>
> or use dynamic i

You can use `globalThis` property

[Documentation](https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/globalThis)
