[{"data":1,"prerenderedAt":365},["ShallowReactive",2],{"navigation":3,"-guide-basics-lifecycle":184,"-guide-basics-lifecycle-surround":360},[4,91,133,161,168],{"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},"H3 Utils","/utils","2.utils/0.index",[96,98,103,108,113,118,123,128],{"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},"More utils","/utils/more","2.utils/9.more","mingcute:plus-line",{"title":129,"path":130,"stem":131,"icon":132},"Community","/utils/community","2.utils/99.community","lets-icons:external",{"title":134,"path":135,"stem":136,"children":137,"icon":139},"Examples","/examples","4.examples/0.index",[138,140,145,149,153,157],{"title":134,"path":135,"stem":136,"icon":139},"ph:code",{"title":141,"path":142,"stem":143,"icon":144},"Cookies","/examples/handle-cookie","4.examples/handle-cookie","ph:arrow-right",{"title":146,"path":147,"stem":148,"icon":144},"Sessions","/examples/handle-session","4.examples/handle-session",{"title":150,"path":151,"stem":152,"icon":144},"Static Assets","/examples/serve-static-assets","4.examples/serve-static-assets",{"title":154,"path":155,"stem":156,"icon":144},"Stream Response","/examples/stream-response","4.examples/stream-response",{"title":158,"path":159,"stem":160,"icon":144},"Validate Data","/examples/validate-data","4.examples/validate-data",{"title":162,"path":163,"stem":164,"children":165,"icon":167},"Migration guide for v1 to v2","/migration","5.migration/0.index",[166],{"title":162,"path":163,"stem":164,"icon":167},"icons8:up-round",{"title":169,"path":170,"stem":171,"children":172,"page":-1},"Blog","/blog","99.blog",[173,176,180],{"title":169,"path":170,"stem":174,"icon":175},"99.blog/index","i-lucide-file-text",{"title":177,"path":178,"stem":179,"icon":175},"H3 1.8 - Towards the Edge of the Web","/blog/v1.8","99.blog/1.v1.8",{"title":181,"path":182,"stem":183,"icon":175},"H3 v2 beta","/blog/v2-beta","99.blog/2.v2-beta",{"id":185,"title":18,"body":186,"description":354,"extension":355,"meta":356,"navigation":357,"path":19,"seo":358,"stem":20,"__hash__":359},"content/1.guide/1.basics/1.lifecycle.md",{"type":187,"value":188,"toc":346,"icon":21},"minimark",[189,193,198,214,219,242,246,268,272,276,295,299,311,315,338,342],[190,191,192],"p",{},"Below is an overview of what happens in a H3 server from when an HTTP request arrives until a response is generated.",[194,195,197],"h2",{"id":196},"_1-incoming-request","1. Incoming Request",[190,199,200,201,208,209,213],{},"When An HTTP request is made by Browser or ",[202,203,207],"a",{"href":204,"rel":205},"https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API",[206],"nofollow","fetch()",", server fetch handler receives a ",[202,210,99],{"href":211,"rel":212},"https://developer.mozilla.org/en-US/docs/Web/API/Request",[206]," object.",[215,216,218],"mermaid",{"code":217},"%%{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",[],[220,221,222],"tip",{},[190,223,224,225,230,231,235,236,241],{},"\n​",[202,226,229],{"href":227,"rel":228},"https://srvx.h3.dev",[206],"💥 Srvx"," provides unified ",[232,233,234],"code",{},"server.fetch"," interface and adds ",[202,237,240],{"href":238,"rel":239},"https://srvx.h3.dev/guide/node",[206],"Node.js compatibility",".",[194,243,245],{"id":244},"_2-accept-request","2. Accept Request",[190,247,248,249,253,254,260,261,267],{},"H3 Initializes an ",[202,250,251],{"href":66},[232,252,65],{}," instance from incoming request, calls ",[202,255,257],{"href":256},"/guide/api/h3#global-hooks",[232,258,259],{},"onRequest"," global hook and finally ",[202,262,264],{"href":263},"/guide/api/h3#h3handler",[232,265,266],{},"H3.handler"," with the initialized event.",[215,269,271],{"code":270},"%%{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",[],[194,273,275],{"id":274},"_3-dispatch-request","3. Dispatch Request",[190,277,278,279,282,283,286,287,290,291,294],{},"H3 ",[202,280,281],{"href":24},"matches route"," based on ",[232,284,285],{},"request.url"," and ",[232,288,289],{},"request.method",", calls global ",[202,292,293],{"href":29},"middleware"," and finally matched route handler function with event.",[215,296,298],{"code":297},"%%{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",[],[220,300,301],{},[190,302,303,304,307,308,241],{},"\n🚀 Internally, H3 uses srvx ",[232,305,306],{},"FastURL"," instead of ",[232,309,310],{},"new URL(req.url).pathname",[194,312,314],{"id":313},"_4-send-response","4. Send Response",[190,316,278,317,321,322,326,327,331,332,337],{},[202,318,320],{"href":319},"/guide/basics/response#response-types","converts"," returned value and ",[202,323,325],{"href":324},"/guide/basics/response#preparing-response","prepared headers"," into a ",[202,328,104],{"href":329,"rel":330},"https://developer.mozilla.org/en-US/docs/Web/API/Response",[206],", calls ",[202,333,334],{"href":256},[232,335,336],{},"onResponse"," global hook and finally returns response back to the server fetch handler.",[215,339,341],{"code":340},"%%{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",[],[343,344,345],"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":347,"searchDepth":348,"depth":348,"links":349},"",2,[350,351,352,353],{"id":196,"depth":348,"text":197},{"id":244,"depth":348,"text":245},{"id":274,"depth":348,"text":275},{"id":313,"depth":348,"text":314},"H3 dispatches incoming web requests to final web responses.","md",{"icon":21},{"icon":21},{"title":18,"description":354},"MhiL461YI2jFIWjW1MSkCx9O3-MXQ9F43M6vC_DpwA8",[361,363],{"title":10,"path":6,"stem":7,"description":362,"icon":11,"children":-1},"Get started with H3.",{"title":23,"path":24,"stem":25,"description":364,"icon":26,"children":-1},"Each request is matched to one (most specific) route handler.",1753878201604]