[{"data":1,"prerenderedAt":1344},["ShallowReactive",2],{"navigation":3,"-guide-basics-handler":189,"-guide-basics-handler-surround":1339},[4,91,138,166,173],{"title":5,"path":6,"stem":7,"children":8,"icon":90},"Guide","/guide","1.guide/0.index",[9,12,53,69],{"title":10,"path":6,"stem":7,"icon":11},"Getting Started","pixel:play",{"title":5,"icon":13,"path":14,"stem":15,"children":16,"page":52},"ph:book-open-duotone","/guide/basics","1.guide/1.basics",[17,22,27,32,37,42,47],{"title":18,"path":19,"stem":20,"icon":21},"Request Lifecycle","/guide/basics/lifecycle","1.guide/1.basics/1.lifecycle","icon-park-outline:handle-round",{"title":23,"path":24,"stem":25,"icon":26},"Routing","/guide/basics/routing","1.guide/1.basics/2.routing","solar:routing-bold",{"title":28,"path":29,"stem":30,"icon":31},"Middleware","/guide/basics/middleware","1.guide/1.basics/3.middleware","mdi:middleware-outline",{"title":33,"path":34,"stem":35,"icon":36},"Event Handlers","/guide/basics/handler","1.guide/1.basics/4.handler","mdi:function",{"title":38,"path":39,"stem":40,"icon":41},"Sending Response","/guide/basics/response","1.guide/1.basics/5.response","tabler:json",{"title":43,"path":44,"stem":45,"icon":46},"Error Handling","/guide/basics/error","1.guide/1.basics/6.error","tabler:error-404",{"title":48,"path":49,"stem":50,"icon":51},"Nested Apps","/guide/basics/nested-apps","1.guide/1.basics/7.nested-apps","material-symbols-light:layers-outline",false,{"title":54,"icon":55,"path":56,"stem":57,"children":58,"page":52},"API","material-symbols-light:api-rounded","/guide/api","1.guide/900.api",[59,64],{"title":60,"path":61,"stem":62,"icon":63},"H3","/guide/api/h3","1.guide/900.api/1.h3","material-symbols:bolt-rounded",{"title":65,"path":66,"stem":67,"icon":68},"H3Event","/guide/api/h3event","1.guide/900.api/2.h3event","material-symbols:data-object-rounded",{"title":70,"icon":71,"path":72,"stem":73,"children":74,"page":52},"Advanced","hugeicons:more-01","/guide/advanced","1.guide/901.advanced",[75,80,85],{"title":76,"path":77,"stem":78,"icon":79},"Plugins","/guide/advanced/plugins","1.guide/901.advanced/1.plugins","clarity:plugin-line",{"title":81,"path":82,"stem":83,"icon":84},"WebSockets","/guide/advanced/websocket","1.guide/901.advanced/2.websocket","hugeicons:live-streaming-02",{"title":86,"path":87,"stem":88,"icon":89},"Nightly Builds","/guide/advanced/nightly","1.guide/901.advanced/9.nightly","game-icons:barn-owl","i-ph:book-open-duotone",{"title":92,"path":93,"stem":94,"children":95,"icon":97},"Utils","/utils","2.utils/0.index",[96,98,103,108,113,118,123,128,133],{"title":92,"path":93,"stem":94,"icon":97},"ph:function-bold",{"title":99,"path":100,"stem":101,"icon":102},"Request","/utils/request","2.utils/1.request","material-symbols-light:input",{"title":104,"path":105,"stem":106,"icon":107},"Response","/utils/response","2.utils/2.response","material-symbols-light:output",{"title":109,"path":110,"stem":111,"icon":112},"Cookie","/utils/cookie","2.utils/3.cookie","material-symbols:cookie-outline",{"title":114,"path":115,"stem":116,"icon":117},"Security","/utils/security","2.utils/4.security","wpf:key-security",{"title":119,"path":120,"stem":121,"icon":122},"Proxy","/utils/proxy","2.utils/5.proxy","arcticons:super-proxy",{"title":124,"path":125,"stem":126,"icon":127},"MCP","/utils/mcp","2.utils/6.mcp","material-symbols:swap-calls",{"title":129,"path":130,"stem":131,"icon":132},"More utils","/utils/more","2.utils/9.more","mingcute:plus-line",{"title":134,"path":135,"stem":136,"icon":137},"Community","/utils/community","2.utils/99.community","lets-icons:external",{"title":139,"path":140,"stem":141,"children":142,"icon":144},"Examples","/examples","4.examples/0.index",[143,145,150,154,158,162],{"title":139,"path":140,"stem":141,"icon":144},"ph:code",{"title":146,"path":147,"stem":148,"icon":149},"Cookies","/examples/handle-cookie","4.examples/handle-cookie","ph:arrow-right",{"title":151,"path":152,"stem":153,"icon":149},"Sessions","/examples/handle-session","4.examples/handle-session",{"title":155,"path":156,"stem":157,"icon":149},"Static Assets","/examples/serve-static-assets","4.examples/serve-static-assets",{"title":159,"path":160,"stem":161,"icon":149},"Stream Response","/examples/stream-response","4.examples/stream-response",{"title":163,"path":164,"stem":165,"icon":149},"Validate Data","/examples/validate-data","4.examples/validate-data",{"title":167,"path":168,"stem":169,"children":170,"icon":172},"Migration","/migration","5.migration/0.index",[171],{"title":167,"path":168,"stem":169,"icon":172},"icons8:up-round",{"title":174,"path":175,"stem":176,"children":177},"Blog","/blog","99.blog",[178,181,185],{"title":174,"path":175,"stem":179,"icon":180},"99.blog/index","i-lucide-file-text",{"title":182,"path":183,"stem":184,"icon":180},"H3 1.8 - Towards the Edge of the Web","/blog/v1.8","99.blog/1.v1.8",{"title":186,"path":187,"stem":188,"icon":180},"H3 v2 beta","/blog/v2-beta","99.blog/2.v2-beta",{"id":190,"title":33,"body":191,"description":1333,"extension":1334,"meta":1335,"navigation":1336,"path":34,"seo":1337,"stem":35,"__hash__":1338},"content/1.guide/1.basics/4.handler.md",{"type":192,"value":193,"toc":1320,"icon":36},"minimark",[194,203,325,340,343,370,375,379,385,456,460,462,465,468,603,609,616,625,723,727,734,737,821,824,827,974,978,981,985,1007,1165,1169,1180,1186,1316],[195,196,197,198,202],"p",{},"You can define typed event handlers using ",[199,200,201],"code",{},"defineHandler",".",[204,205,210],"pre",{"className":206,"code":207,"language":208,"meta":209,"style":209},"language-js shiki shiki-themes github-light github-dark github-dark","import { H3, defineHandler } from \"h3\";\n\nconst app = new H3();\n\nconst handler = defineHandler((event) => \"Response\");\n\napp.get(\"/\", handler);\n","js","",[199,211,212,235,242,265,270,302,307],{"__ignoreMap":209},[213,214,217,221,225,228,232],"span",{"class":215,"line":216},"line",1,[213,218,220],{"class":219},"so5gQ","import",[213,222,224],{"class":223},"slsVL"," { H3, defineHandler } ",[213,226,227],{"class":219},"from",[213,229,231],{"class":230},"sfrk1"," \"h3\"",[213,233,234],{"class":223},";\n",[213,236,238],{"class":215,"line":237},2,[213,239,241],{"emptyLinePlaceholder":240},true,"\n",[213,243,245,248,252,255,258,262],{"class":215,"line":244},3,[213,246,247],{"class":219},"const",[213,249,251],{"class":250},"suiK_"," app",[213,253,254],{"class":219}," =",[213,256,257],{"class":219}," new",[213,259,261],{"class":260},"shcOC"," H3",[213,263,264],{"class":223},"();\n",[213,266,268],{"class":215,"line":267},4,[213,269,241],{"emptyLinePlaceholder":240},[213,271,273,275,278,280,283,286,290,293,296,299],{"class":215,"line":272},5,[213,274,247],{"class":219},[213,276,277],{"class":250}," handler",[213,279,254],{"class":219},[213,281,282],{"class":260}," defineHandler",[213,284,285],{"class":223},"((",[213,287,289],{"class":288},"sQHwn","event",[213,291,292],{"class":223},") ",[213,294,295],{"class":219},"=>",[213,297,298],{"class":230}," \"Response\"",[213,300,301],{"class":223},");\n",[213,303,305],{"class":215,"line":304},6,[213,306,241],{"emptyLinePlaceholder":240},[213,308,310,313,316,319,322],{"class":215,"line":309},7,[213,311,312],{"class":223},"app.",[213,314,315],{"class":260},"get",[213,317,318],{"class":223},"(",[213,320,321],{"class":230},"\"/\"",[213,323,324],{"class":223},", handler);\n",[326,327,328],"note",{},[195,329,330,331,333,334,339],{},"\nUsing ",[199,332,201],{}," is optional.\nYou can instead, simply use a function that accepts an ",[335,336,337],"a",{"href":66},[199,338,65],{}," and returns a response.",[195,341,342],{},"The callback function can be sync or async:",[204,344,346],{"className":206,"code":345,"language":208,"meta":209,"style":209},"defineHandler(async (event) => \"Response\");\n",[199,347,348],{"__ignoreMap":209},[213,349,350,352,354,357,360,362,364,366,368],{"class":215,"line":216},[213,351,201],{"class":260},[213,353,318],{"class":223},[213,355,356],{"class":219},"async",[213,358,359],{"class":223}," (",[213,361,289],{"class":288},[213,363,292],{"class":223},[213,365,295],{"class":219},[213,367,298],{"class":230},[213,369,301],{"class":223},[371,372,374],"h2",{"id":373},"object-syntax","Object Syntax",[376,377,378],"h3",{"id":378},"middleware",[195,380,381,382,384],{},"You can optionally register some ",[335,383,378],{"href":29}," to run with event handler to intercept request, response or errors.",[204,386,388],{"className":206,"code":387,"language":208,"meta":209,"style":209},"import { basicAuth } from \"h3\";\n\ndefineHandler({\n  middleware: [basicAuth({ password: \"test\" })],\n  handler: (event) => \"Hi!\",\n});\n",[199,389,390,403,407,414,431,451],{"__ignoreMap":209},[213,391,392,394,397,399,401],{"class":215,"line":216},[213,393,220],{"class":219},[213,395,396],{"class":223}," { basicAuth } ",[213,398,227],{"class":219},[213,400,231],{"class":230},[213,402,234],{"class":223},[213,404,405],{"class":215,"line":237},[213,406,241],{"emptyLinePlaceholder":240},[213,408,409,411],{"class":215,"line":244},[213,410,201],{"class":260},[213,412,413],{"class":223},"({\n",[213,415,416,419,422,425,428],{"class":215,"line":267},[213,417,418],{"class":223},"  middleware: [",[213,420,421],{"class":260},"basicAuth",[213,423,424],{"class":223},"({ password: ",[213,426,427],{"class":230},"\"test\"",[213,429,430],{"class":223}," })],\n",[213,432,433,436,439,441,443,445,448],{"class":215,"line":272},[213,434,435],{"class":260},"  handler",[213,437,438],{"class":223},": (",[213,440,289],{"class":288},[213,442,292],{"class":223},[213,444,295],{"class":219},[213,446,447],{"class":230}," \"Hi!\"",[213,449,450],{"class":223},",\n",[213,452,453],{"class":215,"line":304},[213,454,455],{"class":223},"});\n",[457,458],"read-more",{"to":39,"title":459},"Response Handling",[457,461],{"to":66},[376,463,464],{"id":464},"meta",[195,466,467],{},"You can define optional route meta attached to handlers, and access them from any other middleware.",[204,469,471],{"className":206,"code":470,"language":208,"meta":209,"style":209},"import { H3, defineHandler } from \"h3\";\n\nconst app = new H3();\n\napp.use((event) => {\n  console.log(event.context.matchedRoute?.meta); // { tag: \"admin\" }\n});\n\napp.get(\"/admin/**\", defineHandler({\n  meta: { tag: \"admin\" },\n  handler: (event) => \"Hi!\",\n})\n",[199,472,473,485,489,503,507,525,540,544,549,568,580,597],{"__ignoreMap":209},[213,474,475,477,479,481,483],{"class":215,"line":216},[213,476,220],{"class":219},[213,478,224],{"class":223},[213,480,227],{"class":219},[213,482,231],{"class":230},[213,484,234],{"class":223},[213,486,487],{"class":215,"line":237},[213,488,241],{"emptyLinePlaceholder":240},[213,490,491,493,495,497,499,501],{"class":215,"line":244},[213,492,247],{"class":219},[213,494,251],{"class":250},[213,496,254],{"class":219},[213,498,257],{"class":219},[213,500,261],{"class":260},[213,502,264],{"class":223},[213,504,505],{"class":215,"line":267},[213,506,241],{"emptyLinePlaceholder":240},[213,508,509,511,514,516,518,520,522],{"class":215,"line":272},[213,510,312],{"class":223},[213,512,513],{"class":260},"use",[213,515,285],{"class":223},[213,517,289],{"class":288},[213,519,292],{"class":223},[213,521,295],{"class":219},[213,523,524],{"class":223}," {\n",[213,526,527,530,533,536],{"class":215,"line":304},[213,528,529],{"class":223},"  console.",[213,531,532],{"class":260},"log",[213,534,535],{"class":223},"(event.context.matchedRoute?.meta); ",[213,537,539],{"class":538},"sCsY4","// { tag: \"admin\" }\n",[213,541,542],{"class":215,"line":309},[213,543,455],{"class":223},[213,545,547],{"class":215,"line":546},8,[213,548,241],{"emptyLinePlaceholder":240},[213,550,552,554,556,558,561,564,566],{"class":215,"line":551},9,[213,553,312],{"class":223},[213,555,315],{"class":260},[213,557,318],{"class":223},[213,559,560],{"class":230},"\"/admin/**\"",[213,562,563],{"class":223},", ",[213,565,201],{"class":260},[213,567,413],{"class":223},[213,569,571,574,577],{"class":215,"line":570},10,[213,572,573],{"class":223},"  meta: { tag: ",[213,575,576],{"class":230},"\"admin\"",[213,578,579],{"class":223}," },\n",[213,581,583,585,587,589,591,593,595],{"class":215,"line":582},11,[213,584,435],{"class":260},[213,586,438],{"class":223},[213,588,289],{"class":288},[213,590,292],{"class":223},[213,592,295],{"class":219},[213,594,447],{"class":230},[213,596,450],{"class":223},[213,598,600],{"class":215,"line":599},12,[213,601,602],{"class":223},"})\n",[457,604,606],{"to":605},"/guide/basics/routing#route-meta",[195,607,608],{},"It is also possible to add route meta when registering them to app instance.",[371,610,612,613],{"id":611},"handler-fetch","Handler ",[199,614,615],{},".fetch",[195,617,618,619,621,622,624],{},"Event handlers defined with ",[199,620,201],{},", can act as a web handler without even using ",[335,623,60],{"href":61}," class.",[204,626,628],{"className":206,"code":627,"language":208,"meta":209,"style":209},"const handler = defineHandler(async (event) => `Request: ${event.req.url}`);\n\nconst response = await handler.fetch(\"http://localhost/\");\nconsole.log(response, await response.text());\n",[199,629,630,672,676,701],{"__ignoreMap":209},[213,631,632,634,636,638,640,642,644,646,648,650,652,655,657,659,662,664,667,670],{"class":215,"line":216},[213,633,247],{"class":219},[213,635,277],{"class":250},[213,637,254],{"class":219},[213,639,282],{"class":260},[213,641,318],{"class":223},[213,643,356],{"class":219},[213,645,359],{"class":223},[213,647,289],{"class":288},[213,649,292],{"class":223},[213,651,295],{"class":219},[213,653,654],{"class":230}," `Request: ${",[213,656,289],{"class":223},[213,658,202],{"class":230},[213,660,661],{"class":223},"req",[213,663,202],{"class":230},[213,665,666],{"class":223},"url",[213,668,669],{"class":230},"}`",[213,671,301],{"class":223},[213,673,674],{"class":215,"line":237},[213,675,241],{"emptyLinePlaceholder":240},[213,677,678,680,683,685,688,691,694,696,699],{"class":215,"line":244},[213,679,247],{"class":219},[213,681,682],{"class":250}," response",[213,684,254],{"class":219},[213,686,687],{"class":219}," await",[213,689,690],{"class":223}," handler.",[213,692,693],{"class":260},"fetch",[213,695,318],{"class":223},[213,697,698],{"class":230},"\"http://localhost/\"",[213,700,301],{"class":223},[213,702,703,706,708,711,714,717,720],{"class":215,"line":267},[213,704,705],{"class":223},"console.",[213,707,532],{"class":260},[213,709,710],{"class":223},"(response, ",[213,712,713],{"class":219},"await",[213,715,716],{"class":223}," response.",[213,718,719],{"class":260},"text",[213,721,722],{"class":223},"());\n",[371,724,726],{"id":725},"lazy-handlers","Lazy Handlers",[195,728,729,730,733],{},"You can define lazy event handlers using ",[199,731,732],{},"defineLazyEventHandler",". This allow you to define some one-time logic that will be executed only once when the first request matching the route is received.",[195,735,736],{},"A lazy event handler must return an event handler.",[204,738,740],{"className":206,"code":739,"language":208,"meta":209,"style":209},"import { defineLazyEventHandler } from \"h3\";\n\ndefineLazyEventHandler(async () => {\n  await initSomething(); // Will be executed only once\n  return (event) => {\n    return \"Response\";\n  };\n});\n",[199,741,742,755,759,774,788,803,812,817],{"__ignoreMap":209},[213,743,744,746,749,751,753],{"class":215,"line":216},[213,745,220],{"class":219},[213,747,748],{"class":223}," { defineLazyEventHandler } ",[213,750,227],{"class":219},[213,752,231],{"class":230},[213,754,234],{"class":223},[213,756,757],{"class":215,"line":237},[213,758,241],{"emptyLinePlaceholder":240},[213,760,761,763,765,767,770,772],{"class":215,"line":244},[213,762,732],{"class":260},[213,764,318],{"class":223},[213,766,356],{"class":219},[213,768,769],{"class":223}," () ",[213,771,295],{"class":219},[213,773,524],{"class":223},[213,775,776,779,782,785],{"class":215,"line":267},[213,777,778],{"class":219},"  await",[213,780,781],{"class":260}," initSomething",[213,783,784],{"class":223},"(); ",[213,786,787],{"class":538},"// Will be executed only once\n",[213,789,790,793,795,797,799,801],{"class":215,"line":272},[213,791,792],{"class":219},"  return",[213,794,359],{"class":223},[213,796,289],{"class":288},[213,798,292],{"class":223},[213,800,295],{"class":219},[213,802,524],{"class":223},[213,804,805,808,810],{"class":215,"line":304},[213,806,807],{"class":219},"    return",[213,809,298],{"class":230},[213,811,234],{"class":223},[213,813,814],{"class":215,"line":309},[213,815,816],{"class":223},"  };\n",[213,818,819],{"class":215,"line":546},[213,820,455],{"class":223},[195,822,823],{},"This is useful to define some one-time logic such as configuration, class initialization, heavy computation, etc.",[195,825,826],{},"Another use-case is lazy loading route chunks:",[828,829,830,928],"CodeGroup",{},[204,831,834],{"className":206,"code":832,"filename":833,"language":208,"meta":209,"style":209},"import { H3, defineLazyEventHandler } from \"h3\";\n\nconst app = new H3();\n\napp.all(\n  \"/route\",\n  defineLazyEventHandler(() => import(\"./route.mjs\").then((mod) => mod.default)),\n);\n","app.mjs",[199,835,836,849,853,867,871,881,888,924],{"__ignoreMap":209},[213,837,838,840,843,845,847],{"class":215,"line":216},[213,839,220],{"class":219},[213,841,842],{"class":223}," { H3, defineLazyEventHandler } ",[213,844,227],{"class":219},[213,846,231],{"class":230},[213,848,234],{"class":223},[213,850,851],{"class":215,"line":237},[213,852,241],{"emptyLinePlaceholder":240},[213,854,855,857,859,861,863,865],{"class":215,"line":244},[213,856,247],{"class":219},[213,858,251],{"class":250},[213,860,254],{"class":219},[213,862,257],{"class":219},[213,864,261],{"class":260},[213,866,264],{"class":223},[213,868,869],{"class":215,"line":267},[213,870,241],{"emptyLinePlaceholder":240},[213,872,873,875,878],{"class":215,"line":272},[213,874,312],{"class":223},[213,876,877],{"class":260},"all",[213,879,880],{"class":223},"(\n",[213,882,883,886],{"class":215,"line":304},[213,884,885],{"class":230},"  \"/route\"",[213,887,450],{"class":223},[213,889,890,893,896,898,901,903,906,909,912,914,917,919,921],{"class":215,"line":309},[213,891,892],{"class":260},"  defineLazyEventHandler",[213,894,895],{"class":223},"(() ",[213,897,295],{"class":219},[213,899,900],{"class":219}," import",[213,902,318],{"class":223},[213,904,905],{"class":230},"\"./route.mjs\"",[213,907,908],{"class":223},").",[213,910,911],{"class":260},"then",[213,913,285],{"class":223},[213,915,916],{"class":288},"mod",[213,918,292],{"class":223},[213,920,295],{"class":219},[213,922,923],{"class":223}," mod.default)),\n",[213,925,926],{"class":215,"line":546},[213,927,301],{"class":223},[204,929,932],{"className":206,"code":930,"filename":931,"language":208,"meta":209,"style":209},"import { defineHandler } from \"h3\";\n\nexport default defineHandler((event) => \"Hello!\");\n","route.mjs",[199,933,934,947,951],{"__ignoreMap":209},[213,935,936,938,941,943,945],{"class":215,"line":216},[213,937,220],{"class":219},[213,939,940],{"class":223}," { defineHandler } ",[213,942,227],{"class":219},[213,944,231],{"class":230},[213,946,234],{"class":223},[213,948,949],{"class":215,"line":237},[213,950,241],{"emptyLinePlaceholder":240},[213,952,953,956,959,961,963,965,967,969,972],{"class":215,"line":244},[213,954,955],{"class":219},"export",[213,957,958],{"class":219}," default",[213,960,282],{"class":260},[213,962,285],{"class":223},[213,964,289],{"class":288},[213,966,292],{"class":223},[213,968,295],{"class":219},[213,970,971],{"class":230}," \"Hello!\"",[213,973,301],{"class":223},[371,975,977],{"id":976},"converting-to-handler","Converting to Handler",[195,979,980],{},"There are situations that you might want to convert an event handler or utility made for Node.js or another framework to H3.\nThere are built-in utils to do this.",[376,982,984],{"id":983},"from-web-handlers","From Web Handlers",[195,986,987,988,993,994,998,999,1002,1003,202],{},"Request handlers with ",[335,989,99],{"href":990,"rel":991},"https://developer.mozilla.org/en-US/docs/Web/API/Request",[992],"nofollow"," => ",[335,995,104],{"href":996,"rel":997},"https://developer.mozilla.org/en-US/docs/Web/API/Response",[992]," signuture can be converted into H3 event handlers using ",[199,1000,1001],{},"fromWebHandler"," utility or ",[335,1004,1006],{"href":1005},"/guide/api/h3#h3mount","H3.mount",[204,1008,1010],{"className":206,"code":1009,"language":208,"meta":209,"style":209},"import { H3, fromWebHandler } from \"h3\";\n\nexport const app = new H3();\n\nconst webHandler = (request) => new Response(\"👋 Hello!\");\n\n// Using fromWebHandler utiliy\napp.all(\"/web\", fromWebHandler(webHandler));\n\n// Using simple wrapper\napp.all(\"/web\", (event) => webHandler(event.req));\n\n// Using app.mount\napp.mount(\"/web\", webHandler);\n",[199,1011,1012,1025,1029,1046,1050,1080,1084,1089,1107,1111,1116,1140,1144,1150],{"__ignoreMap":209},[213,1013,1014,1016,1019,1021,1023],{"class":215,"line":216},[213,1015,220],{"class":219},[213,1017,1018],{"class":223}," { H3, fromWebHandler } ",[213,1020,227],{"class":219},[213,1022,231],{"class":230},[213,1024,234],{"class":223},[213,1026,1027],{"class":215,"line":237},[213,1028,241],{"emptyLinePlaceholder":240},[213,1030,1031,1033,1036,1038,1040,1042,1044],{"class":215,"line":244},[213,1032,955],{"class":219},[213,1034,1035],{"class":219}," const",[213,1037,251],{"class":250},[213,1039,254],{"class":219},[213,1041,257],{"class":219},[213,1043,261],{"class":260},[213,1045,264],{"class":223},[213,1047,1048],{"class":215,"line":267},[213,1049,241],{"emptyLinePlaceholder":240},[213,1051,1052,1054,1057,1059,1061,1064,1066,1068,1070,1073,1075,1078],{"class":215,"line":272},[213,1053,247],{"class":219},[213,1055,1056],{"class":260}," webHandler",[213,1058,254],{"class":219},[213,1060,359],{"class":223},[213,1062,1063],{"class":288},"request",[213,1065,292],{"class":223},[213,1067,295],{"class":219},[213,1069,257],{"class":219},[213,1071,1072],{"class":260}," Response",[213,1074,318],{"class":223},[213,1076,1077],{"class":230},"\"👋 Hello!\"",[213,1079,301],{"class":223},[213,1081,1082],{"class":215,"line":304},[213,1083,241],{"emptyLinePlaceholder":240},[213,1085,1086],{"class":215,"line":309},[213,1087,1088],{"class":538},"// Using fromWebHandler utiliy\n",[213,1090,1091,1093,1095,1097,1100,1102,1104],{"class":215,"line":546},[213,1092,312],{"class":223},[213,1094,877],{"class":260},[213,1096,318],{"class":223},[213,1098,1099],{"class":230},"\"/web\"",[213,1101,563],{"class":223},[213,1103,1001],{"class":260},[213,1105,1106],{"class":223},"(webHandler));\n",[213,1108,1109],{"class":215,"line":551},[213,1110,241],{"emptyLinePlaceholder":240},[213,1112,1113],{"class":215,"line":570},[213,1114,1115],{"class":538},"// Using simple wrapper\n",[213,1117,1118,1120,1122,1124,1126,1129,1131,1133,1135,1137],{"class":215,"line":582},[213,1119,312],{"class":223},[213,1121,877],{"class":260},[213,1123,318],{"class":223},[213,1125,1099],{"class":230},[213,1127,1128],{"class":223},", (",[213,1130,289],{"class":288},[213,1132,292],{"class":223},[213,1134,295],{"class":219},[213,1136,1056],{"class":260},[213,1138,1139],{"class":223},"(event.req));\n",[213,1141,1142],{"class":215,"line":599},[213,1143,241],{"emptyLinePlaceholder":240},[213,1145,1147],{"class":215,"line":1146},13,[213,1148,1149],{"class":538},"// Using app.mount\n",[213,1151,1153,1155,1158,1160,1162],{"class":215,"line":1152},14,[213,1154,312],{"class":223},[213,1156,1157],{"class":260},"mount",[213,1159,318],{"class":223},[213,1161,1099],{"class":230},[213,1163,1164],{"class":223},", webHandler);\n",[376,1166,1168],{"id":1167},"from-nodejs-handlers","From Node.js Handlers",[195,1170,1171,1172,1175,1176,1179],{},"If you have a legacy request handler with ",[199,1173,1174],{},"(req, res) => {}"," syntax made for Node.js, you can use ",[199,1177,1178],{},"fromNodeHandler"," to convert it to an h3 event handler.",[1181,1182,1183],"important",{},[195,1184,1185],{},"\nNode.js event handlers can only run within Node.js server runtime!",[204,1187,1189],{"className":206,"code":1188,"language":208,"meta":209,"style":209},"import { H3, fromNodeHandler } from \"h3\";\n\n// Force using Node.js compatibility (also works with Bun and Deno)\nimport { serve } from \"h3/node\";\n\nexport const app = new H3();\n\nconst nodeHandler = (req, res) => {\n  res.end(\"Node handlers work!\");\n};\n\napp.get(\"/web\", fromNodeHandler(nodeHandler));\n",[199,1190,1191,1204,1208,1213,1227,1231,1247,1251,1275,1290,1295,1299],{"__ignoreMap":209},[213,1192,1193,1195,1198,1200,1202],{"class":215,"line":216},[213,1194,220],{"class":219},[213,1196,1197],{"class":223}," { H3, fromNodeHandler } ",[213,1199,227],{"class":219},[213,1201,231],{"class":230},[213,1203,234],{"class":223},[213,1205,1206],{"class":215,"line":237},[213,1207,241],{"emptyLinePlaceholder":240},[213,1209,1210],{"class":215,"line":244},[213,1211,1212],{"class":538},"// Force using Node.js compatibility (also works with Bun and Deno)\n",[213,1214,1215,1217,1220,1222,1225],{"class":215,"line":267},[213,1216,220],{"class":219},[213,1218,1219],{"class":223}," { serve } ",[213,1221,227],{"class":219},[213,1223,1224],{"class":230}," \"h3/node\"",[213,1226,234],{"class":223},[213,1228,1229],{"class":215,"line":272},[213,1230,241],{"emptyLinePlaceholder":240},[213,1232,1233,1235,1237,1239,1241,1243,1245],{"class":215,"line":304},[213,1234,955],{"class":219},[213,1236,1035],{"class":219},[213,1238,251],{"class":250},[213,1240,254],{"class":219},[213,1242,257],{"class":219},[213,1244,261],{"class":260},[213,1246,264],{"class":223},[213,1248,1249],{"class":215,"line":309},[213,1250,241],{"emptyLinePlaceholder":240},[213,1252,1253,1255,1258,1260,1262,1264,1266,1269,1271,1273],{"class":215,"line":546},[213,1254,247],{"class":219},[213,1256,1257],{"class":260}," nodeHandler",[213,1259,254],{"class":219},[213,1261,359],{"class":223},[213,1263,661],{"class":288},[213,1265,563],{"class":223},[213,1267,1268],{"class":288},"res",[213,1270,292],{"class":223},[213,1272,295],{"class":219},[213,1274,524],{"class":223},[213,1276,1277,1280,1283,1285,1288],{"class":215,"line":551},[213,1278,1279],{"class":223},"  res.",[213,1281,1282],{"class":260},"end",[213,1284,318],{"class":223},[213,1286,1287],{"class":230},"\"Node handlers work!\"",[213,1289,301],{"class":223},[213,1291,1292],{"class":215,"line":570},[213,1293,1294],{"class":223},"};\n",[213,1296,1297],{"class":215,"line":582},[213,1298,241],{"emptyLinePlaceholder":240},[213,1300,1301,1303,1305,1307,1309,1311,1313],{"class":215,"line":599},[213,1302,312],{"class":223},[213,1304,315],{"class":260},[213,1306,318],{"class":223},[213,1308,1099],{"class":230},[213,1310,563],{"class":223},[213,1312,1178],{"class":260},[213,1314,1315],{"class":223},"(nodeHandler));\n",[1317,1318,1319],"style",{},"html pre.shiki code .so5gQ, html code.shiki .so5gQ{--shiki-light:#D73A49;--shiki-default:#F97583;--shiki-dark:#F97583}html pre.shiki code .slsVL, html code.shiki .slsVL{--shiki-light:#24292E;--shiki-default:#E1E4E8;--shiki-dark:#E1E4E8}html pre.shiki code .sfrk1, html code.shiki .sfrk1{--shiki-light:#032F62;--shiki-default:#9ECBFF;--shiki-dark:#9ECBFF}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 .sQHwn, html code.shiki .sQHwn{--shiki-light:#E36209;--shiki-default:#FFAB70;--shiki-dark:#FFAB70}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);}html pre.shiki code .sCsY4, html code.shiki .sCsY4{--shiki-light:#6A737D;--shiki-default:#6A737D;--shiki-dark:#6A737D}",{"title":209,"searchDepth":237,"depth":237,"links":1321},[1322,1326,1328,1329],{"id":373,"depth":237,"text":374,"children":1323},[1324,1325],{"id":378,"depth":244,"text":378},{"id":464,"depth":244,"text":464},{"id":611,"depth":237,"text":1327},"Handler .fetch",{"id":725,"depth":237,"text":726},{"id":976,"depth":237,"text":977,"children":1330},[1331,1332],{"id":983,"depth":244,"text":984},{"id":1167,"depth":244,"text":1168},"An event handler is a function that receives an H3Event and returns a response.","md",{"icon":36},{"icon":36},{"title":33,"description":1333},"AAdfUf3YPb-CMLat1MTzM_zOvDjQ7GPm21nRmlfXrIs",[1340,1342],{"title":28,"path":29,"stem":30,"description":1341,"icon":31,"children":-1},"Intercept request, response and errors using H3 middleware.",{"title":38,"path":39,"stem":40,"description":1343,"icon":41,"children":-1},"H3 automatically converts any returned value into a web response.",1783115413976]