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