[{"data":1,"prerenderedAt":881},["ShallowReactive",2],{"navigation":3,"-guide":193,"-guide-surround":877},[4,91,138,170,177],{"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,166],{"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},"HTTP QUERY Method","/examples/handle-query","4.examples/handle-query",{"title":155,"path":156,"stem":157,"icon":149},"Sessions","/examples/handle-session","4.examples/handle-session",{"title":159,"path":160,"stem":161,"icon":149},"Static Assets","/examples/serve-static-assets","4.examples/serve-static-assets",{"title":163,"path":164,"stem":165,"icon":149},"Stream Response","/examples/stream-response","4.examples/stream-response",{"title":167,"path":168,"stem":169,"icon":149},"Validate Data","/examples/validate-data","4.examples/validate-data",{"title":171,"path":172,"stem":173,"children":174,"icon":176},"Migration","/migration","5.migration/0.index",[175],{"title":171,"path":172,"stem":173,"icon":176},"icons8:up-round",{"title":178,"path":179,"stem":180,"children":181},"Blog","/blog","99.blog",[182,185,189],{"title":178,"path":179,"stem":183,"icon":184},"99.blog/index","i-lucide-file-text",{"title":186,"path":187,"stem":188,"icon":184},"H3 1.8 - Towards the Edge of the Web","/blog/v1.8","99.blog/1.v1.8",{"title":190,"path":191,"stem":192,"icon":184},"H3 v2 beta","/blog/v2-beta","99.blog/2.v2-beta",{"id":194,"title":10,"body":195,"description":871,"extension":872,"meta":873,"navigation":874,"path":6,"seo":875,"stem":7,"__hash__":876},"content/1.guide/0.index.md",{"type":196,"value":197,"toc":865,"icon":11},"minimark",[198,213,218,247,258,271,277,281,285,297,305,308,311,422,425,483,486,490,493,503,523,543,550,596,598,606,608,617,634,663,673,676,784,790,861],[199,200,201],"important",{},[202,203,204,205,212],"p",{},"\nYou are currently reading H3 v2 docs. See ",[206,207,211],"a",{"href":208,"rel":209},"https://v1.h3.dev/",[210],"nofollow","v1.h3.dev"," for legacy docs.",[214,215,217],"h2",{"id":216},"overview","Overview",[202,219,220,221,225,226,225,230,235,236,241,242,246],{},"⚡ H3 (short for H(TTP), pronounced as /eɪtʃθriː/, like h-3) is a lightweight, fast, and composable server framework for modern JavaScript runtimes. It is based on web standard primitives such as ",[206,222,99],{"href":223,"rel":224},"https://developer.mozilla.org/en-US/docs/Web/API/Request",[210],", ",[206,227,104],{"href":228,"rel":229},"https://developer.mozilla.org/en-US/docs/Web/API/Response",[210],[206,231,234],{"href":232,"rel":233},"https://developer.mozilla.org/en-US/docs/Web/API/URL",[210],"URL",", and ",[206,237,240],{"href":238,"rel":239},"https://developer.mozilla.org/en-US/docs/Web/API/Headers",[210],"Headers",". You can integrate H3 with any compatible runtime or ",[206,243,245],{"href":244},"/guide/api/h3#h3mount","mount"," other web-compatible handlers to H3 with almost no added latency.",[202,248,249,250,253,254,257],{},"H3 is designed to be extendable and composable. Instead of providing one big core, you start with a lightweight ",[206,251,252],{"href":61},"H3 instance"," and then import built-in, tree-shakable ",[206,255,256],{"href":93},"utilities"," or bring your own for more functionality.\nComposable utilities has several advantages:",[259,260,261,265,268],"ul",{},[262,263,264],"li",{},"The server only includes used code and runs them exactly where is needed.",[262,266,267],{},"Application size can scale better. Usage of utilities is explicit and clean, with less global impact.",[262,269,270],{},"H3 is minimally opinionated and won't limit your choices.",[202,272,273,274,276],{},"All utilities, share an ",[206,275,65],{"href":66}," context.",[278,279],"read-more",{"title":280,"to":93},"built-in H3 utilities",[214,282,284],{"id":283},"quick-start","Quick Start",[286,287,288],"tip",{},[202,289,290,291,296],{},"\nYou try H3 online ",[206,292,295],{"href":293,"rel":294},"https://stackblitz.com/github/h3js/h3/tree/main/playground?file=server.mjs",[210],"on ⚡️ Stackblitz ",".",[202,298,299,300,304],{},"Install ",[301,302,303],"code",{},"h3"," as a dependency:",[306,307],"pm-install",{"name":303},[202,309,310],{},"Create a new file for server entry:",[312,313,319],"pre",{"className":314,"code":315,"filename":316,"language":317,"meta":318,"style":318},"language-ts shiki shiki-themes github-light github-dark github-dark","import { H3, serve } from \"h3\";\n\nconst app = new H3().get(\"/\", (event) => \"⚡️ Tadaa!\");\n\nserve(app, { port: 3000 });\n","server.mjs","ts","",[301,320,321,344,351,402,407],{"__ignoreMap":318},[322,323,326,330,334,337,341],"span",{"class":324,"line":325},"line",1,[322,327,329],{"class":328},"so5gQ","import",[322,331,333],{"class":332},"slsVL"," { H3, serve } ",[322,335,336],{"class":328},"from",[322,338,340],{"class":339},"sfrk1"," \"h3\"",[322,342,343],{"class":332},";\n",[322,345,347],{"class":324,"line":346},2,[322,348,350],{"emptyLinePlaceholder":349},true,"\n",[322,352,354,357,361,364,367,371,374,377,380,383,386,390,393,396,399],{"class":324,"line":353},3,[322,355,356],{"class":328},"const",[322,358,360],{"class":359},"suiK_"," app",[322,362,363],{"class":328}," =",[322,365,366],{"class":328}," new",[322,368,370],{"class":369},"shcOC"," H3",[322,372,373],{"class":332},"().",[322,375,376],{"class":369},"get",[322,378,379],{"class":332},"(",[322,381,382],{"class":339},"\"/\"",[322,384,385],{"class":332},", (",[322,387,389],{"class":388},"sQHwn","event",[322,391,392],{"class":332},") ",[322,394,395],{"class":328},"=>",[322,397,398],{"class":339}," \"⚡️ Tadaa!\"",[322,400,401],{"class":332},");\n",[322,403,405],{"class":324,"line":404},4,[322,406,350],{"emptyLinePlaceholder":349},[322,408,410,413,416,419],{"class":324,"line":409},5,[322,411,412],{"class":369},"serve",[322,414,415],{"class":332},"(app, { port: ",[322,417,418],{"class":359},"3000",[322,420,421],{"class":332}," });\n",[202,423,424],{},"Then, run the server using your favorite runtime:",[426,427,428,446,466],"code-group",{},[312,429,434],{"className":430,"code":431,"filename":432,"language":433,"meta":318,"style":318},"language-bash shiki shiki-themes github-light github-dark github-dark","node --watch ./server.mjs\n","node","bash",[301,435,436],{"__ignoreMap":318},[322,437,438,440,443],{"class":324,"line":325},[322,439,432],{"class":369},[322,441,442],{"class":359}," --watch",[322,444,445],{"class":339}," ./server.mjs\n",[312,447,450],{"className":430,"code":448,"filename":449,"language":433,"meta":318,"style":318},"deno run -A --watch ./server.mjs\n","deno",[301,451,452],{"__ignoreMap":318},[322,453,454,456,459,462,464],{"class":324,"line":325},[322,455,449],{"class":369},[322,457,458],{"class":339}," run",[322,460,461],{"class":359}," -A",[322,463,442],{"class":359},[322,465,445],{"class":339},[312,467,470],{"className":430,"code":468,"filename":469,"language":433,"meta":318,"style":318},"bun run --watch server.mjs\n","bun",[301,471,472],{"__ignoreMap":318},[322,473,474,476,478,480],{"class":324,"line":325},[322,475,469],{"class":369},[322,477,458],{"class":339},[322,479,442],{"class":359},[322,481,482],{"class":339}," server.mjs\n",[202,484,485],{},"And tadaa! We have a web server running locally.",[303,487,489],{"id":488},"what-happened","What Happened?",[202,491,492],{},"Okay, let's now break down our hello world example.",[202,494,495,496,498,499,502],{},"We first created an ",[206,497,60],{"href":61}," app instance using ",[301,500,501],{},"new H3()",":",[312,504,506],{"className":314,"code":505,"language":317,"meta":318,"style":318},"const app = new H3();\n",[301,507,508],{"__ignoreMap":318},[322,509,510,512,514,516,518,520],{"class":324,"line":325},[322,511,356],{"class":328},[322,513,360],{"class":359},[322,515,363],{"class":328},[322,517,366],{"class":328},[322,519,370],{"class":369},[322,521,522],{"class":332},"();\n",[202,524,525,527,528,225,531,534,535,538,539,296],{},[206,526,60],{"href":61}," is a tiny class capable of ",[206,529,530],{"href":24},"matching routes",[206,532,533],{"href":39},"generating responses"," and calling ",[206,536,537],{"href":29},"middleware"," and ",[206,540,542],{"href":541},"/guide/api/h3#global-hooks","global hooks",[202,544,545,546,549],{},"Then we add a route for handling HTTP GET requests to ",[301,547,548],{},"/"," path.",[312,551,553],{"className":314,"code":552,"language":317,"meta":318,"style":318},"app.get(\"/\", (event) => {\n  return { message: \"⚡️ Tadaa!\" };\n});\n",[301,554,555,577,591],{"__ignoreMap":318},[322,556,557,560,562,564,566,568,570,572,574],{"class":324,"line":325},[322,558,559],{"class":332},"app.",[322,561,376],{"class":369},[322,563,379],{"class":332},[322,565,382],{"class":339},[322,567,385],{"class":332},[322,569,389],{"class":388},[322,571,392],{"class":332},[322,573,395],{"class":328},[322,575,576],{"class":332}," {\n",[322,578,579,582,585,588],{"class":324,"line":346},[322,580,581],{"class":328},"  return",[322,583,584],{"class":332}," { message: ",[322,586,587],{"class":339},"\"⚡️ Tadaa!\"",[322,589,590],{"class":332}," };\n",[322,592,593],{"class":324,"line":353},[322,594,595],{"class":332},"});\n",[278,597],{"title":23,"to":24},[202,599,600,601,605],{},"We simply returned an object. H3 automatically ",[206,602,604],{"href":603},"/guide/basics/response#response-types","converts"," values into web responses.",[278,607],{"title":38,"to":39},[202,609,610,611,613,614,616],{},"Finally, we use ",[301,612,412],{}," method to start the server listener. Using ",[301,615,412],{}," method you can easily start an H3 server in various runtimes.",[312,618,622],{"className":619,"code":620,"language":621,"meta":318,"style":318},"language-js shiki shiki-themes github-light github-dark github-dark","serve(app, { port: 3000 });\n","js",[301,623,624],{"__ignoreMap":318},[322,625,626,628,630,632],{"class":324,"line":325},[322,627,412],{"class":369},[322,629,415],{"class":332},[322,631,418],{"class":359},[322,633,421],{"class":332},[286,635,636],{},[202,637,638,639,641,642,647,648,225,653,538,658,296],{},"\nThe ",[301,640,412],{}," method is powered by ",[206,643,646],{"href":644,"rel":645},"https://srvx.h3.dev/",[210],"💥 srvx",", a runtime-agnostic universal server listener based on web standards that works seamlessly with ",[206,649,652],{"href":650,"rel":651},"https://deno.com/",[210],"Deno",[206,654,657],{"href":655,"rel":656},"https://nodejs.org/",[210],"Node.js",[206,659,662],{"href":660,"rel":661},"https://bun.sh/",[210],"Bun",[202,664,665,666,672],{},"We also have ",[206,667,669],{"href":668},"/guide/api/h3#h3fetch",[301,670,671],{},"app.fetch"," which can be directly used to run H3 apps in any web-compatible runtime or even directly called for testing purposes.",[278,674],{"title":675,"to":668},"H3.fetch",[312,677,679],{"className":619,"code":678,"language":621,"meta":318,"style":318},"import { H3, serve } from \"h3\";\n\nconst app = new H3().get(\"/\", () => \"⚡️ Tadaa!\");\n\n// Test without listening\nconst response = await app.request(\"/\");\nconsole.log(await response.text());\n",[301,680,681,693,697,726,730,736,761],{"__ignoreMap":318},[322,682,683,685,687,689,691],{"class":324,"line":325},[322,684,329],{"class":328},[322,686,333],{"class":332},[322,688,336],{"class":328},[322,690,340],{"class":339},[322,692,343],{"class":332},[322,694,695],{"class":324,"line":346},[322,696,350],{"emptyLinePlaceholder":349},[322,698,699,701,703,705,707,709,711,713,715,717,720,722,724],{"class":324,"line":353},[322,700,356],{"class":328},[322,702,360],{"class":359},[322,704,363],{"class":328},[322,706,366],{"class":328},[322,708,370],{"class":369},[322,710,373],{"class":332},[322,712,376],{"class":369},[322,714,379],{"class":332},[322,716,382],{"class":339},[322,718,719],{"class":332},", () ",[322,721,395],{"class":328},[322,723,398],{"class":339},[322,725,401],{"class":332},[322,727,728],{"class":324,"line":404},[322,729,350],{"emptyLinePlaceholder":349},[322,731,732],{"class":324,"line":409},[322,733,735],{"class":734},"sCsY4","// Test without listening\n",[322,737,739,741,744,746,749,752,755,757,759],{"class":324,"line":738},6,[322,740,356],{"class":328},[322,742,743],{"class":359}," response",[322,745,363],{"class":328},[322,747,748],{"class":328}," await",[322,750,751],{"class":332}," app.",[322,753,754],{"class":369},"request",[322,756,379],{"class":332},[322,758,382],{"class":339},[322,760,401],{"class":332},[322,762,764,767,770,772,775,778,781],{"class":324,"line":763},7,[322,765,766],{"class":332},"console.",[322,768,769],{"class":369},"log",[322,771,379],{"class":332},[322,773,774],{"class":328},"await",[322,776,777],{"class":332}," response.",[322,779,780],{"class":369},"text",[322,782,783],{"class":332},"());\n",[202,785,786,787,789],{},"You can directly import ",[301,788,303],{}," library from CDN alternatively. This method can be used for Bun, Deno and other runtimes such as Cloudflare Workers.",[312,791,793],{"className":619,"code":792,"language":621,"meta":318,"style":318},"import { H3 } from \"https://esm.sh/h3\";\n\nconst app = new H3().get(\"/\", () => \"⚡️ Tadaa!\");\n\nexport const fetch = app.fetch;\n",[301,794,795,809,813,841,845],{"__ignoreMap":318},[322,796,797,799,802,804,807],{"class":324,"line":325},[322,798,329],{"class":328},[322,800,801],{"class":332}," { H3 } ",[322,803,336],{"class":328},[322,805,806],{"class":339}," \"https://esm.sh/h3\"",[322,808,343],{"class":332},[322,810,811],{"class":324,"line":346},[322,812,350],{"emptyLinePlaceholder":349},[322,814,815,817,819,821,823,825,827,829,831,833,835,837,839],{"class":324,"line":353},[322,816,356],{"class":328},[322,818,360],{"class":359},[322,820,363],{"class":328},[322,822,366],{"class":328},[322,824,370],{"class":369},[322,826,373],{"class":332},[322,828,376],{"class":369},[322,830,379],{"class":332},[322,832,382],{"class":339},[322,834,719],{"class":332},[322,836,395],{"class":328},[322,838,398],{"class":339},[322,840,401],{"class":332},[322,842,843],{"class":324,"line":404},[322,844,350],{"emptyLinePlaceholder":349},[322,846,847,850,853,856,858],{"class":324,"line":409},[322,848,849],{"class":328},"export",[322,851,852],{"class":328}," const",[322,854,855],{"class":359}," fetch",[322,857,363],{"class":328},[322,859,860],{"class":332}," app.fetch;\n",[862,863,864],"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":318,"searchDepth":346,"depth":346,"links":866},[867,868],{"id":216,"depth":346,"text":217},{"id":283,"depth":346,"text":284,"children":869},[870],{"id":488,"depth":353,"text":489},"Get started with H3.","md",{"automd":349,"icon":11},{"icon":11},{"title":10,"description":871},"4ES3cy6mSQEg40mYOAmrL0m-kPzEWicHdvEqtWJvSNo",[878,879],null,{"title":18,"path":19,"stem":20,"description":880,"icon":21,"children":-1},"H3 dispatches incoming web requests to final web responses.",1783670986849]