// To run this example: // // bun --hot bun-hot-websockets.js // const css = ([inner]) => { return inner; }; const styles = css` #bun { margin: 0 auto; margin-top: 200px; object-fit: cover; } html, body { margin: 0; padding: 0; } body { background: #f1239f; font-family: "Inter", sans-serif; display: flex; align-items: center; justify-content: center; align-content: center; color: white; } h1 { padding: 0; text-align: center; font-size: 3rem; -webkit-text-stroke: 2px black; } * { box-sizing: border-box; } `; Bun.serve({ websocket: { message(ws, msg) { ws.send(styles); }, }, fetch(req, server) { if (req.url.endsWith("/hot")) { if (server.upgrade(req)) return new Response("", { status: 101, }); } return new Response( `