[{"data":1,"prerenderedAt":1506},["ShallowReactive",2],{"navigation":3,"-docs-lifecycle":402,"-docs-lifecycle-surround":1501},[4,93,226,232,387,399],{"title":5,"path":6,"stem":7,"children":8,"icon":92},"","/docs","1.docs/1.index",[9,12,17,22,27,32,37,42,47,52,57,62,67,72,77,82,87],{"title":10,"path":6,"stem":7,"icon":11},"Introduction","i-lucide-compass",{"title":13,"path":14,"stem":15,"icon":16},"Quick Start","/docs/quick-start","1.docs/2.quick-start","i-lucide-zap",{"title":18,"path":19,"stem":20,"icon":21},"Renderer","/docs/renderer","1.docs/4.renderer","ri:layout-masonry-line",{"title":23,"path":24,"stem":25,"icon":26},"Routing","/docs/routing","1.docs/5.routing","ri:direction-line",{"title":28,"path":29,"stem":30,"icon":31},"Assets","/docs/assets","1.docs/50.assets","ri:image-2-line",{"title":33,"path":34,"stem":35,"icon":36},"Configuration","/docs/configuration","1.docs/50.configuration","ri:settings-3-line",{"title":38,"path":39,"stem":40,"icon":41},"Database","/docs/database","1.docs/50.database","ri:database-2-line",{"title":43,"path":44,"stem":45,"icon":46},"Lifecycle","/docs/lifecycle","1.docs/50.lifecycle","i-lucide-layers",{"title":48,"path":49,"stem":50,"icon":51},"OpenAPI","/docs/openapi","1.docs/50.openapi","ri:contract-line",{"title":53,"path":54,"stem":55,"icon":56},"Plugins","/docs/plugins","1.docs/50.plugins","ri:plug-line",{"title":58,"path":59,"stem":60,"icon":61},"Tasks","/docs/tasks","1.docs/50.tasks","codicon:run-all",{"title":63,"path":64,"stem":65,"icon":66},"WebSocket","/docs/websocket","1.docs/50.websocket","ri:broadcast-fill",{"title":68,"path":69,"stem":70,"icon":71},"Server Entry","/docs/server-entry","1.docs/6.server-entry","ri:server-line",{"title":73,"path":74,"stem":75,"icon":76},"Cache","/docs/cache","1.docs/7.cache","ri:speed-line",{"title":78,"path":79,"stem":80,"icon":81},"KV Storage","/docs/storage","1.docs/8.storage","carbon:datastore",{"title":83,"path":84,"stem":85,"icon":86},"Migration Guide","/docs/migration","1.docs/99.migration","ri:arrow-right-up-line",{"title":88,"path":89,"stem":90,"icon":91},"Nightly Channel","/docs/nightly","1.docs/99.nightly","ri:moon-fill","i-lucide-book-open",{"title":94,"path":95,"stem":96,"children":97,"icon":99},"Deploy","/deploy","2.deploy/0.index",[98,100,121],{"title":94,"path":95,"stem":96,"icon":99},"ri:upload-cloud-2-line",{"title":101,"path":102,"stem":103,"children":104,"page":120},"Runtimes","/deploy/runtimes","2.deploy/10.runtimes",[105,110,115],{"title":106,"path":107,"stem":108,"icon":109},"Node.js","/deploy/runtimes/node","2.deploy/10.runtimes/1.node","akar-icons:node-fill",{"title":111,"path":112,"stem":113,"icon":114},"Bun","/deploy/runtimes/bun","2.deploy/10.runtimes/bun","simple-icons:bun",{"title":116,"path":117,"stem":118,"icon":119},"Deno","/deploy/runtimes/deno","2.deploy/10.runtimes/deno","simple-icons:deno",false,{"title":122,"path":123,"stem":124,"children":125,"page":120},"Providers","/deploy/providers","2.deploy/20.providers",[126,130,134,138,142,146,150,154,158,162,166,170,174,178,182,186,190,194,198,202,206,210,214,218,222],{"title":127,"path":128,"stem":129},"Alwaysdata","/deploy/providers/alwaysdata","2.deploy/20.providers/alwaysdata",{"title":131,"path":132,"stem":133},"AWS Lambda","/deploy/providers/aws","2.deploy/20.providers/aws",{"title":135,"path":136,"stem":137},"AWS Amplify","/deploy/providers/aws-amplify","2.deploy/20.providers/aws-amplify",{"title":139,"path":140,"stem":141},"Azure","/deploy/providers/azure","2.deploy/20.providers/azure",{"title":143,"path":144,"stem":145},"Cleavr","/deploy/providers/cleavr","2.deploy/20.providers/cleavr",{"title":147,"path":148,"stem":149},"Cloudflare","/deploy/providers/cloudflare","2.deploy/20.providers/cloudflare",{"title":151,"path":152,"stem":153},"Deno Deploy","/deploy/providers/deno-deploy","2.deploy/20.providers/deno-deploy",{"title":155,"path":156,"stem":157},"DigitalOcean","/deploy/providers/digitalocean","2.deploy/20.providers/digitalocean",{"title":159,"path":160,"stem":161},"EdgeOne Pages","/deploy/providers/edgeone","2.deploy/20.providers/edgeone",{"title":163,"path":164,"stem":165},"Firebase","/deploy/providers/firebase","2.deploy/20.providers/firebase",{"title":167,"path":168,"stem":169},"Flightcontrol","/deploy/providers/flightcontrol","2.deploy/20.providers/flightcontrol",{"title":171,"path":172,"stem":173},"Genezio","/deploy/providers/genezio","2.deploy/20.providers/genezio",{"title":175,"path":176,"stem":177},"GitHub Pages","/deploy/providers/github-pages","2.deploy/20.providers/github-pages",{"title":179,"path":180,"stem":181},"GitLab Pages","/deploy/providers/gitlab-pages","2.deploy/20.providers/gitlab-pages",{"title":183,"path":184,"stem":185},"Heroku","/deploy/providers/heroku","2.deploy/20.providers/heroku",{"title":187,"path":188,"stem":189},"IIS","/deploy/providers/iis","2.deploy/20.providers/iis",{"title":191,"path":192,"stem":193},"Koyeb","/deploy/providers/koyeb","2.deploy/20.providers/koyeb",{"title":195,"path":196,"stem":197},"Netlify","/deploy/providers/netlify","2.deploy/20.providers/netlify",{"title":199,"path":200,"stem":201},"Platform.sh","/deploy/providers/platform-sh","2.deploy/20.providers/platform-sh",{"title":203,"path":204,"stem":205},"Render.com","/deploy/providers/render","2.deploy/20.providers/render",{"title":207,"path":208,"stem":209},"StormKit","/deploy/providers/stormkit","2.deploy/20.providers/stormkit",{"title":211,"path":212,"stem":213},"Vercel","/deploy/providers/vercel","2.deploy/20.providers/vercel",{"title":215,"path":216,"stem":217},"Zeabur","/deploy/providers/zeabur","2.deploy/20.providers/zeabur",{"title":219,"path":220,"stem":221},"Zephyr Cloud","/deploy/providers/zephyr","2.deploy/20.providers/zephyr",{"title":223,"path":224,"stem":225},"Zerops","/deploy/providers/zerops","2.deploy/20.providers/zerops",{"title":227,"path":228,"stem":229,"children":230,"icon":36},"Config","/config","3.config/0.index",[231],{"title":227,"path":228,"stem":229,"icon":36},{"title":233,"path":234,"stem":235,"children":236,"icon":238},"Examples","/examples","4.examples/0.index",[237,239,244,249,254,259,263,268,273,278,283,288,293,297,302,306,310,315,320,325,330,335,340,345,350,355,359,364,369,373,378,383],{"title":233,"path":234,"stem":235,"icon":238},"i-lucide-folder-code",{"title":240,"path":241,"stem":242,"icon":243},"API Routes","/examples/api-routes","4.examples/api-routes","i-lucide-route",{"title":245,"path":246,"stem":247,"icon":248},"Auto Imports","/examples/auto-imports","4.examples/auto-imports","i-lucide-import",{"title":250,"path":251,"stem":252,"icon":253},"Cached Handler","/examples/cached-handler","4.examples/cached-handler","i-lucide-clock",{"title":255,"path":256,"stem":257,"icon":258},"Custom Error Handler","/examples/custom-error-handler","4.examples/custom-error-handler","i-lucide-alert-circle",{"title":38,"path":260,"stem":261,"icon":262},"/examples/database","4.examples/database","i-lucide-database",{"title":264,"path":265,"stem":266,"icon":267},"Elysia","/examples/elysia","4.examples/elysia","i-skill-icons-elysia-dark",{"title":269,"path":270,"stem":271,"icon":272},"Express","/examples/express","4.examples/express","i-simple-icons-express",{"title":274,"path":275,"stem":276,"icon":277},"Fastify","/examples/fastify","4.examples/fastify","i-simple-icons-fastify",{"title":279,"path":280,"stem":281,"icon":282},"Hello World","/examples/hello-world","4.examples/hello-world","i-lucide-sparkles",{"title":284,"path":285,"stem":286,"icon":287},"Hono","/examples/hono","4.examples/hono","i-logos-hono",{"title":289,"path":290,"stem":291,"icon":292},"Import Alias","/examples/import-alias","4.examples/import-alias","i-lucide-at-sign",{"title":294,"path":295,"stem":296,"icon":46},"Middleware","/examples/middleware","4.examples/middleware",{"title":298,"path":299,"stem":300,"icon":301},"Mono JSX","/examples/mono-jsx","4.examples/mono-jsx","i-lucide-brackets",{"title":303,"path":304,"stem":305,"icon":301},"Nano JSX","/examples/nano-jsx","4.examples/nano-jsx",{"title":53,"path":307,"stem":308,"icon":309},"/examples/plugins","4.examples/plugins","i-lucide-plug",{"title":311,"path":312,"stem":313,"icon":314},"Custom Renderer","/examples/renderer","4.examples/renderer","i-lucide-code",{"title":316,"path":317,"stem":318,"icon":319},"Runtime Config","/examples/runtime-config","4.examples/runtime-config","i-lucide-settings",{"title":321,"path":322,"stem":323,"icon":324},"Server Fetch","/examples/server-fetch","4.examples/server-fetch","i-lucide-arrow-right-left",{"title":326,"path":327,"stem":328,"icon":329},"Shiki","/examples/shiki","4.examples/shiki","i-lucide-highlighter",{"title":331,"path":332,"stem":333,"icon":334},"Virtual Routes","/examples/virtual-routes","4.examples/virtual-routes","i-lucide-box",{"title":336,"path":337,"stem":338,"icon":339},"Vite Nitro Plugin","/examples/vite-nitro-plugin","4.examples/vite-nitro-plugin","i-logos-vitejs",{"title":341,"path":342,"stem":343,"icon":344},"Vite RSC","/examples/vite-rsc","4.examples/vite-rsc","i-logos-react",{"title":346,"path":347,"stem":348,"icon":349},"Vite SSR HTML","/examples/vite-ssr-html","4.examples/vite-ssr-html","i-logos-html-5",{"title":351,"path":352,"stem":353,"icon":354},"SSR with Preact","/examples/vite-ssr-preact","4.examples/vite-ssr-preact","i-logos-preact",{"title":356,"path":357,"stem":358,"icon":344},"SSR with React","/examples/vite-ssr-react","4.examples/vite-ssr-react",{"title":360,"path":361,"stem":362,"icon":363},"SSR with SolidJS","/examples/vite-ssr-solid","4.examples/vite-ssr-solid","i-logos-solidjs-icon",{"title":365,"path":366,"stem":367,"icon":368},"SSR with TanStack Router","/examples/vite-ssr-tsr-react","4.examples/vite-ssr-tsr-react","i-simple-icons-tanstack",{"title":370,"path":371,"stem":372,"icon":368},"SSR with TanStack Start","/examples/vite-ssr-tss-react","4.examples/vite-ssr-tss-react",{"title":374,"path":375,"stem":376,"icon":377},"SSR with Vue Router","/examples/vite-ssr-vue-router","4.examples/vite-ssr-vue-router","i-logos-vue",{"title":379,"path":380,"stem":381,"icon":382},"Vite + tRPC","/examples/vite-trpc","4.examples/vite-trpc","i-simple-icons-trpc",{"title":63,"path":384,"stem":385,"icon":386},"/examples/websocket","4.examples/websocket","i-lucide-radio",{"title":388,"path":389,"stem":390,"children":391},"Blog","/blog","9.blog",[392,395],{"title":388,"path":389,"stem":393,"icon":394},"9.blog/index","i-lucide-file-text",{"title":396,"path":397,"stem":398,"icon":394},"Nitro v3 Beta is here!","/blog/v3-beta","9.blog/1.v3-beta",{"title":5,"path":400,"stem":401},"/","index",{"id":403,"title":43,"body":404,"description":1495,"extension":1496,"meta":1497,"navigation":1498,"path":44,"seo":1499,"stem":45,"__hash__":1500},"content/1.docs/50.lifecycle.md",{"type":405,"value":406,"toc":1478,"icon":46},"minimark",[407,412,416,1087,1091,1094,1111,1212,1219,1222,1268,1281,1285,1292,1368,1372,1382,1461,1469,1474],[408,409,411],"h2",{"id":410},"request-lifecycle","Request lifecycle",[413,414,415],"p",{},"A request can be intercepted and terminated (with or without a response) from any of these layers, in this order:",[417,418,419,428,439,574,590,594,606,624,631,635,638,708,713,717,724,787,793,799,803,813,817,824,855,861,868,943,948,951,954,959,965,975,1080],"steps",{},[420,421,423,427],"h3",{"id":422},"request-hook",[424,425,426],"code",{},"request"," hook",[413,429,430,431,433,434,438],{},"The ",[424,432,426],{}," hook is the first code that runs for every incoming request. It is registered via a ",[435,436,437],"a",{"href":54},"server plugin",":",[440,441,446],"pre",{"className":442,"code":443,"filename":444,"language":445,"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.path}`);\n  });\n});\n","plugins/request-hook.ts","ts",[424,447,448,471,478,507,534,562,568],{"__ignoreMap":5},[449,450,453,457,461,464,468],"span",{"class":451,"line":452},"line",1,[449,454,456],{"class":455},"so5gQ","import",[449,458,460],{"class":459},"slsVL"," { definePlugin } ",[449,462,463],{"class":455},"from",[449,465,467],{"class":466},"sfrk1"," \"nitro\"",[449,469,470],{"class":459},";\n",[449,472,474],{"class":451,"line":473},2,[449,475,477],{"emptyLinePlaceholder":476},true,"\n",[449,479,481,484,487,491,494,498,501,504],{"class":451,"line":480},3,[449,482,483],{"class":455},"export",[449,485,486],{"class":455}," default",[449,488,490],{"class":489},"shcOC"," definePlugin",[449,492,493],{"class":459},"((",[449,495,497],{"class":496},"sQHwn","nitroApp",[449,499,500],{"class":459},") ",[449,502,503],{"class":455},"=>",[449,505,506],{"class":459}," {\n",[449,508,510,513,516,519,522,525,528,530,532],{"class":451,"line":509},4,[449,511,512],{"class":459},"  nitroApp.hooks.",[449,514,515],{"class":489},"hook",[449,517,518],{"class":459},"(",[449,520,521],{"class":466},"\"request\"",[449,523,524],{"class":459},", (",[449,526,527],{"class":496},"event",[449,529,500],{"class":459},[449,531,503],{"class":455},[449,533,506],{"class":459},[449,535,537,540,543,545,548,550,553,556,559],{"class":451,"line":536},5,[449,538,539],{"class":459},"    console.",[449,541,542],{"class":489},"log",[449,544,518],{"class":459},[449,546,547],{"class":466},"`Incoming request on ${",[449,549,527],{"class":459},[449,551,552],{"class":466},".",[449,554,555],{"class":459},"path",[449,557,558],{"class":466},"}`",[449,560,561],{"class":459},");\n",[449,563,565],{"class":451,"line":564},6,[449,566,567],{"class":459},"  });\n",[449,569,571],{"class":451,"line":570},7,[449,572,573],{"class":459},"});\n",[575,576,577],"note",{},[413,578,579,580,582,583,589],{},"Errors thrown inside the ",[424,581,426],{}," hook are captured by the ",[435,584,586,427],{"href":585},"#error-handling",[424,587,588],{},"error"," and do not terminate the request pipeline.",[420,591,593],{"id":592},"static-assets","Static assets",[413,595,596,597,600,601,605],{},"When static asset serving is enabled (the default for most presets), Nitro checks if the request matches a file in the ",[424,598,599],{},"public/"," directory ",[602,603,604],"strong",{},"before"," any other middleware or route handler runs.",[413,607,608,609,612,613,612,616,619,620,623],{},"If a match is found, the static file is served immediately with appropriate ",[424,610,611],{},"Content-Type",", ",[424,614,615],{},"ETag",[424,617,618],{},"Last-Modified",", and ",[424,621,622],{},"Cache-Control"," headers. The request is terminated and no further middleware or routes are executed.",[413,625,626,627,630],{},"Static assets also support content negotiation for pre-compressed files (gzip, brotli, zstd) via the ",[424,628,629],{},"Accept-Encoding"," header.",[420,632,634],{"id":633},"route-rules","Route rules",[413,636,637],{},"The matching route rules defined in the Nitro config will execute. Route rules run as middleware so most of them alter the response without terminating it (for instance, adding a header or setting a cache policy).",[440,639,642],{"className":442,"code":640,"filename":641,"language":445,"meta":5,"style":5},"import { defineConfig } from \"nitro\";\n\nexport default defineConfig({\n  routeRules: {\n    '/**': { headers: { 'x-nitro': 'first' } }\n  }\n})\n","nitro.config.ts",[424,643,644,657,661,673,678,698,703],{"__ignoreMap":5},[449,645,646,648,651,653,655],{"class":451,"line":452},[449,647,456],{"class":455},[449,649,650],{"class":459}," { defineConfig } ",[449,652,463],{"class":455},[449,654,467],{"class":466},[449,656,470],{"class":459},[449,658,659],{"class":451,"line":473},[449,660,477],{"emptyLinePlaceholder":476},[449,662,663,665,667,670],{"class":451,"line":480},[449,664,483],{"class":455},[449,666,486],{"class":455},[449,668,669],{"class":489}," defineConfig",[449,671,672],{"class":459},"({\n",[449,674,675],{"class":451,"line":509},[449,676,677],{"class":459},"  routeRules: {\n",[449,679,680,683,686,689,692,695],{"class":451,"line":536},[449,681,682],{"class":466},"    '/**'",[449,684,685],{"class":459},": { headers: { ",[449,687,688],{"class":466},"'x-nitro'",[449,690,691],{"class":459},": ",[449,693,694],{"class":466},"'first'",[449,696,697],{"class":459}," } }\n",[449,699,700],{"class":451,"line":564},[449,701,702],{"class":459},"  }\n",[449,704,705],{"class":451,"line":570},[449,706,707],{"class":459},"})\n",[709,710],"read-more",{"to":711,"title":712},"/docs/routing#route-rules","Routing > Route rules",[420,714,716],{"id":715},"global-middleware","Global middleware",[413,718,719,720,723],{},"Any global middleware defined in the ",[424,721,722],{},"middleware/"," directory will be run:",[440,725,728],{"className":442,"code":726,"filename":727,"language":445,"meta":5,"style":5},"import { defineHandler } from \"nitro\";\n\nexport default defineHandler((event) => {\n  event.context.info = { name: \"Nitro\" };\n});\n","middleware/info.ts",[424,729,730,743,747,766,783],{"__ignoreMap":5},[449,731,732,734,737,739,741],{"class":451,"line":452},[449,733,456],{"class":455},[449,735,736],{"class":459}," { defineHandler } ",[449,738,463],{"class":455},[449,740,467],{"class":466},[449,742,470],{"class":459},[449,744,745],{"class":451,"line":473},[449,746,477],{"emptyLinePlaceholder":476},[449,748,749,751,753,756,758,760,762,764],{"class":451,"line":480},[449,750,483],{"class":455},[449,752,486],{"class":455},[449,754,755],{"class":489}," defineHandler",[449,757,493],{"class":459},[449,759,527],{"class":496},[449,761,500],{"class":459},[449,763,503],{"class":455},[449,765,506],{"class":459},[449,767,768,771,774,777,780],{"class":451,"line":509},[449,769,770],{"class":459},"  event.context.info ",[449,772,773],{"class":455},"=",[449,775,776],{"class":459}," { name: ",[449,778,779],{"class":466},"\"Nitro\"",[449,781,782],{"class":459}," };\n",[449,784,785],{"class":451,"line":536},[449,786,573],{"class":459},[788,789,790],"warning",{},[413,791,792],{},"Returning from a middleware will close the request and should be avoided when possible.",[709,794,796],{"to":795},"/docs/routing#middleware",[413,797,798],{},"Learn more about Nitro middleware.",[420,800,802],{"id":801},"routed-middleware","Routed middleware",[413,804,805,806,809,810,812],{},"Middleware that targets a specific route pattern (defined with a ",[424,807,808],{},"route"," in ",[424,811,722],{},") runs after global middleware but before the matched route handler.",[420,814,816],{"id":815},"routes","Routes",[413,818,819,820,823],{},"Nitro will look at defined routes in the ",[424,821,822],{},"routes/"," folder to match the incoming request.",[440,825,828],{"className":442,"code":826,"filename":827,"language":445,"meta":5,"style":5},"export default (event) => ({ world: true })\n","routes/api/hello.ts",[424,829,830],{"__ignoreMap":5},[449,831,832,834,836,839,841,843,845,848,852],{"class":451,"line":452},[449,833,483],{"class":455},[449,835,486],{"class":455},[449,837,838],{"class":459}," (",[449,840,527],{"class":496},[449,842,500],{"class":459},[449,844,503],{"class":455},[449,846,847],{"class":459}," ({ world: ",[449,849,851],{"class":850},"suiK_","true",[449,853,854],{"class":459}," })\n",[709,856,858],{"to":857},"/docs/routing#filesystem-routing",[413,859,860],{},"Learn more about Nitro file-system routing.",[413,862,863,864,867],{},"If serverEntry is defined it will catch all requests not matching any other route acting as ",[424,865,866],{},"/**"," route handler.",[440,869,872],{"className":442,"code":870,"filename":871,"language":445,"meta":5,"style":5},"import { defineHandler } from \"nitro\";\n\nexport default defineHandler((event) => {\n  if (event.path === \"/\") {\n    return \"Home page\";\n  }\n});\n","server.ts",[424,873,874,886,890,908,925,935,939],{"__ignoreMap":5},[449,875,876,878,880,882,884],{"class":451,"line":452},[449,877,456],{"class":455},[449,879,736],{"class":459},[449,881,463],{"class":455},[449,883,467],{"class":466},[449,885,470],{"class":459},[449,887,888],{"class":451,"line":473},[449,889,477],{"emptyLinePlaceholder":476},[449,891,892,894,896,898,900,902,904,906],{"class":451,"line":480},[449,893,483],{"class":455},[449,895,486],{"class":455},[449,897,755],{"class":489},[449,899,493],{"class":459},[449,901,527],{"class":496},[449,903,500],{"class":459},[449,905,503],{"class":455},[449,907,506],{"class":459},[449,909,910,913,916,919,922],{"class":451,"line":509},[449,911,912],{"class":455},"  if",[449,914,915],{"class":459}," (event.path ",[449,917,918],{"class":455},"===",[449,920,921],{"class":466}," \"/\"",[449,923,924],{"class":459},") {\n",[449,926,927,930,933],{"class":451,"line":536},[449,928,929],{"class":455},"    return",[449,931,932],{"class":466}," \"Home page\"",[449,934,470],{"class":459},[449,936,937],{"class":451,"line":564},[449,938,702],{"class":459},[449,940,941],{"class":451,"line":570},[449,942,573],{"class":459},[709,944,945],{"to":69},[413,946,947],{},"Learn more about Nitro server entry.",[420,949,18],{"id":950},"renderer",[413,952,953],{},"If no route is matched, Nitro will look for a renderer handler (defined or auto-detected) to handle the request.",[709,955,956],{"to":19},[413,957,958],{},"Learn more about Nitro renderer.",[420,960,962,427],{"id":961},"response-hook",[424,963,964],{},"response",[413,966,967,968,970,971,974],{},"After the response is created (from any of the layers above), the ",[424,969,964],{}," hook runs. This hook receives the final ",[424,972,973],{},"Response"," object and the event, and can be used to inspect or modify response headers:",[440,976,979],{"className":442,"code":977,"filename":978,"language":445,"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.path}`);\n  });\n});\n","plugins/response-hook.ts",[424,980,981,993,997,1015,1041,1072,1076],{"__ignoreMap":5},[449,982,983,985,987,989,991],{"class":451,"line":452},[449,984,456],{"class":455},[449,986,460],{"class":459},[449,988,463],{"class":455},[449,990,467],{"class":466},[449,992,470],{"class":459},[449,994,995],{"class":451,"line":473},[449,996,477],{"emptyLinePlaceholder":476},[449,998,999,1001,1003,1005,1007,1009,1011,1013],{"class":451,"line":480},[449,1000,483],{"class":455},[449,1002,486],{"class":455},[449,1004,490],{"class":489},[449,1006,493],{"class":459},[449,1008,497],{"class":496},[449,1010,500],{"class":459},[449,1012,503],{"class":455},[449,1014,506],{"class":459},[449,1016,1017,1019,1021,1023,1026,1028,1031,1033,1035,1037,1039],{"class":451,"line":509},[449,1018,512],{"class":459},[449,1020,515],{"class":489},[449,1022,518],{"class":459},[449,1024,1025],{"class":466},"\"response\"",[449,1027,524],{"class":459},[449,1029,1030],{"class":496},"res",[449,1032,612],{"class":459},[449,1034,527],{"class":496},[449,1036,500],{"class":459},[449,1038,503],{"class":455},[449,1040,506],{"class":459},[449,1042,1043,1045,1047,1049,1052,1054,1056,1059,1062,1064,1066,1068,1070],{"class":451,"line":536},[449,1044,539],{"class":459},[449,1046,542],{"class":489},[449,1048,518],{"class":459},[449,1050,1051],{"class":466},"`Response ${",[449,1053,1030],{"class":459},[449,1055,552],{"class":466},[449,1057,1058],{"class":459},"status",[449,1060,1061],{"class":466},"} for ${",[449,1063,527],{"class":459},[449,1065,552],{"class":466},[449,1067,555],{"class":459},[449,1069,558],{"class":466},[449,1071,561],{"class":459},[449,1073,1074],{"class":451,"line":564},[449,1075,567],{"class":459},[449,1077,1078],{"class":451,"line":570},[449,1079,573],{"class":459},[575,1081,1082],{},[413,1083,430,1084,1086],{},[424,1085,964],{}," hook runs for every response, including static assets, middleware-terminated requests, and error responses.",[408,1088,1090],{"id":1089},"error-handling","Error handling",[413,1092,1093],{},"When an error occurs at any point in the request lifecycle, Nitro:",[417,1095,1097,1104],{"level":1096},"4",[1098,1099,1100,1101,1103],"h4",{},"Calls the ",[424,1102,588],{}," hook with the error and context (including the event and source tags).",[1098,1105,1106,1107,1110],{},"Passes the error to the ",[602,1108,1109],{},"error handler"," which converts it into an HTTP response.",[440,1112,1115],{"className":442,"code":1113,"filename":1114,"language":445,"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    // context.event - the H3 event (if available)\n    // context.tags  - error source tags like \"request\", \"response\", \"plugin\"\n  });\n});\n","plugins/errors.ts",[424,1116,1117,1129,1133,1151,1177,1191,1197,1202,1207],{"__ignoreMap":5},[449,1118,1119,1121,1123,1125,1127],{"class":451,"line":452},[449,1120,456],{"class":455},[449,1122,460],{"class":459},[449,1124,463],{"class":455},[449,1126,467],{"class":466},[449,1128,470],{"class":459},[449,1130,1131],{"class":451,"line":473},[449,1132,477],{"emptyLinePlaceholder":476},[449,1134,1135,1137,1139,1141,1143,1145,1147,1149],{"class":451,"line":480},[449,1136,483],{"class":455},[449,1138,486],{"class":455},[449,1140,490],{"class":489},[449,1142,493],{"class":459},[449,1144,497],{"class":496},[449,1146,500],{"class":459},[449,1148,503],{"class":455},[449,1150,506],{"class":459},[449,1152,1153,1155,1157,1159,1162,1164,1166,1168,1171,1173,1175],{"class":451,"line":509},[449,1154,512],{"class":459},[449,1156,515],{"class":489},[449,1158,518],{"class":459},[449,1160,1161],{"class":466},"\"error\"",[449,1163,524],{"class":459},[449,1165,588],{"class":496},[449,1167,612],{"class":459},[449,1169,1170],{"class":496},"context",[449,1172,500],{"class":459},[449,1174,503],{"class":455},[449,1176,506],{"class":459},[449,1178,1179,1181,1183,1185,1188],{"class":451,"line":536},[449,1180,539],{"class":459},[449,1182,588],{"class":489},[449,1184,518],{"class":459},[449,1186,1187],{"class":466},"\"Captured error:\"",[449,1189,1190],{"class":459},", error);\n",[449,1192,1193],{"class":451,"line":564},[449,1194,1196],{"class":1195},"sCsY4","    // context.event - the H3 event (if available)\n",[449,1198,1199],{"class":451,"line":570},[449,1200,1201],{"class":1195},"    // context.tags  - error source tags like \"request\", \"response\", \"plugin\"\n",[449,1203,1205],{"class":451,"line":1204},8,[449,1206,567],{"class":459},[449,1208,1210],{"class":451,"line":1209},9,[449,1211,573],{"class":459},[413,1213,1214,1215,1218],{},"Errors are also tracked per-request in ",[424,1216,1217],{},"event.req.context.nitro.errors"," for inspection in later hooks.",[413,1220,1221],{},"You can provide a custom error handler in the Nitro config to control error response formatting:",[440,1223,1225],{"className":442,"code":1224,"filename":641,"language":445,"meta":5,"style":5},"import { defineConfig } from \"nitro\";\n\nexport default defineConfig({\n  errorHandler: \"~/error\",\n})\n",[424,1226,1227,1239,1243,1253,1264],{"__ignoreMap":5},[449,1228,1229,1231,1233,1235,1237],{"class":451,"line":452},[449,1230,456],{"class":455},[449,1232,650],{"class":459},[449,1234,463],{"class":455},[449,1236,467],{"class":466},[449,1238,470],{"class":459},[449,1240,1241],{"class":451,"line":473},[449,1242,477],{"emptyLinePlaceholder":476},[449,1244,1245,1247,1249,1251],{"class":451,"line":480},[449,1246,483],{"class":455},[449,1248,486],{"class":455},[449,1250,669],{"class":489},[449,1252,672],{"class":459},[449,1254,1255,1258,1261],{"class":451,"line":509},[449,1256,1257],{"class":459},"  errorHandler: ",[449,1259,1260],{"class":466},"\"~/error\"",[449,1262,1263],{"class":459},",\n",[449,1265,1266],{"class":451,"line":536},[449,1267,707],{"class":459},[413,1269,1270,1271,1273,1274,1277,1278,552],{},"Additionally, unhandled promise rejections and uncaught exceptions at the process level are automatically captured into the ",[424,1272,588],{}," hook with the tags ",[424,1275,1276],{},"\"unhandledRejection\""," and ",[424,1279,1280],{},"\"uncaughtException\"",[408,1282,1284],{"id":1283},"server-shutdown","Server shutdown",[413,1286,1287,1288,1291],{},"When the Nitro server is shutting down, the ",[424,1289,1290],{},"close"," hook is called. Use this to clean up resources such as database connections, timers, or external service handles:",[440,1293,1296],{"className":442,"code":1294,"filename":1295,"language":445,"meta":5,"style":5},"import { definePlugin } from \"nitro\";\n\nexport default definePlugin((nitroApp) => {\n  nitroApp.hooks.hook(\"close\", async () => {\n    // Clean up resources\n  });\n});\n","plugins/cleanup.ts",[424,1297,1298,1310,1314,1332,1355,1360,1364],{"__ignoreMap":5},[449,1299,1300,1302,1304,1306,1308],{"class":451,"line":452},[449,1301,456],{"class":455},[449,1303,460],{"class":459},[449,1305,463],{"class":455},[449,1307,467],{"class":466},[449,1309,470],{"class":459},[449,1311,1312],{"class":451,"line":473},[449,1313,477],{"emptyLinePlaceholder":476},[449,1315,1316,1318,1320,1322,1324,1326,1328,1330],{"class":451,"line":480},[449,1317,483],{"class":455},[449,1319,486],{"class":455},[449,1321,490],{"class":489},[449,1323,493],{"class":459},[449,1325,497],{"class":496},[449,1327,500],{"class":459},[449,1329,503],{"class":455},[449,1331,506],{"class":459},[449,1333,1334,1336,1338,1340,1343,1345,1348,1351,1353],{"class":451,"line":509},[449,1335,512],{"class":459},[449,1337,515],{"class":489},[449,1339,518],{"class":459},[449,1341,1342],{"class":466},"\"close\"",[449,1344,612],{"class":459},[449,1346,1347],{"class":455},"async",[449,1349,1350],{"class":459}," () ",[449,1352,503],{"class":455},[449,1354,506],{"class":459},[449,1356,1357],{"class":451,"line":536},[449,1358,1359],{"class":1195},"    // Clean up resources\n",[449,1361,1362],{"class":451,"line":564},[449,1363,567],{"class":459},[449,1365,1366],{"class":451,"line":570},[449,1367,573],{"class":459},[408,1369,1371],{"id":1370},"hooks-reference","Hooks reference",[413,1373,1374,1375,1378,1379,552],{},"All runtime hooks are registered through ",[435,1376,1377],{"href":54},"server plugins"," using ",[424,1380,1381],{},"nitroApp.hooks.hook()",[1383,1384,1385,1401],"table",{},[1386,1387,1388],"thead",{},[1389,1390,1391,1395,1398],"tr",{},[1392,1393,1394],"th",{},"Hook",[1392,1396,1397],{},"Signature",[1392,1399,1400],{},"When it runs",[1402,1403,1404,1419,1433,1447],"tbody",{},[1389,1405,1406,1411,1416],{},[1407,1408,1409],"td",{},[424,1410,426],{},[1407,1412,1413],{},[424,1414,1415],{},"(event: HTTPEvent) => void | Promise\u003Cvoid>",[1407,1417,1418],{},"Start of each request, before routing.",[1389,1420,1421,1425,1430],{},[1407,1422,1423],{},[424,1424,964],{},[1407,1426,1427],{},[424,1428,1429],{},"(res: Response, event: HTTPEvent) => void | Promise\u003Cvoid>",[1407,1431,1432],{},"After the response is created, before it is sent.",[1389,1434,1435,1439,1444],{},[1407,1436,1437],{},[424,1438,588],{},[1407,1440,1441],{},[424,1442,1443],{},"(error: Error, context: { event?, tags? }) => void",[1407,1445,1446],{},"When any error is captured during the lifecycle.",[1389,1448,1449,1453,1458],{},[1407,1450,1451],{},[424,1452,1290],{},[1407,1454,1455],{},[424,1456,1457],{},"() => void",[1407,1459,1460],{},"When the Nitro server is shutting down.",[575,1462,1463],{},[413,1464,430,1465,1468],{},[424,1466,1467],{},"NitroRuntimeHooks"," interface is augmentable. Deployment presets (such as Cloudflare) can extend it with platform-specific hooks.",[709,1470,1471],{"to":54},[413,1472,1473],{},"Learn more about Nitro plugins and hook usage examples.",[1475,1476,1477],"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":473,"depth":473,"links":1479},[1480,1492,1493,1494],{"id":410,"depth":473,"text":411,"children":1481},[1482,1484,1485,1486,1487,1488,1489,1490],{"id":422,"depth":480,"text":1483},"request hook",{"id":592,"depth":480,"text":593},{"id":633,"depth":480,"text":634},{"id":715,"depth":480,"text":716},{"id":801,"depth":480,"text":802},{"id":815,"depth":480,"text":816},{"id":950,"depth":480,"text":18},{"id":961,"depth":480,"text":1491},"response hook",{"id":1089,"depth":473,"text":1090},{"id":1283,"depth":473,"text":1284},{"id":1370,"depth":473,"text":1371},"Understand how Nitro runs and serves incoming requests to your application.","md",{"icon":46},{"icon":46},{"title":43,"description":1495},"_AJ0U3JpzBNRXWSRKgVc80n_UI3TaiBCKNsdrlp36fc",[1502,1504],{"title":38,"path":39,"stem":40,"description":1503,"icon":41,"children":-1},"Nitro provides a built-in and lightweight SQL database layer.",{"title":48,"path":49,"stem":50,"description":1505,"icon":51,"children":-1},"Nitro can automatically generate an OpenAPI specification from your route handlers and serve interactive API documentation.",1776367075947]