I'm using the appwrite client side sdk for my NextJS project. While importing the appwrite utility functions in the middleware.js file, I'm running into the error ''window is not defined". My understanding is that in next.js, the middleware runs on the server side and then on the client. I tried to conditionally import the module only middleware runs on the client side but its not working. Can someone help here ?
TL;DR
Developers are encountering a "window is not defined" error when using the appwrite client-side SDK in a NextJS middleware file. The issue arises because NextJS middleware runs both on the server and client side. To address this, one solution is to conditionally import the module for client-side execution only.