tauri: @tauri-apps/api@1.2.0, "__TAURI_METADATA__" in window cause ReferenceError: window is not defined
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)
ssr = falsedisables dev SSR. Either way, let’s not discuss framework specifics in this issueSame here in NextJs. Even wrapping components in
dynamicdoesn’t solve the issue, I need to import any@tauri-appswithawait importinside 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.