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