Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 88x 88x 88x 88x 88x | import { io, type Socket, type ManagerOptions, type SocketOptions } from 'socket.io-client'
/**
* The path where the Socket.IO server is mounted.
* All client connections MUST use this path.
*/
const SOCKET_PATH = '/api/socket'
/**
* Create a Socket.IO client connection with the correct server path.
*
* Always use this instead of calling `io()` directly — the server mounts
* at `/api/socket`, not the default `/socket.io/`. Calling `io()` without
* the path will silently fail to connect.
*/
export function createSocket(opts?: Partial<ManagerOptions & SocketOptions>): Socket {
return io({
path: SOCKET_PATH,
...opts,
})
}
|