[{"data":1,"prerenderedAt":2129},["ShallowReactive",2],{"navigation":3,"-docs-lifecycle":445,"-docs-lifecycle-surround":2124},[4,123,260,266,430,442],{"title":5,"path":6,"stem":7,"children":8,"icon":122},"","\u002Fdocs","1.docs\u002F1.index",[9,12,17,22,27,32,37,42,47,52,57,62,67,72,77,82,87,92,97,102,107,112,117],{"title":10,"path":6,"stem":7,"icon":11},"Introduction","i-lucide-compass",{"title":13,"path":14,"stem":15,"icon":16},"Quick Start","\u002Fdocs\u002Fquick-start","1.docs\u002F2.quick-start","i-lucide-zap",{"title":18,"path":19,"stem":20,"icon":21},"Renderer","\u002Fdocs\u002Frenderer","1.docs\u002F4.renderer","ri:layout-masonry-line",{"title":23,"path":24,"stem":25,"icon":26},"Routing","\u002Fdocs\u002Frouting","1.docs\u002F5.routing","ri:direction-line",{"title":28,"path":29,"stem":30,"icon":31},"Assets","\u002Fdocs\u002Fassets","1.docs\u002F50.assets","ri:image-2-line",{"title":33,"path":34,"stem":35,"icon":36},"Configuration","\u002Fdocs\u002Fconfiguration","1.docs\u002F50.configuration","ri:settings-3-line",{"title":38,"path":39,"stem":40,"icon":41},"Database","\u002Fdocs\u002Fdatabase","1.docs\u002F50.database","ri:database-2-line",{"title":43,"path":44,"stem":45,"icon":46},"Lifecycle","\u002Fdocs\u002Flifecycle","1.docs\u002F50.lifecycle","i-lucide-layers",{"title":48,"path":49,"stem":50,"icon":51},"OpenAPI","\u002Fdocs\u002Fopenapi","1.docs\u002F50.openapi","ri:contract-line",{"title":53,"path":54,"stem":55,"icon":56},"Plugins","\u002Fdocs\u002Fplugins","1.docs\u002F50.plugins","ri:plug-line",{"title":58,"path":59,"stem":60,"icon":61},"Prerendering","\u002Fdocs\u002Fprerendering","1.docs\u002F50.prerendering","ri:file-copy-2-line",{"title":63,"path":64,"stem":65,"icon":66},"Tasks","\u002Fdocs\u002Ftasks","1.docs\u002F50.tasks","codicon:run-all",{"title":68,"path":69,"stem":70,"icon":71},"WebSocket","\u002Fdocs\u002Fwebsocket","1.docs\u002F50.websocket","ri:broadcast-fill",{"title":73,"path":74,"stem":75,"icon":76},"Modules","\u002Fdocs\u002Fmodules","1.docs\u002F55.modules","i-lucide-puzzle",{"title":78,"path":79,"stem":80,"icon":81},"Server Entry","\u002Fdocs\u002Fserver-entry","1.docs\u002F6.server-entry","ri:server-line",{"title":83,"path":84,"stem":85,"icon":86},"CLI","\u002Fdocs\u002Fcli","1.docs\u002F60.cli","i-lucide-terminal",{"title":88,"path":89,"stem":90,"icon":91},"Vite","\u002Fdocs\u002Fvite","1.docs\u002F61.vite","i-logos-vitejs",{"title":93,"path":94,"stem":95,"icon":96},"Utils","\u002Fdocs\u002Futils","1.docs\u002F62.utils","i-lucide-braces",{"title":98,"path":99,"stem":100,"icon":101},"TypeScript","\u002Fdocs\u002Ftypescript","1.docs\u002F63.typescript","i-logos-typescript-icon",{"title":103,"path":104,"stem":105,"icon":106},"Cache","\u002Fdocs\u002Fcache","1.docs\u002F7.cache","ri:speed-line",{"title":108,"path":109,"stem":110,"icon":111},"KV Storage","\u002Fdocs\u002Fstorage","1.docs\u002F8.storage","carbon:datastore",{"title":113,"path":114,"stem":115,"icon":116},"Migration Guide","\u002Fdocs\u002Fmigration","1.docs\u002F99.migration","ri:arrow-right-up-line",{"title":118,"path":119,"stem":120,"icon":121},"Nightly Channel","\u002Fdocs\u002Fnightly","1.docs\u002F99.nightly","ri:moon-fill","i-lucide-book-open",{"title":124,"path":125,"stem":126,"children":127,"icon":129},"Deploy","\u002Fdeploy","2.deploy\u002F0.index",[128,130,155],{"title":124,"path":125,"stem":126,"icon":129},"ri:upload-cloud-2-line",{"title":131,"path":132,"stem":133,"children":134,"page":154},"Runtimes","\u002Fdeploy\u002Fruntimes","2.deploy\u002F10.runtimes",[135,140,145,150],{"title":136,"path":137,"stem":138,"icon":139},"Node.js","\u002Fdeploy\u002Fruntimes\u002Fnode","2.deploy\u002F10.runtimes\u002F1.node","akar-icons:node-fill",{"title":141,"path":142,"stem":143,"icon":144},"Bun","\u002Fdeploy\u002Fruntimes\u002Fbun","2.deploy\u002F10.runtimes\u002Fbun","simple-icons:bun",{"title":146,"path":147,"stem":148,"icon":149},"Deno","\u002Fdeploy\u002Fruntimes\u002Fdeno","2.deploy\u002F10.runtimes\u002Fdeno","simple-icons:deno",{"title":151,"path":152,"stem":153},"Standard","\u002Fdeploy\u002Fruntimes\u002Fstandard","2.deploy\u002F10.runtimes\u002Fstandard",false,{"title":156,"path":157,"stem":158,"children":159,"page":154},"Providers","\u002Fdeploy\u002Fproviders","2.deploy\u002F20.providers",[160,164,168,172,176,180,184,188,192,196,200,204,208,212,216,220,224,228,232,236,240,244,248,252,256],{"title":161,"path":162,"stem":163},"Alwaysdata","\u002Fdeploy\u002Fproviders\u002Falwaysdata","2.deploy\u002F20.providers\u002Falwaysdata",{"title":165,"path":166,"stem":167},"AWS Lambda","\u002Fdeploy\u002Fproviders\u002Faws","2.deploy\u002F20.providers\u002Faws",{"title":169,"path":170,"stem":171},"AWS Amplify","\u002Fdeploy\u002Fproviders\u002Faws-amplify","2.deploy\u002F20.providers\u002Faws-amplify",{"title":173,"path":174,"stem":175},"Azure","\u002Fdeploy\u002Fproviders\u002Fazure","2.deploy\u002F20.providers\u002Fazure",{"title":177,"path":178,"stem":179},"Cleavr","\u002Fdeploy\u002Fproviders\u002Fcleavr","2.deploy\u002F20.providers\u002Fcleavr",{"title":181,"path":182,"stem":183},"Cloudflare","\u002Fdeploy\u002Fproviders\u002Fcloudflare","2.deploy\u002F20.providers\u002Fcloudflare",{"title":185,"path":186,"stem":187},"Deno Deploy","\u002Fdeploy\u002Fproviders\u002Fdeno-deploy","2.deploy\u002F20.providers\u002Fdeno-deploy",{"title":189,"path":190,"stem":191},"DigitalOcean","\u002Fdeploy\u002Fproviders\u002Fdigitalocean","2.deploy\u002F20.providers\u002Fdigitalocean",{"title":193,"path":194,"stem":195},"EdgeOne Pages","\u002Fdeploy\u002Fproviders\u002Fedgeone","2.deploy\u002F20.providers\u002Fedgeone",{"title":197,"path":198,"stem":199},"Firebase","\u002Fdeploy\u002Fproviders\u002Ffirebase","2.deploy\u002F20.providers\u002Ffirebase",{"title":201,"path":202,"stem":203},"Flightcontrol","\u002Fdeploy\u002Fproviders\u002Fflightcontrol","2.deploy\u002F20.providers\u002Fflightcontrol",{"title":205,"path":206,"stem":207},"Genezio","\u002Fdeploy\u002Fproviders\u002Fgenezio","2.deploy\u002F20.providers\u002Fgenezio",{"title":209,"path":210,"stem":211},"GitHub Pages","\u002Fdeploy\u002Fproviders\u002Fgithub-pages","2.deploy\u002F20.providers\u002Fgithub-pages",{"title":213,"path":214,"stem":215},"GitLab Pages","\u002Fdeploy\u002Fproviders\u002Fgitlab-pages","2.deploy\u002F20.providers\u002Fgitlab-pages",{"title":217,"path":218,"stem":219},"Heroku","\u002Fdeploy\u002Fproviders\u002Fheroku","2.deploy\u002F20.providers\u002Fheroku",{"title":221,"path":222,"stem":223},"IIS","\u002Fdeploy\u002Fproviders\u002Fiis","2.deploy\u002F20.providers\u002Fiis",{"title":225,"path":226,"stem":227},"Koyeb","\u002Fdeploy\u002Fproviders\u002Fkoyeb","2.deploy\u002F20.providers\u002Fkoyeb",{"title":229,"path":230,"stem":231},"Netlify","\u002Fdeploy\u002Fproviders\u002Fnetlify","2.deploy\u002F20.providers\u002Fnetlify",{"title":233,"path":234,"stem":235},"Platform.sh","\u002Fdeploy\u002Fproviders\u002Fplatform-sh","2.deploy\u002F20.providers\u002Fplatform-sh",{"title":237,"path":238,"stem":239},"Render.com","\u002Fdeploy\u002Fproviders\u002Frender","2.deploy\u002F20.providers\u002Frender",{"title":241,"path":242,"stem":243},"Stormkit","\u002Fdeploy\u002Fproviders\u002Fstormkit","2.deploy\u002F20.providers\u002Fstormkit",{"title":245,"path":246,"stem":247},"Vercel","\u002Fdeploy\u002Fproviders\u002Fvercel","2.deploy\u002F20.providers\u002Fvercel",{"title":249,"path":250,"stem":251},"Zeabur","\u002Fdeploy\u002Fproviders\u002Fzeabur","2.deploy\u002F20.providers\u002Fzeabur",{"title":253,"path":254,"stem":255},"Zephyr Cloud","\u002Fdeploy\u002Fproviders\u002Fzephyr","2.deploy\u002F20.providers\u002Fzephyr",{"title":257,"path":258,"stem":259},"Zerops","\u002Fdeploy\u002Fproviders\u002Fzerops","2.deploy\u002F20.providers\u002Fzerops",{"title":261,"path":262,"stem":263,"children":264,"icon":36},"Config","\u002Fconfig","3.config\u002F0.index",[265],{"title":261,"path":262,"stem":263,"icon":36},{"title":267,"path":268,"stem":269,"children":270,"icon":272},"Examples","\u002Fexamples","4.examples\u002F0.index",[271,273,278,283,288,293,297,302,307,312,317,322,327,331,336,340,344,349,354,359,364,369,374,379,383,388,393,398,402,407,412,416,421,426],{"title":267,"path":268,"stem":269,"icon":272},"i-lucide-folder-code",{"title":274,"path":275,"stem":276,"icon":277},"API Routes","\u002Fexamples\u002Fapi-routes","4.examples\u002Fapi-routes","i-lucide-route",{"title":279,"path":280,"stem":281,"icon":282},"Auto Imports","\u002Fexamples\u002Fauto-imports","4.examples\u002Fauto-imports","i-lucide-import",{"title":284,"path":285,"stem":286,"icon":287},"Cached Handler","\u002Fexamples\u002Fcached-handler","4.examples\u002Fcached-handler","i-lucide-clock",{"title":289,"path":290,"stem":291,"icon":292},"Custom Error Handler","\u002Fexamples\u002Fcustom-error-handler","4.examples\u002Fcustom-error-handler","i-lucide-alert-circle",{"title":38,"path":294,"stem":295,"icon":296},"\u002Fexamples\u002Fdatabase","4.examples\u002Fdatabase","i-lucide-database",{"title":298,"path":299,"stem":300,"icon":301},"Elysia","\u002Fexamples\u002Felysia","4.examples\u002Felysia","i-skill-icons-elysia-dark",{"title":303,"path":304,"stem":305,"icon":306},"Express","\u002Fexamples\u002Fexpress","4.examples\u002Fexpress","i-simple-icons-express",{"title":308,"path":309,"stem":310,"icon":311},"Fastify","\u002Fexamples\u002Ffastify","4.examples\u002Ffastify","i-simple-icons-fastify",{"title":313,"path":314,"stem":315,"icon":316},"Hello World","\u002Fexamples\u002Fhello-world","4.examples\u002Fhello-world","i-lucide-sparkles",{"title":318,"path":319,"stem":320,"icon":321},"Hono","\u002Fexamples\u002Fhono","4.examples\u002Fhono","i-logos-hono",{"title":323,"path":324,"stem":325,"icon":326},"Import Alias","\u002Fexamples\u002Fimport-alias","4.examples\u002Fimport-alias","i-lucide-at-sign",{"title":328,"path":329,"stem":330,"icon":46},"Middleware","\u002Fexamples\u002Fmiddleware","4.examples\u002Fmiddleware",{"title":332,"path":333,"stem":334,"icon":335},"Mono JSX","\u002Fexamples\u002Fmono-jsx","4.examples\u002Fmono-jsx","i-lucide-brackets",{"title":337,"path":338,"stem":339,"icon":335},"Nano JSX","\u002Fexamples\u002Fnano-jsx","4.examples\u002Fnano-jsx",{"title":53,"path":341,"stem":342,"icon":343},"\u002Fexamples\u002Fplugins","4.examples\u002Fplugins","i-lucide-plug",{"title":345,"path":346,"stem":347,"icon":348},"Custom Renderer","\u002Fexamples\u002Frenderer","4.examples\u002Frenderer","i-lucide-code",{"title":350,"path":351,"stem":352,"icon":353},"Runtime Config","\u002Fexamples\u002Fruntime-config","4.examples\u002Fruntime-config","i-lucide-settings",{"title":355,"path":356,"stem":357,"icon":358},"Server Fetch","\u002Fexamples\u002Fserver-fetch","4.examples\u002Fserver-fetch","i-lucide-arrow-right-left",{"title":360,"path":361,"stem":362,"icon":363},"Shiki","\u002Fexamples\u002Fshiki","4.examples\u002Fshiki","i-lucide-highlighter",{"title":365,"path":366,"stem":367,"icon":368},"Takumi","\u002Fexamples\u002Ftakumi","4.examples\u002Ftakumi","i-lucide-image",{"title":370,"path":371,"stem":372,"icon":373},"Tracing","\u002Fexamples\u002Ftracing","4.examples\u002Ftracing","i-lucide-activity",{"title":375,"path":376,"stem":377,"icon":378},"Virtual Routes","\u002Fexamples\u002Fvirtual-routes","4.examples\u002Fvirtual-routes","i-lucide-box",{"title":380,"path":381,"stem":382,"icon":91},"Vite Nitro Plugin","\u002Fexamples\u002Fvite-nitro-plugin","4.examples\u002Fvite-nitro-plugin",{"title":384,"path":385,"stem":386,"icon":387},"Vite RSC","\u002Fexamples\u002Fvite-rsc","4.examples\u002Fvite-rsc","i-logos-react",{"title":389,"path":390,"stem":391,"icon":392},"Vite SSR HTML","\u002Fexamples\u002Fvite-ssr-html","4.examples\u002Fvite-ssr-html","i-logos-html-5",{"title":394,"path":395,"stem":396,"icon":397},"SSR with Preact","\u002Fexamples\u002Fvite-ssr-preact","4.examples\u002Fvite-ssr-preact","i-logos-preact",{"title":399,"path":400,"stem":401,"icon":387},"SSR with React","\u002Fexamples\u002Fvite-ssr-react","4.examples\u002Fvite-ssr-react",{"title":403,"path":404,"stem":405,"icon":406},"SSR with SolidJS","\u002Fexamples\u002Fvite-ssr-solid","4.examples\u002Fvite-ssr-solid","i-logos-solidjs-icon",{"title":408,"path":409,"stem":410,"icon":411},"SSR with TanStack Router","\u002Fexamples\u002Fvite-ssr-tsr-react","4.examples\u002Fvite-ssr-tsr-react","i-simple-icons-tanstack",{"title":413,"path":414,"stem":415,"icon":411},"SSR with TanStack Start","\u002Fexamples\u002Fvite-ssr-tss-react","4.examples\u002Fvite-ssr-tss-react",{"title":417,"path":418,"stem":419,"icon":420},"SSR with Vue Router","\u002Fexamples\u002Fvite-ssr-vue-router","4.examples\u002Fvite-ssr-vue-router","i-logos-vue",{"title":422,"path":423,"stem":424,"icon":425},"Vite + tRPC","\u002Fexamples\u002Fvite-trpc","4.examples\u002Fvite-trpc","i-simple-icons-trpc",{"title":68,"path":427,"stem":428,"icon":429},"\u002Fexamples\u002Fwebsocket","4.examples\u002Fwebsocket","i-lucide-radio",{"title":431,"path":432,"stem":433,"children":434},"Blog","\u002Fblog","9.blog",[435,438],{"title":431,"path":432,"stem":436,"icon":437},"9.blog\u002Findex","i-lucide-file-text",{"title":439,"path":440,"stem":441,"icon":437},"Nitro v3 Beta is here!","\u002Fblog\u002Fv3-beta","9.blog\u002F1.v3-beta",{"title":5,"path":443,"stem":444},"\u002F","index",{"id":446,"title":43,"body":447,"description":2118,"extension":2119,"meta":2120,"navigation":2121,"path":44,"seo":2122,"stem":45,"__hash__":2123},"content\u002F1.docs\u002F50.lifecycle.md",{"type":448,"value":449,"toc":2095,"icon":46},"minimark",[450,455,459,1148,1152,1155,1172,1176,1183,1350,1367,1371,1374,1442,1453,1457,1467,1624,1633,1684,1695,1700,1706,1760,1764,1773,1871,1885,1898,1902,1909,1985,1989,1999,2078,2086,2091],[451,452,454],"h2",{"id":453},"request-lifecycle","Request lifecycle",[456,457,458],"p",{},"A request can be intercepted and terminated (with or without a response) from any of these layers, in this order:",[460,461,462,471,482,622,638,642,650,720,724,728,740,758,765,769,776,839,845,851,855,866,870,877,908,914,918,925,1000,1005,1008,1011,1016,1022,1032,1141],"steps",{},[463,464,466,470],"h3",{"id":465},"request-hook",[467,468,469],"code",{},"request"," hook",[456,472,473,474,476,477,481],{},"The ",[467,475,469],{}," hook is the first code that runs for every incoming request. It is registered via a ",[478,479,480],"a",{"href":54},"runtime plugin",":",[483,484,489],"pre",{"className":485,"code":486,"filename":487,"language":488,"meta":5,"style":5},"language-ts shiki shiki-themes github-light github-dark github-dark","import { definePlugin } from \"nitro\";\n\nexport default definePlugin((nitroApp) => {\n  nitroApp.hooks.hook(\"request\", (event) => {\n    console.log(`Incoming request on ${event.req.url}`);\n  });\n});\n","plugins\u002Frequest-hook.ts","ts",[467,490,491,514,521,550,577,610,616],{"__ignoreMap":5},[492,493,496,500,504,507,511],"span",{"class":494,"line":495},"line",1,[492,497,499],{"class":498},"so5gQ","import",[492,501,503],{"class":502},"slsVL"," { definePlugin } ",[492,505,506],{"class":498},"from",[492,508,510],{"class":509},"sfrk1"," \"nitro\"",[492,512,513],{"class":502},";\n",[492,515,517],{"class":494,"line":516},2,[492,518,520],{"emptyLinePlaceholder":519},true,"\n",[492,522,524,527,530,534,537,541,544,547],{"class":494,"line":523},3,[492,525,526],{"class":498},"export",[492,528,529],{"class":498}," default",[492,531,533],{"class":532},"shcOC"," definePlugin",[492,535,536],{"class":502},"((",[492,538,540],{"class":539},"sQHwn","nitroApp",[492,542,543],{"class":502},") ",[492,545,546],{"class":498},"=>",[492,548,549],{"class":502}," {\n",[492,551,553,556,559,562,565,568,571,573,575],{"class":494,"line":552},4,[492,554,555],{"class":502},"  nitroApp.hooks.",[492,557,558],{"class":532},"hook",[492,560,561],{"class":502},"(",[492,563,564],{"class":509},"\"request\"",[492,566,567],{"class":502},", (",[492,569,570],{"class":539},"event",[492,572,543],{"class":502},[492,574,546],{"class":498},[492,576,549],{"class":502},[492,578,580,583,586,588,591,593,596,599,601,604,607],{"class":494,"line":579},5,[492,581,582],{"class":502},"    console.",[492,584,585],{"class":532},"log",[492,587,561],{"class":502},[492,589,590],{"class":509},"`Incoming request on ${",[492,592,570],{"class":502},[492,594,595],{"class":509},".",[492,597,598],{"class":502},"req",[492,600,595],{"class":509},[492,602,603],{"class":502},"url",[492,605,606],{"class":509},"}`",[492,608,609],{"class":502},");\n",[492,611,613],{"class":494,"line":612},6,[492,614,615],{"class":502},"  });\n",[492,617,619],{"class":494,"line":618},7,[492,620,621],{"class":502},"});\n",[623,624,625],"note",{},[456,626,627,628,630,631,637],{},"Errors thrown inside the ",[467,629,469],{}," hook are captured by the ",[478,632,634,470],{"href":633},"#error-handling",[467,635,636],{},"error"," and do not terminate the request pipeline.",[463,639,641],{"id":640},"route-rules","Route rules",[456,643,644,645,649],{},"Matching ",[478,646,648],{"href":647},"\u002Fdocs\u002Frouting#route-rules","route rules"," from the Nitro config execute next. Route rules run as middleware, before any global middleware, and most of them alter the response without terminating it (for instance, adding a header or setting a cache policy).",[483,651,654],{"className":485,"code":652,"filename":653,"language":488,"meta":5,"style":5},"import { defineConfig } from \"nitro\";\n\nexport default defineConfig({\n  routeRules: {\n    '\u002F**': { headers: { 'x-nitro': 'first' } }\n  }\n})\n","nitro.config.ts",[467,655,656,669,673,685,690,710,715],{"__ignoreMap":5},[492,657,658,660,663,665,667],{"class":494,"line":495},[492,659,499],{"class":498},[492,661,662],{"class":502}," { defineConfig } ",[492,664,506],{"class":498},[492,666,510],{"class":509},[492,668,513],{"class":502},[492,670,671],{"class":494,"line":516},[492,672,520],{"emptyLinePlaceholder":519},[492,674,675,677,679,682],{"class":494,"line":523},[492,676,526],{"class":498},[492,678,529],{"class":498},[492,680,681],{"class":532}," defineConfig",[492,683,684],{"class":502},"({\n",[492,686,687],{"class":494,"line":552},[492,688,689],{"class":502},"  routeRules: {\n",[492,691,692,695,698,701,704,707],{"class":494,"line":579},[492,693,694],{"class":509},"    '\u002F**'",[492,696,697],{"class":502},": { headers: { ",[492,699,700],{"class":509},"'x-nitro'",[492,702,703],{"class":502},": ",[492,705,706],{"class":509},"'first'",[492,708,709],{"class":502}," } }\n",[492,711,712],{"class":494,"line":612},[492,713,714],{"class":502},"  }\n",[492,716,717],{"class":494,"line":618},[492,718,719],{"class":502},"})\n",[721,722],"read-more",{"to":647,"title":723},"Routing > Route rules",[463,725,727],{"id":726},"static-assets","Static assets",[456,729,730,731,735,736,739],{},"When static asset serving is enabled (the default for most presets), Nitro registers a static assets handler as the ",[732,733,734],"strong",{},"first global middleware",". It checks if the request matches a file in the ",[467,737,738],{},"public\u002F"," directory before other global middleware and route handlers run.",[456,741,742,743,746,747,746,750,753,754,757],{},"If a match is found, the static file is served immediately with appropriate ",[467,744,745],{},"Content-Type",", ",[467,748,749],{},"ETag",[467,751,752],{},"Last-Modified",", and ",[467,755,756],{},"Cache-Control"," headers. The request is terminated and no further middleware or routes are executed.",[456,759,760,761,764],{},"Static assets also support content negotiation for pre-compressed files (gzip, brotli, zstd) via the ",[467,762,763],{},"Accept-Encoding"," header.",[463,766,768],{"id":767},"global-middleware","Global middleware",[456,770,771,772,775],{},"Any global middleware defined in the ",[467,773,774],{},"middleware\u002F"," directory runs next:",[483,777,780],{"className":485,"code":778,"filename":779,"language":488,"meta":5,"style":5},"import { defineHandler } from \"nitro\";\n\nexport default defineHandler((event) => {\n  event.context.info = { name: \"Nitro\" };\n});\n","middleware\u002Finfo.ts",[467,781,782,795,799,818,835],{"__ignoreMap":5},[492,783,784,786,789,791,793],{"class":494,"line":495},[492,785,499],{"class":498},[492,787,788],{"class":502}," { defineHandler } ",[492,790,506],{"class":498},[492,792,510],{"class":509},[492,794,513],{"class":502},[492,796,797],{"class":494,"line":516},[492,798,520],{"emptyLinePlaceholder":519},[492,800,801,803,805,808,810,812,814,816],{"class":494,"line":523},[492,802,526],{"class":498},[492,804,529],{"class":498},[492,806,807],{"class":532}," defineHandler",[492,809,536],{"class":502},[492,811,570],{"class":539},[492,813,543],{"class":502},[492,815,546],{"class":498},[492,817,549],{"class":502},[492,819,820,823,826,829,832],{"class":494,"line":552},[492,821,822],{"class":502},"  event.context.info ",[492,824,825],{"class":498},"=",[492,827,828],{"class":502}," { name: ",[492,830,831],{"class":509},"\"Nitro\"",[492,833,834],{"class":502}," };\n",[492,836,837],{"class":494,"line":579},[492,838,621],{"class":502},[840,841,842],"warning",{},[456,843,844],{},"Returning from a middleware will close the request and should be avoided when possible.",[721,846,848],{"to":847},"\u002Fdocs\u002Frouting#middleware",[456,849,850],{},"Learn more about Nitro middleware.",[463,852,854],{"id":853},"routed-middleware","Routed middleware",[456,856,857,858,865],{},"Middleware registered for a specific route pattern (via the ",[478,859,861,864],{"href":860},"\u002Fdocs\u002Frouting#route-scoped-middleware",[467,862,863],{},"handlers"," config",") runs after global middleware. Any middleware attached to the matched route itself runs last, right before the route handler.",[463,867,869],{"id":868},"routes","Routes",[456,871,872,873,876],{},"Nitro matches the incoming request against the routes defined in the ",[467,874,875],{},"routes\u002F"," folder.",[483,878,881],{"className":485,"code":879,"filename":880,"language":488,"meta":5,"style":5},"export default (event) => ({ world: true })\n","routes\u002Fapi\u002Fhello.ts",[467,882,883],{"__ignoreMap":5},[492,884,885,887,889,892,894,896,898,901,905],{"class":494,"line":495},[492,886,526],{"class":498},[492,888,529],{"class":498},[492,890,891],{"class":502}," (",[492,893,570],{"class":539},[492,895,543],{"class":502},[492,897,546],{"class":498},[492,899,900],{"class":502}," ({ world: ",[492,902,904],{"class":903},"suiK_","true",[492,906,907],{"class":502}," })\n",[721,909,911],{"to":910},"\u002Fdocs\u002Frouting#filesystem-routing",[456,912,913],{},"Learn more about Nitro filesystem routing.",[463,915,917],{"id":916},"server-entry","Server entry",[456,919,920,921,924],{},"If a server entry is defined, it catches all requests not matched by any route, acting as a ",[467,922,923],{},"\u002F**"," route handler.",[483,926,929],{"className":485,"code":927,"filename":928,"language":488,"meta":5,"style":5},"import { defineHandler } from \"nitro\";\n\nexport default defineHandler((event) => {\n  if (event.url.pathname === \"\u002F\") {\n    return \"Home page\";\n  }\n});\n","server.ts",[467,930,931,943,947,965,982,992,996],{"__ignoreMap":5},[492,932,933,935,937,939,941],{"class":494,"line":495},[492,934,499],{"class":498},[492,936,788],{"class":502},[492,938,506],{"class":498},[492,940,510],{"class":509},[492,942,513],{"class":502},[492,944,945],{"class":494,"line":516},[492,946,520],{"emptyLinePlaceholder":519},[492,948,949,951,953,955,957,959,961,963],{"class":494,"line":523},[492,950,526],{"class":498},[492,952,529],{"class":498},[492,954,807],{"class":532},[492,956,536],{"class":502},[492,958,570],{"class":539},[492,960,543],{"class":502},[492,962,546],{"class":498},[492,964,549],{"class":502},[492,966,967,970,973,976,979],{"class":494,"line":552},[492,968,969],{"class":498},"  if",[492,971,972],{"class":502}," (event.url.pathname ",[492,974,975],{"class":498},"===",[492,977,978],{"class":509}," \"\u002F\"",[492,980,981],{"class":502},") {\n",[492,983,984,987,990],{"class":494,"line":579},[492,985,986],{"class":498},"    return",[492,988,989],{"class":509}," \"Home page\"",[492,991,513],{"class":502},[492,993,994],{"class":494,"line":612},[492,995,714],{"class":502},[492,997,998],{"class":494,"line":618},[492,999,621],{"class":502},[721,1001,1002],{"to":79},[456,1003,1004],{},"Learn more about the Nitro server entry.",[463,1006,18],{"id":1007},"renderer",[456,1009,1010],{},"If no route is matched, Nitro will look for a renderer handler (defined or auto-detected) to handle the request.",[721,1012,1013],{"to":19},[456,1014,1015],{},"Learn more about Nitro renderer.",[463,1017,1019,470],{"id":1018},"response-hook",[467,1020,1021],{},"response",[456,1023,1024,1025,1027,1028,1031],{},"After the response is created (from any of the layers above), the ",[467,1026,1021],{}," hook runs. This hook receives the final ",[467,1029,1030],{},"Response"," object and the event, and can be used to inspect or modify response headers:",[483,1033,1036],{"className":485,"code":1034,"filename":1035,"language":488,"meta":5,"style":5},"import { definePlugin } from \"nitro\";\n\nexport default definePlugin((nitroApp) => {\n  nitroApp.hooks.hook(\"response\", (res, event) => {\n    console.log(`Response ${res.status} for ${event.req.url}`);\n  });\n});\n","plugins\u002Fresponse-hook.ts",[467,1037,1038,1050,1054,1072,1098,1133,1137],{"__ignoreMap":5},[492,1039,1040,1042,1044,1046,1048],{"class":494,"line":495},[492,1041,499],{"class":498},[492,1043,503],{"class":502},[492,1045,506],{"class":498},[492,1047,510],{"class":509},[492,1049,513],{"class":502},[492,1051,1052],{"class":494,"line":516},[492,1053,520],{"emptyLinePlaceholder":519},[492,1055,1056,1058,1060,1062,1064,1066,1068,1070],{"class":494,"line":523},[492,1057,526],{"class":498},[492,1059,529],{"class":498},[492,1061,533],{"class":532},[492,1063,536],{"class":502},[492,1065,540],{"class":539},[492,1067,543],{"class":502},[492,1069,546],{"class":498},[492,1071,549],{"class":502},[492,1073,1074,1076,1078,1080,1083,1085,1088,1090,1092,1094,1096],{"class":494,"line":552},[492,1075,555],{"class":502},[492,1077,558],{"class":532},[492,1079,561],{"class":502},[492,1081,1082],{"class":509},"\"response\"",[492,1084,567],{"class":502},[492,1086,1087],{"class":539},"res",[492,1089,746],{"class":502},[492,1091,570],{"class":539},[492,1093,543],{"class":502},[492,1095,546],{"class":498},[492,1097,549],{"class":502},[492,1099,1100,1102,1104,1106,1109,1111,1113,1116,1119,1121,1123,1125,1127,1129,1131],{"class":494,"line":579},[492,1101,582],{"class":502},[492,1103,585],{"class":532},[492,1105,561],{"class":502},[492,1107,1108],{"class":509},"`Response ${",[492,1110,1087],{"class":502},[492,1112,595],{"class":509},[492,1114,1115],{"class":502},"status",[492,1117,1118],{"class":509},"} for ${",[492,1120,570],{"class":502},[492,1122,595],{"class":509},[492,1124,598],{"class":502},[492,1126,595],{"class":509},[492,1128,603],{"class":502},[492,1130,606],{"class":509},[492,1132,609],{"class":502},[492,1134,1135],{"class":494,"line":612},[492,1136,615],{"class":502},[492,1138,1139],{"class":494,"line":618},[492,1140,621],{"class":502},[623,1142,1143],{},[456,1144,473,1145,1147],{},[467,1146,1021],{}," hook runs for every response, including static assets, middleware-terminated requests, and error responses.",[451,1149,1151],{"id":1150},"error-handling","Error handling",[456,1153,1154],{},"When an error occurs at any point in the request lifecycle, Nitro:",[460,1156,1158,1165],{"level":1157},"4",[1159,1160,1161,1162,1164],"h4",{},"Calls the ",[467,1163,636],{}," hook with the error and context (including the event and source tags).",[1159,1166,1167,1168,1171],{},"Passes the error to the ",[732,1169,1170],{},"error handler"," which converts it into an HTTP response.",[463,1173,1175],{"id":1174},"throwing-errors","Throwing errors",[456,1177,1178,1179,1182],{},"Throw an ",[467,1180,1181],{},"HTTPError"," from any handler or middleware to end the request with a specific status code, message, and optional data:",[483,1184,1187],{"className":485,"code":1185,"filename":1186,"language":488,"meta":5,"style":5},"import { defineHandler, HTTPError } from \"nitro\";\n\nexport default defineHandler((event) => {\n  \u002F\u002F Message and details\n  throw new HTTPError(\"Invalid user input\", { status: 400 });\n\n  \u002F\u002F Status code shortcut\n  throw HTTPError.status(400, \"Bad Request\");\n\n  \u002F\u002F Full object form\n  throw new HTTPError({\n    status: 400,\n    message: \"Invalid user input\",\n    data: { field: \"email\" },\n  });\n});\n","routes\u002Fsignup.ts",[467,1188,1189,1202,1206,1224,1230,1255,1259,1264,1285,1290,1296,1307,1318,1328,1340,1345],{"__ignoreMap":5},[492,1190,1191,1193,1196,1198,1200],{"class":494,"line":495},[492,1192,499],{"class":498},[492,1194,1195],{"class":502}," { defineHandler, HTTPError } ",[492,1197,506],{"class":498},[492,1199,510],{"class":509},[492,1201,513],{"class":502},[492,1203,1204],{"class":494,"line":516},[492,1205,520],{"emptyLinePlaceholder":519},[492,1207,1208,1210,1212,1214,1216,1218,1220,1222],{"class":494,"line":523},[492,1209,526],{"class":498},[492,1211,529],{"class":498},[492,1213,807],{"class":532},[492,1215,536],{"class":502},[492,1217,570],{"class":539},[492,1219,543],{"class":502},[492,1221,546],{"class":498},[492,1223,549],{"class":502},[492,1225,1226],{"class":494,"line":552},[492,1227,1229],{"class":1228},"sCsY4","  \u002F\u002F Message and details\n",[492,1231,1232,1235,1238,1241,1243,1246,1249,1252],{"class":494,"line":579},[492,1233,1234],{"class":498},"  throw",[492,1236,1237],{"class":498}," new",[492,1239,1240],{"class":532}," HTTPError",[492,1242,561],{"class":502},[492,1244,1245],{"class":509},"\"Invalid user input\"",[492,1247,1248],{"class":502},", { status: ",[492,1250,1251],{"class":903},"400",[492,1253,1254],{"class":502}," });\n",[492,1256,1257],{"class":494,"line":612},[492,1258,520],{"emptyLinePlaceholder":519},[492,1260,1261],{"class":494,"line":618},[492,1262,1263],{"class":1228},"  \u002F\u002F Status code shortcut\n",[492,1265,1267,1269,1272,1274,1276,1278,1280,1283],{"class":494,"line":1266},8,[492,1268,1234],{"class":498},[492,1270,1271],{"class":502}," HTTPError.",[492,1273,1115],{"class":532},[492,1275,561],{"class":502},[492,1277,1251],{"class":903},[492,1279,746],{"class":502},[492,1281,1282],{"class":509},"\"Bad Request\"",[492,1284,609],{"class":502},[492,1286,1288],{"class":494,"line":1287},9,[492,1289,520],{"emptyLinePlaceholder":519},[492,1291,1293],{"class":494,"line":1292},10,[492,1294,1295],{"class":1228},"  \u002F\u002F Full object form\n",[492,1297,1299,1301,1303,1305],{"class":494,"line":1298},11,[492,1300,1234],{"class":498},[492,1302,1237],{"class":498},[492,1304,1240],{"class":532},[492,1306,684],{"class":502},[492,1308,1310,1313,1315],{"class":494,"line":1309},12,[492,1311,1312],{"class":502},"    status: ",[492,1314,1251],{"class":903},[492,1316,1317],{"class":502},",\n",[492,1319,1321,1324,1326],{"class":494,"line":1320},13,[492,1322,1323],{"class":502},"    message: ",[492,1325,1245],{"class":509},[492,1327,1317],{"class":502},[492,1329,1331,1334,1337],{"class":494,"line":1330},14,[492,1332,1333],{"class":502},"    data: { field: ",[492,1335,1336],{"class":509},"\"email\"",[492,1338,1339],{"class":502}," },\n",[492,1341,1343],{"class":494,"line":1342},15,[492,1344,615],{"class":502},[492,1346,1348],{"class":494,"line":1347},16,[492,1349,621],{"class":502},[623,1351,1352],{},[456,1353,1354,1355,1358,1359,1362,1363,1366],{},"Any other thrown value (such as a plain ",[467,1356,1357],{},"new Error()",") is treated as an ",[732,1360,1361],{},"unhandled"," error: the response is always ",[467,1364,1365],{},"500"," and the message, data, and stack are hidden from the client for security.",[463,1368,1370],{"id":1369},"default-error-responses","Default error responses",[456,1372,1373],{},"In production, the default error handler always responds with JSON:",[483,1375,1379],{"className":1376,"code":1377,"language":1378,"meta":5,"style":5},"language-json shiki shiki-themes github-light github-dark github-dark","{\n  \"error\": true,\n  \"status\": 400,\n  \"message\": \"Invalid user input\",\n  \"data\": { \"field\": \"email\" }\n}\n","json",[467,1380,1381,1386,1397,1408,1419,1437],{"__ignoreMap":5},[492,1382,1383],{"class":494,"line":495},[492,1384,1385],{"class":502},"{\n",[492,1387,1388,1391,1393,1395],{"class":494,"line":516},[492,1389,1390],{"class":903},"  \"error\"",[492,1392,703],{"class":502},[492,1394,904],{"class":903},[492,1396,1317],{"class":502},[492,1398,1399,1402,1404,1406],{"class":494,"line":523},[492,1400,1401],{"class":903},"  \"status\"",[492,1403,703],{"class":502},[492,1405,1251],{"class":903},[492,1407,1317],{"class":502},[492,1409,1410,1413,1415,1417],{"class":494,"line":552},[492,1411,1412],{"class":903},"  \"message\"",[492,1414,703],{"class":502},[492,1416,1245],{"class":509},[492,1418,1317],{"class":502},[492,1420,1421,1424,1427,1430,1432,1434],{"class":494,"line":579},[492,1422,1423],{"class":903},"  \"data\"",[492,1425,1426],{"class":502},": { ",[492,1428,1429],{"class":903},"\"field\"",[492,1431,703],{"class":502},[492,1433,1336],{"class":509},[492,1435,1436],{"class":502}," }\n",[492,1438,1439],{"class":494,"line":612},[492,1440,1441],{"class":502},"}\n",[456,1443,1444,1445,1448,1449,1452],{},"In development, programmatic requests receive the same JSON format, but when the request's ",[467,1446,1447],{},"Accept"," header includes ",[467,1450,1451],{},"text\u002Fhtml"," (browsers), Nitro renders an interactive HTML error page with a source-mapped stack trace.",[463,1454,1456],{"id":1455},"custom-error-handlers","Custom error handlers",[456,1458,1459,1460,1463,1464,481],{},"To control error response formatting, set ",[467,1461,1462],{},"errorHandler"," in the Nitro config to a file that exports a handler with ",[467,1465,1466],{},"defineErrorHandler",[1468,1469,1470,1515],"CodeGroup",{},[483,1471,1473],{"className":485,"code":1472,"filename":653,"language":488,"meta":5,"style":5},"import { defineConfig } from \"nitro\";\n\nexport default defineConfig({\n  errorHandler: \"~\u002Ferror\",\n});\n",[467,1474,1475,1487,1491,1501,1511],{"__ignoreMap":5},[492,1476,1477,1479,1481,1483,1485],{"class":494,"line":495},[492,1478,499],{"class":498},[492,1480,662],{"class":502},[492,1482,506],{"class":498},[492,1484,510],{"class":509},[492,1486,513],{"class":502},[492,1488,1489],{"class":494,"line":516},[492,1490,520],{"emptyLinePlaceholder":519},[492,1492,1493,1495,1497,1499],{"class":494,"line":523},[492,1494,526],{"class":498},[492,1496,529],{"class":498},[492,1498,681],{"class":532},[492,1500,684],{"class":502},[492,1502,1503,1506,1509],{"class":494,"line":552},[492,1504,1505],{"class":502},"  errorHandler: ",[492,1507,1508],{"class":509},"\"~\u002Ferror\"",[492,1510,1317],{"class":502},[492,1512,1513],{"class":494,"line":579},[492,1514,621],{"class":502},[483,1516,1519],{"className":485,"code":1517,"filename":1518,"language":488,"meta":5,"style":5},"import { defineErrorHandler } from \"nitro\";\n\nexport default defineErrorHandler((error, event) => {\n  return new Response(`[custom error] ${error.message}`, {\n    status: error.status || 500,\n    headers: { \"Content-Type\": \"text\u002Fplain\" },\n  });\n});\n","error.ts",[467,1520,1521,1534,1538,1561,1588,1601,1616,1620],{"__ignoreMap":5},[492,1522,1523,1525,1528,1530,1532],{"class":494,"line":495},[492,1524,499],{"class":498},[492,1526,1527],{"class":502}," { defineErrorHandler } ",[492,1529,506],{"class":498},[492,1531,510],{"class":509},[492,1533,513],{"class":502},[492,1535,1536],{"class":494,"line":516},[492,1537,520],{"emptyLinePlaceholder":519},[492,1539,1540,1542,1544,1547,1549,1551,1553,1555,1557,1559],{"class":494,"line":523},[492,1541,526],{"class":498},[492,1543,529],{"class":498},[492,1545,1546],{"class":532}," defineErrorHandler",[492,1548,536],{"class":502},[492,1550,636],{"class":539},[492,1552,746],{"class":502},[492,1554,570],{"class":539},[492,1556,543],{"class":502},[492,1558,546],{"class":498},[492,1560,549],{"class":502},[492,1562,1563,1566,1568,1571,1573,1576,1578,1580,1583,1585],{"class":494,"line":552},[492,1564,1565],{"class":498},"  return",[492,1567,1237],{"class":498},[492,1569,1570],{"class":532}," Response",[492,1572,561],{"class":502},[492,1574,1575],{"class":509},"`[custom error] ${",[492,1577,636],{"class":502},[492,1579,595],{"class":509},[492,1581,1582],{"class":502},"message",[492,1584,606],{"class":509},[492,1586,1587],{"class":502},", {\n",[492,1589,1590,1593,1596,1599],{"class":494,"line":579},[492,1591,1592],{"class":502},"    status: error.status ",[492,1594,1595],{"class":498},"||",[492,1597,1598],{"class":903}," 500",[492,1600,1317],{"class":502},[492,1602,1603,1606,1609,1611,1614],{"class":494,"line":612},[492,1604,1605],{"class":502},"    headers: { ",[492,1607,1608],{"class":509},"\"Content-Type\"",[492,1610,703],{"class":502},[492,1612,1613],{"class":509},"\"text\u002Fplain\"",[492,1615,1339],{"class":502},[492,1617,1618],{"class":494,"line":618},[492,1619,615],{"class":502},[492,1621,1622],{"class":494,"line":1266},[492,1623,621],{"class":502},[456,1625,1626,1627,1629,1630,1632],{},"Return a ",[467,1628,1030],{}," to send it to the client, or return nothing to fall through to the next handler. ",[467,1631,1462],{}," also accepts an array of handlers that run in order — the first one that returns a response wins, and the built-in default handler is always appended as the last entry, so there is always a fallback response:",[483,1634,1636],{"className":485,"code":1635,"filename":653,"language":488,"meta":5,"style":5},"import { defineConfig } from \"nitro\";\n\nexport default defineConfig({\n  errorHandler: [\"~\u002Ferror\u002Fknown-errors\", \"~\u002Ferror\u002Ffallback\"],\n});\n",[467,1637,1638,1650,1654,1664,1680],{"__ignoreMap":5},[492,1639,1640,1642,1644,1646,1648],{"class":494,"line":495},[492,1641,499],{"class":498},[492,1643,662],{"class":502},[492,1645,506],{"class":498},[492,1647,510],{"class":509},[492,1649,513],{"class":502},[492,1651,1652],{"class":494,"line":516},[492,1653,520],{"emptyLinePlaceholder":519},[492,1655,1656,1658,1660,1662],{"class":494,"line":523},[492,1657,526],{"class":498},[492,1659,529],{"class":498},[492,1661,681],{"class":532},[492,1663,684],{"class":502},[492,1665,1666,1669,1672,1674,1677],{"class":494,"line":552},[492,1667,1668],{"class":502},"  errorHandler: [",[492,1670,1671],{"class":509},"\"~\u002Ferror\u002Fknown-errors\"",[492,1673,746],{"class":502},[492,1675,1676],{"class":509},"\"~\u002Ferror\u002Ffallback\"",[492,1678,1679],{"class":502},"],\n",[492,1681,1682],{"class":494,"line":579},[492,1683,621],{"class":502},[456,1685,1686,1687,1690,1691,1694],{},"If a handler itself throws, the failure is logged and the chain continues with the next handler. Each handler also receives the built-in ",[467,1688,1689],{},"defaultHandler"," as ",[467,1692,1693],{},"{ defaultHandler }"," in its third argument, so you can reuse the default rendering within your own logic.",[721,1696,1697],{"to":290},[456,1698,1699],{},"See a full custom error handler example.",[456,1701,1702,1703,481],{},"To customize error rendering for the development server only (without affecting the production bundle), pass a handler function as ",[467,1704,1705],{},"devErrorHandler",[483,1707,1709],{"className":485,"code":1708,"filename":653,"language":488,"meta":5,"style":5},"import { defineConfig } from \"nitro\";\nimport errorHandler from \".\u002Ferror.ts\";\n\nexport default defineConfig({\n  devErrorHandler: errorHandler,\n});\n",[467,1710,1711,1723,1737,1741,1751,1756],{"__ignoreMap":5},[492,1712,1713,1715,1717,1719,1721],{"class":494,"line":495},[492,1714,499],{"class":498},[492,1716,662],{"class":502},[492,1718,506],{"class":498},[492,1720,510],{"class":509},[492,1722,513],{"class":502},[492,1724,1725,1727,1730,1732,1735],{"class":494,"line":516},[492,1726,499],{"class":498},[492,1728,1729],{"class":502}," errorHandler ",[492,1731,506],{"class":498},[492,1733,1734],{"class":509}," \".\u002Ferror.ts\"",[492,1736,513],{"class":502},[492,1738,1739],{"class":494,"line":523},[492,1740,520],{"emptyLinePlaceholder":519},[492,1742,1743,1745,1747,1749],{"class":494,"line":552},[492,1744,526],{"class":498},[492,1746,529],{"class":498},[492,1748,681],{"class":532},[492,1750,684],{"class":502},[492,1752,1753],{"class":494,"line":579},[492,1754,1755],{"class":502},"  devErrorHandler: errorHandler,\n",[492,1757,1758],{"class":494,"line":612},[492,1759,621],{"class":502},[463,1761,1763],{"id":1762},"observing-errors","Observing errors",[456,1765,1766,1767,1769,1770,481],{},"To observe errors without changing the response, use the ",[467,1768,636],{}," runtime hook from a ",[478,1771,1772],{"href":54},"plugin",[483,1774,1777],{"className":485,"code":1775,"filename":1776,"language":488,"meta":5,"style":5},"import { definePlugin } from \"nitro\";\n\nexport default definePlugin((nitroApp) => {\n  nitroApp.hooks.hook(\"error\", (error, context) => {\n    console.error(\"Captured error:\", error);\n    \u002F\u002F context.event - the H3 event (if available)\n    \u002F\u002F context.tags  - error source tags like \"request\", \"response\", \"plugin\"\n  });\n});\n","plugins\u002Ferrors.ts",[467,1778,1779,1791,1795,1813,1839,1853,1858,1863,1867],{"__ignoreMap":5},[492,1780,1781,1783,1785,1787,1789],{"class":494,"line":495},[492,1782,499],{"class":498},[492,1784,503],{"class":502},[492,1786,506],{"class":498},[492,1788,510],{"class":509},[492,1790,513],{"class":502},[492,1792,1793],{"class":494,"line":516},[492,1794,520],{"emptyLinePlaceholder":519},[492,1796,1797,1799,1801,1803,1805,1807,1809,1811],{"class":494,"line":523},[492,1798,526],{"class":498},[492,1800,529],{"class":498},[492,1802,533],{"class":532},[492,1804,536],{"class":502},[492,1806,540],{"class":539},[492,1808,543],{"class":502},[492,1810,546],{"class":498},[492,1812,549],{"class":502},[492,1814,1815,1817,1819,1821,1824,1826,1828,1830,1833,1835,1837],{"class":494,"line":552},[492,1816,555],{"class":502},[492,1818,558],{"class":532},[492,1820,561],{"class":502},[492,1822,1823],{"class":509},"\"error\"",[492,1825,567],{"class":502},[492,1827,636],{"class":539},[492,1829,746],{"class":502},[492,1831,1832],{"class":539},"context",[492,1834,543],{"class":502},[492,1836,546],{"class":498},[492,1838,549],{"class":502},[492,1840,1841,1843,1845,1847,1850],{"class":494,"line":579},[492,1842,582],{"class":502},[492,1844,636],{"class":532},[492,1846,561],{"class":502},[492,1848,1849],{"class":509},"\"Captured error:\"",[492,1851,1852],{"class":502},", error);\n",[492,1854,1855],{"class":494,"line":612},[492,1856,1857],{"class":1228},"    \u002F\u002F context.event - the H3 event (if available)\n",[492,1859,1860],{"class":494,"line":618},[492,1861,1862],{"class":1228},"    \u002F\u002F context.tags  - error source tags like \"request\", \"response\", \"plugin\"\n",[492,1864,1865],{"class":494,"line":1266},[492,1866,615],{"class":502},[492,1868,1869],{"class":494,"line":1287},[492,1870,621],{"class":502},[456,1872,1873,1874,1880,1881,1884],{},"You can also feed errors into the same pipeline programmatically with ",[478,1875,1877],{"href":1876},"\u002Fdocs\u002Fplugins#programmatic-error-capture",[467,1878,1879],{},"nitroApp.captureError",". Errors are also tracked per-request in ",[467,1882,1883],{},"event.req.context.nitro.errors"," for inspection in later hooks.",[456,1886,1887,1888,1890,1891,1894,1895,595],{},"Additionally, unhandled promise rejections and uncaught exceptions at the process level are automatically captured into the ",[467,1889,636],{}," hook with the tags ",[467,1892,1893],{},"\"unhandledRejection\""," and ",[467,1896,1897],{},"\"uncaughtException\"",[451,1899,1901],{"id":1900},"server-shutdown","Server shutdown",[456,1903,1904,1905,1908],{},"When the Nitro server is shutting down, the ",[467,1906,1907],{},"close"," hook is called. Use this to clean up resources such as database connections, timers, or external service handles:",[483,1910,1913],{"className":485,"code":1911,"filename":1912,"language":488,"meta":5,"style":5},"import { definePlugin } from \"nitro\";\n\nexport default definePlugin((nitroApp) => {\n  nitroApp.hooks.hook(\"close\", async () => {\n    \u002F\u002F Clean up resources\n  });\n});\n","plugins\u002Fcleanup.ts",[467,1914,1915,1927,1931,1949,1972,1977,1981],{"__ignoreMap":5},[492,1916,1917,1919,1921,1923,1925],{"class":494,"line":495},[492,1918,499],{"class":498},[492,1920,503],{"class":502},[492,1922,506],{"class":498},[492,1924,510],{"class":509},[492,1926,513],{"class":502},[492,1928,1929],{"class":494,"line":516},[492,1930,520],{"emptyLinePlaceholder":519},[492,1932,1933,1935,1937,1939,1941,1943,1945,1947],{"class":494,"line":523},[492,1934,526],{"class":498},[492,1936,529],{"class":498},[492,1938,533],{"class":532},[492,1940,536],{"class":502},[492,1942,540],{"class":539},[492,1944,543],{"class":502},[492,1946,546],{"class":498},[492,1948,549],{"class":502},[492,1950,1951,1953,1955,1957,1960,1962,1965,1968,1970],{"class":494,"line":552},[492,1952,555],{"class":502},[492,1954,558],{"class":532},[492,1956,561],{"class":502},[492,1958,1959],{"class":509},"\"close\"",[492,1961,746],{"class":502},[492,1963,1964],{"class":498},"async",[492,1966,1967],{"class":502}," () ",[492,1969,546],{"class":498},[492,1971,549],{"class":502},[492,1973,1974],{"class":494,"line":579},[492,1975,1976],{"class":1228},"    \u002F\u002F Clean up resources\n",[492,1978,1979],{"class":494,"line":612},[492,1980,615],{"class":502},[492,1982,1983],{"class":494,"line":618},[492,1984,621],{"class":502},[451,1986,1988],{"id":1987},"hooks-reference","Hooks reference",[456,1990,1991,1992,1995,1996,595],{},"All runtime hooks are registered through ",[478,1993,1994],{"href":54},"runtime plugins"," using ",[467,1997,1998],{},"nitroApp.hooks.hook()",[2000,2001,2002,2018],"table",{},[2003,2004,2005],"thead",{},[2006,2007,2008,2012,2015],"tr",{},[2009,2010,2011],"th",{},"Hook",[2009,2013,2014],{},"Signature",[2009,2016,2017],{},"When it runs",[2019,2020,2021,2036,2050,2064],"tbody",{},[2006,2022,2023,2028,2033],{},[2024,2025,2026],"td",{},[467,2027,469],{},[2024,2029,2030],{},[467,2031,2032],{},"(event: HTTPEvent) => void | Promise\u003Cvoid>",[2024,2034,2035],{},"Start of each request, before routing.",[2006,2037,2038,2042,2047],{},[2024,2039,2040],{},[467,2041,1021],{},[2024,2043,2044],{},[467,2045,2046],{},"(res: Response, event: HTTPEvent) => void | Promise\u003Cvoid>",[2024,2048,2049],{},"After the response is created, before it is sent.",[2006,2051,2052,2056,2061],{},[2024,2053,2054],{},[467,2055,636],{},[2024,2057,2058],{},[467,2059,2060],{},"(error: Error, context: { event?, tags? }) => void",[2024,2062,2063],{},"When any error is captured during the lifecycle.",[2006,2065,2066,2070,2075],{},[2024,2067,2068],{},[467,2069,1907],{},[2024,2071,2072],{},[467,2073,2074],{},"() => void",[2024,2076,2077],{},"When the Nitro server is shutting down.",[623,2079,2080],{},[456,2081,473,2082,2085],{},[467,2083,2084],{},"NitroRuntimeHooks"," interface is augmentable. Deployment presets (such as Cloudflare) can extend it with platform-specific hooks.",[721,2087,2088],{"to":54},[456,2089,2090],{},"Learn more about Nitro plugins and hook usage examples.",[2092,2093,2094],"style",{},"html pre.shiki code .so5gQ, html code.shiki .so5gQ{--shiki-light:#D73A49;--shiki-default:#F97583;--shiki-dark:#F97583}html pre.shiki code .slsVL, html code.shiki .slsVL{--shiki-light:#24292E;--shiki-default:#E1E4E8;--shiki-dark:#E1E4E8}html pre.shiki code .sfrk1, html code.shiki .sfrk1{--shiki-light:#032F62;--shiki-default:#9ECBFF;--shiki-dark:#9ECBFF}html pre.shiki code .shcOC, html code.shiki .shcOC{--shiki-light:#6F42C1;--shiki-default:#B392F0;--shiki-dark:#B392F0}html pre.shiki code .sQHwn, html code.shiki .sQHwn{--shiki-light:#E36209;--shiki-default:#FFAB70;--shiki-dark:#FFAB70}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);}html pre.shiki code .suiK_, html code.shiki .suiK_{--shiki-light:#005CC5;--shiki-default:#79B8FF;--shiki-dark:#79B8FF}html pre.shiki code .sCsY4, html code.shiki .sCsY4{--shiki-light:#6A737D;--shiki-default:#6A737D;--shiki-dark:#6A737D}",{"title":5,"searchDepth":516,"depth":516,"links":2096},[2097,2110,2116,2117],{"id":453,"depth":516,"text":454,"children":2098},[2099,2101,2102,2103,2104,2105,2106,2107,2108],{"id":465,"depth":523,"text":2100},"request hook",{"id":640,"depth":523,"text":641},{"id":726,"depth":523,"text":727},{"id":767,"depth":523,"text":768},{"id":853,"depth":523,"text":854},{"id":868,"depth":523,"text":869},{"id":916,"depth":523,"text":917},{"id":1007,"depth":523,"text":18},{"id":1018,"depth":523,"text":2109},"response hook",{"id":1150,"depth":516,"text":1151,"children":2111},[2112,2113,2114,2115],{"id":1174,"depth":523,"text":1175},{"id":1369,"depth":523,"text":1370},{"id":1455,"depth":523,"text":1456},{"id":1762,"depth":523,"text":1763},{"id":1900,"depth":516,"text":1901},{"id":1987,"depth":516,"text":1988},"Understand how Nitro runs and serves incoming requests to your application.","md",{"icon":46},{"icon":46},{"title":43,"description":2118},"UjuUcZxtokZvAK6-kaV2vXblEvufdUkdfNDpiojhbcM",[2125,2127],{"title":38,"path":39,"stem":40,"description":2126,"icon":41,"children":-1},"Nitro provides a built-in and lightweight SQL database layer.",{"title":48,"path":49,"stem":50,"description":2128,"icon":51,"children":-1},"Nitro can automatically generate an OpenAPI specification from your route handlers and serve interactive API documentation.",1784019071915]