[{"data":1,"prerenderedAt":650},["ShallowReactive",2],{"navigation":3,"/guide/message":56,"/guide/message-surround":646},[4,30],{"title":5,"_path":6,"children":7,"icon":9},"Getting Started","/guide",[8,10,14,18,22,26],{"title":5,"_path":6,"icon":9},"ph:book-open-duotone",{"title":11,"_path":12,"icon":13},"Hooks","/guide/hooks","material-symbols-light:data-object",{"title":15,"_path":16,"icon":17},"Peer","/guide/peer","mynaui:api",{"title":19,"_path":20,"icon":21},"Message","/guide/message","solar:letter-line-duotone",{"title":23,"_path":24,"icon":25},"Pub / Sub","/guide/pubsub","simple-icons:googlepubsub",{"title":27,"_path":28,"icon":29},"Resolver API","/guide/resolver","tabler:route",{"title":31,"_path":32,"children":33,"icon":35},"Adapters","/adapters",[34,36,40,44,48,52],{"title":31,"_path":32,"icon":35},"emojione-monotone:electric-plug",{"title":37,"_path":38,"icon":39},"Bun","/adapters/bun","simple-icons:bun",{"title":41,"_path":42,"icon":43},"Cloudflare","/adapters/cloudflare","devicon-plain:cloudflareworkers",{"title":45,"_path":46,"icon":47},"Deno","/adapters/deno","teenyicons:deno-solid",{"title":49,"_path":50,"icon":51},"Node.js","/adapters/node","akar-icons:node-fill",{"title":53,"_path":54,"icon":55},"SSE","/adapters/sse","clarity:two-way-arrows-line",{"_path":20,"_dir":57,"_draft":58,"_partial":58,"_locale":59,"title":19,"description":59,"icon":21,"body":60,"_type":640,"_id":641,"_source":642,"_file":643,"_stem":644,"_extension":645},"guide",false,"",{"type":61,"children":62,"toc":621},"root",[63,88,111,118,129,143,153,166,176,188,198,203,213,230,236,246,251,256,266,284,385,395,413,418,428,457,461,471,487,491,497,615],{"type":64,"tag":65,"props":66,"children":67},"element","p",{},[68,71,78,80,86],{"type":69,"value":70},"text","On ",{"type":64,"tag":72,"props":73,"children":75},"code",{"className":74},[],[76],{"type":69,"value":77},"message",{"type":69,"value":79}," ",{"type":64,"tag":81,"props":82,"children":83},"a",{"href":12},[84],{"type":69,"value":85},"hook",{"type":69,"value":87},", you receive a message object containing data from the client.",{"type":64,"tag":89,"props":90,"children":91},"note",{},[92],{"type":64,"tag":65,"props":93,"children":94},{},[95,97,109],{"type":69,"value":96},"\nMessage object is API-compatible with standard Websocket ",{"type":64,"tag":81,"props":98,"children":102},{"href":99,"rel":100},"https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/message_event",[101],"nofollow",[103],{"type":64,"tag":72,"props":104,"children":106},{"className":105},[],[107],{"type":69,"value":108},"MessageEvent",{"type":69,"value":110}," with convenient superset of utils.",{"type":64,"tag":112,"props":113,"children":115},"h2",{"id":114},"instance-properties",[116],{"type":69,"value":117},"Instance properties",{"type":64,"tag":119,"props":120,"children":122},"h3",{"id":121},"messageid",[123],{"type":64,"tag":72,"props":124,"children":126},{"className":125},[],[127],{"type":69,"value":128},"message.id",{"type":64,"tag":65,"props":130,"children":131},{},[132,134,141],{"type":69,"value":133},"Unique random identifier (",{"type":64,"tag":81,"props":135,"children":138},{"href":136,"rel":137},"https://developer.mozilla.org/en-US/docs/Glossary/UUID",[101],[139],{"type":69,"value":140},"uuid v4",{"type":69,"value":142},") for the message.",{"type":64,"tag":119,"props":144,"children":146},{"id":145},"messageevent",[147],{"type":64,"tag":72,"props":148,"children":150},{"className":149},[],[151],{"type":69,"value":152},"message.event",{"type":64,"tag":65,"props":154,"children":155},{},[156,158,164],{"type":69,"value":157},"Access to the original ",{"type":64,"tag":81,"props":159,"children":161},{"href":99,"rel":160},[101],[162],{"type":69,"value":163},"message event",{"type":69,"value":165}," if available.",{"type":64,"tag":119,"props":167,"children":169},{"id":168},"messagepeer",[170],{"type":64,"tag":72,"props":171,"children":173},{"className":172},[],[174],{"type":69,"value":175},"message.peer",{"type":64,"tag":65,"props":177,"children":178},{},[179,181,186],{"type":69,"value":180},"Access to the ",{"type":64,"tag":81,"props":182,"children":183},{"href":16},[184],{"type":69,"value":185},"peer instance",{"type":69,"value":187}," that emitted the message.",{"type":64,"tag":119,"props":189,"children":191},{"id":190},"messagerawdata",[192],{"type":64,"tag":72,"props":193,"children":195},{"className":194},[],[196],{"type":69,"value":197},"message.rawData",{"type":64,"tag":65,"props":199,"children":200},{},[201],{"type":69,"value":202},"Raw message data (can be of any type).",{"type":64,"tag":119,"props":204,"children":206},{"id":205},"messagedata",[207],{"type":64,"tag":72,"props":208,"children":210},{"className":209},[],[211],{"type":69,"value":212},"message.data",{"type":64,"tag":65,"props":214,"children":215},{},[216,218,228],{"type":69,"value":217},"Message data (value varies based on ",{"type":64,"tag":81,"props":219,"children":221},{"href":220},"/guide/peer#peerbinarytype",[222],{"type":64,"tag":72,"props":223,"children":225},{"className":224},[],[226],{"type":69,"value":227},"peer.binaryType",{"type":69,"value":229},").",{"type":64,"tag":112,"props":231,"children":233},{"id":232},"instance-methods",[234],{"type":69,"value":235},"Instance methods",{"type":64,"tag":119,"props":237,"children":239},{"id":238},"messagetext",[240],{"type":64,"tag":72,"props":241,"children":243},{"className":242},[],[244],{"type":69,"value":245},"message.text()",{"type":64,"tag":65,"props":247,"children":248},{},[249],{"type":69,"value":250},"Get stringified text version of the message.",{"type":64,"tag":65,"props":252,"children":253},{},[254],{"type":69,"value":255},"If raw data is in any other format, it will be automatically converted or decoded.",{"type":64,"tag":119,"props":257,"children":259},{"id":258},"messagejson",[260],{"type":64,"tag":72,"props":261,"children":263},{"className":262},[],[264],{"type":69,"value":265},"message.json()",{"type":64,"tag":65,"props":267,"children":268},{},[269,271,282],{"type":69,"value":270},"Get parsed version of the message text with ",{"type":64,"tag":81,"props":272,"children":275},{"href":273,"rel":274},"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse",[101],[276],{"type":64,"tag":72,"props":277,"children":279},{"className":278},[],[280],{"type":69,"value":281},"JSON.parse()",{"type":69,"value":283},".",{"type":64,"tag":285,"props":286,"children":287},"tip",{},[288,306,311],{"type":64,"tag":65,"props":289,"children":290},{},[291,293,304],{"type":69,"value":292},"\nYou can optionally use ",{"type":64,"tag":81,"props":294,"children":297},{"href":295,"rel":296},"https://github.com/unjs/destr",[101],[298],{"type":64,"tag":72,"props":299,"children":301},{"className":300},[],[302],{"type":69,"value":303},"unjs/destr",{"type":69,"value":305}," to safely parse the message object.",{"type":64,"tag":65,"props":307,"children":308},{},[309],{"type":69,"value":310},"It does not throw an error if the input is not valid JSON but falls back to text and also removes any fields that could potentially cause prototype pollution vulnerabilities.",{"type":64,"tag":312,"props":313,"children":317},"pre",{"className":314,"code":315,"language":316,"meta":59,"style":59},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","const data = destr(await message.text());\n","ts",[318],{"type":64,"tag":72,"props":319,"children":320},{"__ignoreMap":59},[321],{"type":64,"tag":322,"props":323,"children":326},"span",{"class":324,"line":325},"line",1,[327,333,339,345,351,356,362,367,371,375,380],{"type":64,"tag":322,"props":328,"children":330},{"style":329},"--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA",[331],{"type":69,"value":332},"const",{"type":64,"tag":322,"props":334,"children":336},{"style":335},"--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8",[337],{"type":69,"value":338}," data ",{"type":64,"tag":322,"props":340,"children":342},{"style":341},"--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF",[343],{"type":69,"value":344},"=",{"type":64,"tag":322,"props":346,"children":348},{"style":347},"--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF",[349],{"type":69,"value":350}," destr",{"type":64,"tag":322,"props":352,"children":353},{"style":335},[354],{"type":69,"value":355},"(",{"type":64,"tag":322,"props":357,"children":359},{"style":358},"--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic",[360],{"type":69,"value":361},"await",{"type":64,"tag":322,"props":363,"children":364},{"style":335},[365],{"type":69,"value":366}," message",{"type":64,"tag":322,"props":368,"children":369},{"style":341},[370],{"type":69,"value":283},{"type":64,"tag":322,"props":372,"children":373},{"style":347},[374],{"type":69,"value":69},{"type":64,"tag":322,"props":376,"children":377},{"style":335},[378],{"type":69,"value":379},"())",{"type":64,"tag":322,"props":381,"children":382},{"style":341},[383],{"type":69,"value":384},";\n",{"type":64,"tag":119,"props":386,"children":388},{"id":387},"messageuint8array",[389],{"type":64,"tag":72,"props":390,"children":392},{"className":391},[],[393],{"type":69,"value":394},"message.uint8Array()",{"type":64,"tag":65,"props":396,"children":397},{},[398,400,411],{"type":69,"value":399},"Get data as ",{"type":64,"tag":81,"props":401,"children":404},{"href":402,"rel":403},"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array",[101],[405],{"type":64,"tag":72,"props":406,"children":408},{"className":407},[],[409],{"type":69,"value":410},"Uint8Array",{"type":69,"value":412}," value.",{"type":64,"tag":65,"props":414,"children":415},{},[416],{"type":69,"value":417},"If raw data is in any other format or string, it will be automatically converted or encoded.",{"type":64,"tag":119,"props":419,"children":421},{"id":420},"messagearraybuffer",[422],{"type":64,"tag":72,"props":423,"children":425},{"className":424},[],[426],{"type":69,"value":427},"message.arrayBuffer()",{"type":64,"tag":65,"props":429,"children":430},{},[431,432,443,445,456],{"type":69,"value":399},{"type":64,"tag":81,"props":433,"children":436},{"href":434,"rel":435},"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer",[101],[437],{"type":64,"tag":72,"props":438,"children":440},{"className":439},[],[441],{"type":69,"value":442},"ArrayBuffer",{"type":69,"value":444}," or ",{"type":64,"tag":81,"props":446,"children":449},{"href":447,"rel":448},"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer",[101],[450],{"type":64,"tag":72,"props":451,"children":453},{"className":452},[],[454],{"type":69,"value":455},"SharedArrayBuffer",{"type":69,"value":412},{"type":64,"tag":65,"props":458,"children":459},{},[460],{"type":69,"value":417},{"type":64,"tag":119,"props":462,"children":464},{"id":463},"messageblob",[465],{"type":64,"tag":72,"props":466,"children":468},{"className":467},[],[469],{"type":69,"value":470},"message.blob()",{"type":64,"tag":65,"props":472,"children":473},{},[474,475,486],{"type":69,"value":399},{"type":64,"tag":81,"props":476,"children":479},{"href":477,"rel":478},"https://developer.mozilla.org/en-US/docs/Web/API/Blob",[101],[480],{"type":64,"tag":72,"props":481,"children":483},{"className":482},[],[484],{"type":69,"value":485},"Blob",{"type":69,"value":412},{"type":64,"tag":65,"props":488,"children":489},{},[490],{"type":69,"value":417},{"type":64,"tag":112,"props":492,"children":494},{"id":493},"adapter-support",[495],{"type":69,"value":496},"Adapter support",{"type":64,"tag":498,"props":499,"children":500},"table",{},[501,568],{"type":64,"tag":502,"props":503,"children":504},"thead",{},[505],{"type":64,"tag":506,"props":507,"children":508},"tr",{},[509,513,520,527,536,543,551,560],{"type":64,"tag":510,"props":511,"children":512},"th",{},[],{"type":64,"tag":510,"props":514,"children":515},{},[516],{"type":64,"tag":81,"props":517,"children":518},{"href":38},[519],{"type":69,"value":37},{"type":64,"tag":510,"props":521,"children":522},{},[523],{"type":64,"tag":81,"props":524,"children":525},{"href":42},[526],{"type":69,"value":41},{"type":64,"tag":510,"props":528,"children":529},{},[530],{"type":64,"tag":81,"props":531,"children":533},{"href":532},"/adapters/cloudflare#durable-objects",[534],{"type":69,"value":535},"Cloudflare (durable)",{"type":64,"tag":510,"props":537,"children":538},{},[539],{"type":64,"tag":81,"props":540,"children":541},{"href":46},[542],{"type":69,"value":45},{"type":64,"tag":510,"props":544,"children":545},{},[546],{"type":64,"tag":81,"props":547,"children":548},{"href":50},[549],{"type":69,"value":550},"Node (ws)",{"type":64,"tag":510,"props":552,"children":553},{},[554],{"type":64,"tag":81,"props":555,"children":557},{"href":556},"/adapters/node#uwebsockets",[558],{"type":69,"value":559},"Node (μWebSockets)",{"type":64,"tag":510,"props":561,"children":562},{},[563],{"type":64,"tag":81,"props":564,"children":566},{"href":565},"adapters/sse",[567],{"type":69,"value":53},{"type":64,"tag":569,"props":570,"children":571},"tbody",{},[572],{"type":64,"tag":506,"props":573,"children":574},{},[575,585,590,595,599,603,607,611],{"type":64,"tag":576,"props":577,"children":578},"td",{},[579],{"type":64,"tag":72,"props":580,"children":582},{"className":581},[],[583],{"type":69,"value":584},"event",{"type":64,"tag":576,"props":586,"children":587},{},[588],{"type":69,"value":589},"⨉",{"type":64,"tag":576,"props":591,"children":592},{},[593],{"type":69,"value":594},"✓",{"type":64,"tag":576,"props":596,"children":597},{},[598],{"type":69,"value":589},{"type":64,"tag":576,"props":600,"children":601},{},[602],{"type":69,"value":594},{"type":64,"tag":576,"props":604,"children":605},{},[606],{"type":69,"value":589},{"type":64,"tag":576,"props":608,"children":609},{},[610],{"type":69,"value":589},{"type":64,"tag":576,"props":612,"children":613},{},[614],{"type":69,"value":589},{"type":64,"tag":616,"props":617,"children":618},"style",{},[619],{"type":69,"value":620},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":59,"searchDepth":622,"depth":622,"links":623},2,[624,632,639],{"id":114,"depth":622,"text":117,"children":625},[626,628,629,630,631],{"id":121,"depth":627,"text":128},3,{"id":145,"depth":627,"text":152},{"id":168,"depth":627,"text":175},{"id":190,"depth":627,"text":197},{"id":205,"depth":627,"text":212},{"id":232,"depth":622,"text":235,"children":633},[634,635,636,637,638],{"id":238,"depth":627,"text":245},{"id":258,"depth":627,"text":265},{"id":387,"depth":627,"text":394},{"id":420,"depth":627,"text":427},{"id":463,"depth":627,"text":470},{"id":493,"depth":622,"text":496},"markdown","content:1.guide:4.message.md","content","1.guide/4.message.md","1.guide/4.message","md",[647,649],{"_path":16,"title":15,"description":648},"Peer object allows easily interacting with connected clients.",{"_path":24,"title":23,"description":59},1747776031617]