# Uppy nextjs "document is not defined", how to make it work?

**URL:** <https://community.transloadit.com/t/uppy-nextjs-document-is-not-defined-how-to-make-it-work/16979>\
**Category:** Uppy\
**Created:** [January 25, 2024, 2:56pm UTC](https://community.transloadit.com/t/uppy-nextjs-document-is-not-defined-how-to-make-it-work/16979 "2024-01-25T14:56:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![florianmartens](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.transloadit.com/florianmartens/32/1022_2.png) [@florianmartens](https://community.transloadit.com/u/florianmartens)\
**Post date:** [January 25, 2024, 2:56pm UTC](https://community.transloadit.com/t/uppy-nextjs-document-is-not-defined-how-to-make-it-work/16979/1 "2024-01-25T14:56:39Z")

</div>

I’m trying to make uppy work in nextjs. Nextjs tries to render every page on the server first and will also evaluate and create bundles on the server. Uppy uses native browser APIs such as `document` and `window` which aren’t defined on the server.

Is there a way to make it work regardless?

Here’s a sandbox illustrating the problem: [Next.js Starter - StackBlitz](https://stackblitz.com/edit/stackblitz-starters-kjtfxx?file=app%2Fpage.tsx)

---

<div class="post-metadata">

**Author:** ![Merlijn](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.transloadit.com/merlijn/32/1382_2.png) [@Merlijn](https://community.transloadit.com/u/Merlijn)\
**Post date:** [January 26, 2024, 9:07am UTC](https://community.transloadit.com/t/uppy-nextjs-document-is-not-defined-how-to-make-it-work/16979/2 "2024-01-26T09:07:35Z")

</div>

Hi, this a Next.js problem, not one for Uppy, as there are many client-side only libraries and it’s up to the implementer in the framework to handle that correctly.

In your case this will probably solve it:

> **[Optimizing: Lazy Loading | Next.js](https://nextjs.org/docs/pages/building-your-application/optimizing/lazy-loading#with-no-ssr)**
>
> Lazy load imported libraries and React Components to improve your application's loading performance.
