title: How to access websocket in svelte?
body: <pre><code>&lt;script&gt;
      const socket = new WebSocket(&quot;ws://localhost:8000/chat&quot;)
      socket.addEventListener(&quot;open&quot;, ()=&gt; {
          console.log(&quot;Opened&quot;)
      })
  
  
  &lt;/script&gt;
  </code></pre>
  <p>I am trying to connect my svelte to my fastapi backend but I am getting this error using svelte kit. I get</p>
  <pre><code>WebSocket is not defined
  ReferenceError: WebSocket is not defined
  </code></pre>
  <p>error.</p>
  <p>How can I fix it ?</p>