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