[{"data":1,"prerenderedAt":360},["ShallowReactive",2],{"navigation":3,"-guide-basics-lifecycle":179,"-guide-basics-lifecycle-surround":355},[4,86,128,156,163],{"title":5,"path":6,"stem":7,"children":8,"icon":85},"Guide","/guide","1.guide/0.index",[9,12,48,64],{"title":10,"path":6,"stem":7,"icon":11},"Getting Started","pixel:play",{"title":5,"icon":13,"path":14,"stem":15,"children":16,"page":47},"ph:book-open-duotone","/guide/basics","1.guide/1.basics",[17,22,27,32,37,42],{"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",false,{"title":49,"icon":50,"path":51,"stem":52,"children":53,"page":47},"API","material-symbols-light:api-rounded","/guide/api","1.guide/900.api",[54,59],{"title":55,"path":56,"stem":57,"icon":58},"H3","/guide/api/h3","1.guide/900.api/1.h3","material-symbols:bolt-rounded",{"title":60,"path":61,"stem":62,"icon":63},"H3Event","/guide/api/h3event","1.guide/900.api/2.h3event","material-symbols:data-object-rounded",{"title":65,"icon":66,"path":67,"stem":68,"children":69,"page":47},"Advanced","hugeicons:more-01","/guide/advanced","1.guide/901.advanced",[70,75,80],{"title":71,"path":72,"stem":73,"icon":74},"Plugins","/guide/advanced/plugins","1.guide/901.advanced/1.plugins","clarity:plugin-line",{"title":76,"path":77,"stem":78,"icon":79},"WebSockets","/guide/advanced/websocket","1.guide/901.advanced/2.websocket","hugeicons:live-streaming-02",{"title":81,"path":82,"stem":83,"icon":84},"Nightly Builds","/guide/advanced/nightly","1.guide/901.advanced/9.nightly","game-icons:barn-owl","i-ph:book-open-duotone",{"title":87,"path":88,"stem":89,"children":90,"icon":92},"H3 Utils","/utils","2.utils/0.index",[91,93,98,103,108,113,118,123],{"title":87,"path":88,"stem":89,"icon":92},"ph:function-bold",{"title":94,"path":95,"stem":96,"icon":97},"Request","/utils/request","2.utils/1.request","material-symbols-light:input",{"title":99,"path":100,"stem":101,"icon":102},"Response","/utils/response","2.utils/2.response","material-symbols-light:output",{"title":104,"path":105,"stem":106,"icon":107},"Cookie","/utils/cookie","2.utils/3.cookie","material-symbols:cookie-outline",{"title":109,"path":110,"stem":111,"icon":112},"Security","/utils/security","2.utils/4.security","wpf:key-security",{"title":114,"path":115,"stem":116,"icon":117},"Proxy","/utils/proxy","2.utils/5.proxy","arcticons:super-proxy",{"title":119,"path":120,"stem":121,"icon":122},"More utils","/utils/more","2.utils/9.more","mingcute:plus-line",{"title":124,"path":125,"stem":126,"icon":127},"Community","/utils/community","2.utils/99.community","lets-icons:external",{"title":129,"path":130,"stem":131,"children":132,"icon":134},"Examples","/examples","4.examples/0.index",[133,135,140,144,148,152],{"title":129,"path":130,"stem":131,"icon":134},"ph:code",{"title":136,"path":137,"stem":138,"icon":139},"Cookies","/examples/handle-cookie","4.examples/handle-cookie","ph:arrow-right",{"title":141,"path":142,"stem":143,"icon":139},"Sessions","/examples/handle-session","4.examples/handle-session",{"title":145,"path":146,"stem":147,"icon":139},"Static Assets","/examples/serve-static-assets","4.examples/serve-static-assets",{"title":149,"path":150,"stem":151,"icon":139},"Stream Response","/examples/stream-response","4.examples/stream-response",{"title":153,"path":154,"stem":155,"icon":139},"Validate Data","/examples/validate-data","4.examples/validate-data",{"title":157,"path":158,"stem":159,"children":160,"icon":162},"Migration guide for v1 to v2","/migration","5.migration/0.index",[161],{"title":157,"path":158,"stem":159,"icon":162},"icons8:up-round",{"title":164,"path":165,"stem":166,"children":167,"page":-1},"Blog","/blog","99.blog",[168,171,175],{"title":164,"path":165,"stem":169,"icon":170},"99.blog/index","i-lucide-file-text",{"title":172,"path":173,"stem":174,"icon":170},"H3 1.8 - Towards the Edge of the Web","/blog/v1.8","99.blog/1.v1.8",{"title":176,"path":177,"stem":178,"icon":170},"H3 v2 beta","/blog/v2-beta","99.blog/2.v2-beta",{"id":180,"title":18,"body":181,"description":349,"extension":350,"meta":351,"navigation":352,"path":19,"seo":353,"stem":20,"__hash__":354},"content/1.guide/1.basics/1.lifecycle.md",{"type":182,"value":183,"toc":341,"icon":21},"minimark",[184,188,193,209,214,237,241,263,267,271,290,294,306,310,333,337],[185,186,187],"p",{},"Below is an overview of what happens in a H3 server from when an HTTP request arrives until a response is generated.",[189,190,192],"h2",{"id":191},"_1-incoming-request","1. Incoming Request",[185,194,195,196,203,204,208],{},"When An HTTP request is made by Browser or ",[197,198,202],"a",{"href":199,"rel":200},"https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API",[201],"nofollow","fetch()",", server fetch handler receives a ",[197,205,94],{"href":206,"rel":207},"https://developer.mozilla.org/en-US/docs/Web/API/Request",[201]," object.",[210,211,213],"mermaid",{"code":212},"%%{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",[],[215,216,217],"tip",{},[185,218,219,220,225,226,230,231,236],{},"\n​",[197,221,224],{"href":222,"rel":223},"https://srvx.h3.dev",[201],"💥 Srvx"," provides unified ",[227,228,229],"code",{},"server.fetch"," interface and adds ",[197,232,235],{"href":233,"rel":234},"https://srvx.h3.dev/guide/node",[201],"Node.js compatibility",".",[189,238,240],{"id":239},"_2-accept-request","2. Accept Request",[185,242,243,244,248,249,255,256,262],{},"H3 Initializes an ",[197,245,246],{"href":61},[227,247,60],{}," instance from incoming request, calls ",[197,250,252],{"href":251},"/guide/api/h3#global-hooks",[227,253,254],{},"onRequest"," global hook and finally ",[197,257,259],{"href":258},"/guide/api/h3#h3handler",[227,260,261],{},"H3.handler"," with the initialized event.",[210,264,266],{"code":265},"%%{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",[],[189,268,270],{"id":269},"_3-dispatch-request","3. Dispatch Request",[185,272,273,274,277,278,281,282,285,286,289],{},"H3 ",[197,275,276],{"href":24},"matches route"," based on ",[227,279,280],{},"request.url"," and ",[227,283,284],{},"request.method",", calls global ",[197,287,288],{"href":29},"middleware"," and finally matched route handler function with event.",[210,291,293],{"code":292},"%%{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",[],[215,295,296],{},[185,297,298,299,302,303,236],{},"\n🚀 Internally, H3 uses srvx ",[227,300,301],{},"FastURL"," instead of ",[227,304,305],{},"new URL(req.url).pathname",[189,307,309],{"id":308},"_4-send-response","4. Send Response",[185,311,273,312,316,317,321,322,326,327,332],{},[197,313,315],{"href":314},"/guide/basics/response#response-types","converts"," returned value and ",[197,318,320],{"href":319},"/guide/basics/response#preparing-response","prepared headers"," into a ",[197,323,99],{"href":324,"rel":325},"https://developer.mozilla.org/en-US/docs/Web/API/Response",[201],", calls ",[197,328,329],{"href":251},[227,330,331],{},"onResponse"," global hook and finally returns response back to the server fetch handler.",[210,334,336],{"code":335},"%%{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",[],[338,339,340],"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":342,"searchDepth":343,"depth":343,"links":344},"",2,[345,346,347,348],{"id":191,"depth":343,"text":192},{"id":239,"depth":343,"text":240},{"id":269,"depth":343,"text":270},{"id":308,"depth":343,"text":309},"H3 dispatches incoming web requests to final web responses.","md",{"icon":21},{"icon":21},{"title":18,"description":349},"MhiL461YI2jFIWjW1MSkCx9O3-MXQ9F43M6vC_DpwA8",[356,358],{"title":10,"path":6,"stem":7,"description":357,"icon":11,"children":-1},"Get started with H3.",{"title":23,"path":24,"stem":25,"description":359,"icon":26,"children":-1},"Each request is matched to one (most specific) route handler.",1751015547867]