[{"data":1,"prerenderedAt":370},["ShallowReactive",2],{"navigation":3,"-guide-basics-lifecycle":193,"-guide-basics-lifecycle-surround":365},[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":18,"body":195,"description":359,"extension":360,"meta":361,"navigation":362,"path":19,"seo":363,"stem":20,"__hash__":364},"content/1.guide/1.basics/1.lifecycle.md",{"type":196,"value":197,"toc":351,"icon":21},"minimark",[198,202,207,223,227,250,254,276,279,283,302,305,317,321,344,347],[199,200,201],"p",{},"Below is an overview of what happens in a H3 server from when an HTTP request arrives until a response is generated.",[203,204,206],"h2",{"id":205},"_1-incoming-request","1. Incoming Request",[199,208,209,210,217,218,222],{},"When An HTTP request is made by Browser or ",[211,212,216],"a",{"href":213,"rel":214},"https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API",[215],"nofollow","fetch()",", server fetch handler receives a ",[211,219,99],{"href":220,"rel":221},"https://developer.mozilla.org/en-US/docs/Web/API/Request",[215]," object.",[224,225],"mermaid",{"code":226},"%%{init: {'theme':'neutral'}}%%\nflowchart LR\n  A1[\"\u003Ccode>fetch(request)\u003C/code>\"] --> A2[\"\u003Ccode>server.fetch(request)\u003C/code>\"]\n\nclick A2 \"/guide/api/h3#h3fetch\"\n",[228,229,230],"tip",{},[199,231,232,233,238,239,243,244,249],{},"\n​",[211,234,237],{"href":235,"rel":236},"https://srvx.h3.dev",[215],"💥 Srvx"," provides unified ",[240,241,242],"code",{},"server.fetch"," interface and adds ",[211,245,248],{"href":246,"rel":247},"https://srvx.h3.dev/guide/node",[215],"Node.js compatibility",".",[203,251,253],{"id":252},"_2-accept-request","2. Accept Request",[199,255,256,257,261,262,268,269,275],{},"H3 Initializes an ",[211,258,259],{"href":66},[240,260,65],{}," instance from incoming request, calls ",[211,263,265],{"href":264},"/guide/api/h3#global-hooks",[240,266,267],{},"onRequest"," global hook and finally ",[211,270,272],{"href":271},"/guide/api/h3#h3handler",[240,273,274],{},"H3.handler"," with the initialized event.",[224,277],{"code":278},"%%{init: {'theme':'neutral'}}%%\nflowchart LR\n  B1[\"\u003Ccode>new H3Event(request)\u003C/code>\"] --> B2[\"\u003Ccode>onRequest(event)\u003C/code>\"] --> B3[\"\u003Ccode>h3.handler(event)\u003C/code>\"]\n\nclick B1 \"/guide/api/h3event\"\nclick B2 \"/guide/api/h3#global-hooks\"\nclick B3 \"/guide/api/h3#apphandler\"\n",[203,280,282],{"id":281},"_3-dispatch-request","3. Dispatch Request",[199,284,285,286,289,290,293,294,297,298,301],{},"H3 ",[211,287,288],{"href":24},"matches route"," based on ",[240,291,292],{},"request.url"," and ",[240,295,296],{},"request.method",", calls global ",[211,299,300],{"href":29},"middleware"," and finally matched route handler function with event.",[224,303],{"code":304},"%%{init: {'theme':'neutral'}}%%\nsequenceDiagram\n    participant MiddlewareA as Middleware1(event, next)\n    participant MiddlewareB as Middleware2(event, next)\n    participant Route as RouteHandler(event)\n\n    MiddlewareA->>+MiddlewareB: await next()\n    MiddlewareB->>+Route: await next()\n    Route-->>-MiddlewareB: rawBody\n    MiddlewareB-->>-MiddlewareA: rawBody\n\n",[228,306,307],{},[199,308,309,310,313,314,249],{},"\n🚀 Internally, H3 uses srvx ",[240,311,312],{},"FastURL"," instead of ",[240,315,316],{},"new URL(req.url).pathname",[203,318,320],{"id":319},"_4-send-response","4. Send Response",[199,322,285,323,327,328,332,333,337,338,343],{},[211,324,326],{"href":325},"/guide/basics/response#response-types","converts"," returned value and ",[211,329,331],{"href":330},"/guide/basics/response#preparing-response","prepared headers"," into a ",[211,334,104],{"href":335,"rel":336},"https://developer.mozilla.org/en-US/docs/Web/API/Response",[215],", calls ",[211,339,340],{"href":264},[240,341,342],{},"onResponse"," global hook and finally returns response back to the server fetch handler.",[224,345],{"code":346},"%%{init: {'theme':'neutral'}}%%\nflowchart LR\n D1[\"Returned Value => Response\"] --> D2[\"\u003Ccode>onResponse(response)\u003C/code>\"] --> D3[\"Response\"]\n\nclick D1 \"/guide/basics/response\"\nclick D2 \"/guide/api/h3#global-hooks\"\n",[348,349,350],"style",{},"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":352,"searchDepth":353,"depth":353,"links":354},"",2,[355,356,357,358],{"id":205,"depth":353,"text":206},{"id":252,"depth":353,"text":253},{"id":281,"depth":353,"text":282},{"id":319,"depth":353,"text":320},"H3 dispatches incoming web requests to final web responses.","md",{"icon":21},{"icon":21},{"title":18,"description":359},"dk7WTpVsrAX7tGscTZl1fBirgJgzSMZL3OLYYENloCs",[366,368],{"title":10,"path":6,"stem":7,"description":367,"icon":11,"children":-1},"Get started with H3.",{"title":23,"path":24,"stem":25,"description":369,"icon":26,"children":-1},"Each request is matched to one (most specific) route handler.",1783690727815]