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