#Window is not defined

17 messages · Page 1 of 1 (latest)

lunar crown
#

Hey there,

After being able to develop my launcher with Tauri, I am not encountering an error that prevents me from building it. I am always getting this error: https://hastebin.skyra.pw/licahotume.php when trying to build my app. I am not aware of any imports in server components I may have done, which is why I am so confused about this error.

tight compass
#

Welcome to the wonderful world of SSR-first frameworks like nextjs :/

if you import invoke make sure to import it from @tauri-apps/api/tauri and not @tauri-apps/api.

imports from the window, path, fs, and os modules have to be done via the await import() syntax to make sure it's only imported on the client side. (may have misremembered the modules, just whatever throws the errors)

lunar crown
lunar crown
tight compass
#

it's the appWindow import

#

replace that with await import in the function itself and nextjs should stop complaining

lunar crown
#

What's wrong about it? Shouldnt the client side component have access to the appWindow?

tight compass
#

even if you annotate it with use client nextjs will still evaluate the imports on the server when building

lunar crown
#

Wow that's...

#

Annoying to say the least

tight compass
#

in most cases this is fine, but the modules i mention export variables that use the window or navigator which is evaluated on import, not when you use it

#

we removed all the variables in v2 for that reason

lunar crown
#

I wish Server actions were possible with Tauri

#

But I get that's not possible

#

Because of the static export