[{"data":1,"prerenderedAt":461},["ShallowReactive",2],{"navigation":3,"-guide-message":88,"-guide-message-surround":457},[4,51],{"title":5,"path":6,"stem":7,"children":8,"icon":10},"Guide","\u002Fguide","1.guide\u002F1.index",[9,11,16,21,26,31,36,41,46],{"title":5,"path":6,"stem":7,"icon":10},"ph:book-open-duotone",{"title":12,"path":13,"stem":14,"icon":15},"Hooks","\u002Fguide\u002Fhooks","1.guide\u002F2.hooks","material-symbols-light:data-object",{"title":17,"path":18,"stem":19,"icon":20},"Peer","\u002Fguide\u002Fpeer","1.guide\u002F3.peer","mynaui:api",{"title":22,"path":23,"stem":24,"icon":25},"Message","\u002Fguide\u002Fmessage","1.guide\u002F4.message","solar:letter-line-duotone",{"title":27,"path":28,"stem":29,"icon":30},"Pub \u002F Sub","\u002Fguide\u002Fpubsub","1.guide\u002F5.pubsub","simple-icons:googlepubsub",{"title":32,"path":33,"stem":34,"icon":35},"Sync Backplane","\u002Fguide\u002Fsync","1.guide\u002F6.sync","tabler:refresh",{"title":37,"path":38,"stem":39,"icon":40},"Resolver API","\u002Fguide\u002Fresolver","1.guide\u002F7.resolver","tabler:route",{"title":42,"path":43,"stem":44,"icon":45},"WebSocket Proxy","\u002Fguide\u002Fproxy","1.guide\u002F8.proxy","tabler:arrows-exchange",{"title":47,"path":48,"stem":49,"icon":50},"WebSocket Client","\u002Fguide\u002Fclient","1.guide\u002F9.client","tabler:plug-connected",{"title":52,"path":53,"stem":54,"children":55,"icon":57},"Adapters","\u002Fadapters","2.adapters\u002F1.index",[56,58,63,68,73,78,83],{"title":52,"path":53,"stem":54,"icon":57},"emojione-monotone:electric-plug",{"title":59,"path":60,"stem":61,"icon":62},"Bun","\u002Fadapters\u002Fbun","2.adapters\u002Fbun","simple-icons:bun",{"title":64,"path":65,"stem":66,"icon":67},"Bunny","\u002Fadapters\u002Fbunny","2.adapters\u002Fbunny","mdi:rabbit",{"title":69,"path":70,"stem":71,"icon":72},"Cloudflare","\u002Fadapters\u002Fcloudflare","2.adapters\u002Fcloudflare","devicon-plain:cloudflareworkers",{"title":74,"path":75,"stem":76,"icon":77},"Deno","\u002Fadapters\u002Fdeno","2.adapters\u002Fdeno","teenyicons:deno-solid",{"title":79,"path":80,"stem":81,"icon":82},"Node.js","\u002Fadapters\u002Fnode","2.adapters\u002Fnode","akar-icons:node-fill",{"title":84,"path":85,"stem":86,"icon":87},"SSE","\u002Fadapters\u002Fsse","2.adapters\u002Fsse","clarity:two-way-arrows-line",{"id":89,"title":22,"body":90,"description":251,"extension":452,"meta":453,"navigation":454,"path":23,"seo":455,"stem":24,"__hash__":456},"content\u002F1.guide\u002F4.message.md",{"type":91,"value":92,"toc":433,"icon":25},"minimark",[93,107,122,127,134,143,149,157,163,170,176,179,185,195,199,205,208,211,217,228,290,296,307,310,316,333,335,341,350,352,356,429],[94,95,96,97,101,102,106],"p",{},"On ",[98,99,100],"code",{},"message"," ",[103,104,105],"a",{"href":13},"hook",", you receive a message object containing data from the client.",[108,109,110],"note",{},[94,111,112,113,121],{},"\nMessage object is API-compatible with standard Websocket ",[103,114,118],{"href":115,"rel":116},"https:\u002F\u002Fdeveloper.mozilla.org\u002Fen-US\u002Fdocs\u002FWeb\u002FAPI\u002FWebSocket\u002Fmessage_event",[117],"nofollow",[98,119,120],{},"MessageEvent"," with convenient superset of utils.",[123,124,126],"h2",{"id":125},"instance-properties","Instance properties",[128,129,131],"h3",{"id":130},"messageid",[98,132,133],{},"message.id",[94,135,136,137,142],{},"Unique random identifier (",[103,138,141],{"href":139,"rel":140},"https:\u002F\u002Fdeveloper.mozilla.org\u002Fen-US\u002Fdocs\u002FGlossary\u002FUUID",[117],"uuid v4",") for the message.",[128,144,146],{"id":145},"messageevent",[98,147,148],{},"message.event",[94,150,151,152,156],{},"Access to the original ",[103,153,155],{"href":115,"rel":154},[117],"message event"," if available.",[128,158,160],{"id":159},"messagepeer",[98,161,162],{},"message.peer",[94,164,165,166,169],{},"Access to the ",[103,167,168],{"href":18},"peer instance"," that emitted the message.",[128,171,173],{"id":172},"messagerawdata",[98,174,175],{},"message.rawData",[94,177,178],{},"Raw message data (can be of any type).",[128,180,182],{"id":181},"messagedata",[98,183,184],{},"message.data",[94,186,187,188,194],{},"Message data (value varies based on ",[103,189,191],{"href":190},"\u002Fguide\u002Fpeer#peerbinarytype",[98,192,193],{},"peer.binaryType",").",[123,196,198],{"id":197},"instance-methods","Instance methods",[128,200,202],{"id":201},"messagetext",[98,203,204],{},"message.text()",[94,206,207],{},"Get stringified text version of the message.",[94,209,210],{},"If raw data is in any other format, it will be automatically converted or decoded.",[128,212,214],{"id":213},"messagejson",[98,215,216],{},"message.json()",[94,218,219,220,227],{},"Get parsed version of the message text with ",[103,221,224],{"href":222,"rel":223},"https:\u002F\u002Fdeveloper.mozilla.org\u002Fen-US\u002Fdocs\u002FWeb\u002FJavaScript\u002FReference\u002FGlobal_Objects\u002FJSON\u002Fparse",[117],[98,225,226],{},"JSON.parse()",".",[229,230,231,242,245],"tip",{},[94,232,233,234,241],{},"\nYou can optionally use ",[103,235,238],{"href":236,"rel":237},"https:\u002F\u002Fgithub.com\u002Funjs\u002Fdestr",[117],[98,239,240],{},"unjs\u002Fdestr"," to safely parse the message object.",[94,243,244],{},"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.",[246,247,252],"pre",{"className":248,"code":249,"language":250,"meta":251,"style":251},"language-ts shiki shiki-themes github-light github-dark github-dark","const data = destr(await message.text());\n","ts","",[98,253,254],{"__ignoreMap":251},[255,256,259,263,267,270,274,278,281,284,287],"span",{"class":257,"line":258},"line",1,[255,260,262],{"class":261},"so5gQ","const",[255,264,266],{"class":265},"suiK_"," data",[255,268,269],{"class":261}," =",[255,271,273],{"class":272},"shcOC"," destr",[255,275,277],{"class":276},"slsVL","(",[255,279,280],{"class":261},"await",[255,282,283],{"class":276}," message.",[255,285,286],{"class":272},"text",[255,288,289],{"class":276},"());\n",[128,291,293],{"id":292},"messageuint8array",[98,294,295],{},"message.uint8Array()",[94,297,298,299,306],{},"Get data as ",[103,300,303],{"href":301,"rel":302},"https:\u002F\u002Fdeveloper.mozilla.org\u002Fen-US\u002Fdocs\u002FWeb\u002FJavaScript\u002FReference\u002FGlobal_Objects\u002FUint8Array",[117],[98,304,305],{},"Uint8Array"," value.",[94,308,309],{},"If raw data is in any other format or string, it will be automatically converted or encoded.",[128,311,313],{"id":312},"messagearraybuffer",[98,314,315],{},"message.arrayBuffer()",[94,317,298,318,325,326,306],{},[103,319,322],{"href":320,"rel":321},"https:\u002F\u002Fdeveloper.mozilla.org\u002Fen-US\u002Fdocs\u002FWeb\u002FJavaScript\u002FReference\u002FGlobal_Objects\u002FArrayBuffer",[117],[98,323,324],{},"ArrayBuffer"," or ",[103,327,330],{"href":328,"rel":329},"https:\u002F\u002Fdeveloper.mozilla.org\u002Fen-US\u002Fdocs\u002FWeb\u002FJavaScript\u002FReference\u002FGlobal_Objects\u002FSharedArrayBuffer",[117],[98,331,332],{},"SharedArrayBuffer",[94,334,309],{},[128,336,338],{"id":337},"messageblob",[98,339,340],{},"message.blob()",[94,342,298,343,306],{},[103,344,347],{"href":345,"rel":346},"https:\u002F\u002Fdeveloper.mozilla.org\u002Fen-US\u002Fdocs\u002FWeb\u002FAPI\u002FBlob",[117],[98,348,349],{},"Blob",[94,351,309],{},[123,353,355],{"id":354},"adapter-support","Adapter support",[357,358,359,402],"table",{},[360,361,362],"thead",{},[363,364,365,368,372,376,382,386,391,397],"tr",{},[366,367],"th",{},[366,369,370],{},[103,371,59],{"href":60},[366,373,374],{},[103,375,69],{"href":70},[366,377,378],{},[103,379,381],{"href":380},"\u002Fadapters\u002Fcloudflare#durable-objects","Cloudflare (durable)",[366,383,384],{},[103,385,74],{"href":75},[366,387,388],{},[103,389,390],{"href":80},"Node (ws)",[366,392,393],{},[103,394,396],{"href":395},"\u002Fadapters\u002Fnode#uwebsockets","Node (μWebSockets)",[366,398,399],{},[103,400,84],{"href":401},"adapters\u002Fsse",[403,404,405],"tbody",{},[363,406,407,413,416,419,421,423,425,427],{},[408,409,410],"td",{},[98,411,412],{},"event",[408,414,415],{},"⨉",[408,417,418],{},"✓",[408,420,415],{},[408,422,418],{},[408,424,415],{},[408,426,415],{},[408,428,415],{},[430,431,432],"style",{},"html pre.shiki code .so5gQ, html code.shiki .so5gQ{--shiki-light:#D73A49;--shiki-default:#F97583;--shiki-dark:#F97583}html pre.shiki code .suiK_, html code.shiki .suiK_{--shiki-light:#005CC5;--shiki-default:#79B8FF;--shiki-dark:#79B8FF}html pre.shiki code .shcOC, html code.shiki .shcOC{--shiki-light:#6F42C1;--shiki-default:#B392F0;--shiki-dark:#B392F0}html pre.shiki code .slsVL, html code.shiki .slsVL{--shiki-light:#24292E;--shiki-default:#E1E4E8;--shiki-dark:#E1E4E8}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":251,"searchDepth":434,"depth":434,"links":435},2,[436,444,451],{"id":125,"depth":434,"text":126,"children":437},[438,440,441,442,443],{"id":130,"depth":439,"text":133},3,{"id":145,"depth":439,"text":148},{"id":159,"depth":439,"text":162},{"id":172,"depth":439,"text":175},{"id":181,"depth":439,"text":184},{"id":197,"depth":434,"text":198,"children":445},[446,447,448,449,450],{"id":201,"depth":439,"text":204},{"id":213,"depth":439,"text":216},{"id":292,"depth":439,"text":295},{"id":312,"depth":439,"text":315},{"id":337,"depth":439,"text":340},{"id":354,"depth":434,"text":355},"md",{"icon":25},{"icon":25},{"title":22,"description":251},"bxz8AFIy4zOlDP9e3YV3cJZp9np_9IaMdGqitRmUgbA",[458,460],{"title":17,"path":18,"stem":19,"description":459,"icon":20,"children":-1},"Peer object allows easily interacting with connected clients.",{"title":27,"path":28,"stem":29,"description":251,"icon":30,"children":-1},1783073589553]