Native Websocket is not defined

Hi, i tried the native websocket like this but i got 500 > WebSocket is not defined. My IDE has no problem but nuxt has it. Then i installed this package but still same error because this package uses the native websocket
12 Replies
isakwang
isakwangβ€’7mo ago
WebSocket - Nitro
Nitro natively support a cross platform WebSocket API
𝔗i𝔯i
𝔗i𝔯iOPβ€’7mo ago
don't wont for server side, only client side
isakwang
isakwangβ€’7mo ago
not sure what you mean
isakwang
isakwangβ€’7mo ago
Alexander Lichter
YouTube
Integrating WebSockets in Nuxt and Nitro
πŸŽ‰ Nitro 2.9 was released just before Vue.js Amsterdam and brings new features such as a database layer, a task API and also WebSocket support! But how can we integrate it in a Nuxt application? This video will teach you πŸ‘Œ Key points: πŸ›  How to set up WebSockets in Nitro and in Nuxt πŸ’‘ Working from scratch to a functional application ⚠️ Hints to m...
isakwang
isakwangβ€’7mo ago
But try that
𝔗i𝔯i
𝔗i𝔯iOPβ€’7mo ago
i dont want to use it as a server, only as a client and connect with this to a server
isakwang
isakwangβ€’7mo ago
Where is your server/what service? I know supabase has an implementation in their library if you use them
𝔗i𝔯i
𝔗i𝔯iOPβ€’7mo ago
no own implementation of a websocket server written in java
Cue
Cueβ€’7mo ago
Unless you’ve disabled SSR, you’ll need to conditionally instantiate a websocket instance in the client. The WebSocket is not defined reference error is usually a clue that its execution environment is server-side.
𝔗i𝔯i
𝔗i𝔯iOPβ€’7mo ago
how can i disable this?
Cue
Cueβ€’7mo ago
ssr: false in your nuxt config
𝔗i𝔯i
𝔗i𝔯iOPβ€’7mo ago
got it, thanks worked thanks

Did you find this page helpful?