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