tauri: @tauri-apps/api@1.2.0, "__TAURI_METADATA__" in window cause ReferenceError: window is not defined

https://github.com/tauri-apps/tauri/blob/50576a5e1e83978882d90aca280809da2235a8d5/tooling/api/src/window.ts#L2033

When running headless tests, this might be troublesome.

Should check typeof window !== 'undefined' first.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 4
  • Comments: 22 (5 by maintainers)

Most upvoted comments

ssr = false disables dev SSR. Either way, let’s not discuss framework specifics in this issue

Same here in NextJs. Even wrapping components in dynamic doesn’t solve the issue, I need to import any @tauri-apps with await import inside the client code completely. Even if that workaround works, it’s pretty tedious to use.

@bennekrouf window.__TAURI_METADATA__ does not exist in v2 anymore. Also, all window references that could cause a similar issue should be removed now too. Please make sure all your tauri related dependencies are updated to v2.

Just to clarify, I’m not using sveltekit, I’m using vite.js.

This was fixed in v2 by removing variables like appWindow and solely relying on functions like getCurrent(). Since this is a breaking change we can’t backport it to v1.

Until v2 hits stable you’ll have to keep using await import() or workarounds like the one posted above this message.