"navigator is not defined" in Next.js #5271
Answered
by
FabianLars
laijackylai
asked this question in
Q&A
-
Beta Was this translation helpful? Give feedback.
Answered by
FabianLars
Sep 23, 2022
Replies: 2 comments 1 reply
-
This is caused by nextjs' SSR nature and an unfortunate design choice of the const openAboutPage = async () => {
const window = await import('@tauri-apps/api/window')
const webview = new window.WebviewWindow('about_window', {
title: 'About',
width: 400,
height: 200,
url: '/about'
})
webview.once('tauri://created', () => {})
webview.once('tauri://error', (e: any) => {
console.error(e)
})
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
FabianLars
-
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is caused by nextjs' SSR nature and an unfortunate design choice of the
window
module. The workaround is to dynamically import the window module instead so that the code that requires the navigator runs on the client side (btw all tauri apis only work on the client side, but iirc only the window and path modules need dynamic imports).