[{"data":1,"prerenderedAt":1482},["ShallowReactive",2],{"navigation":3,"-docs-lifecycle":377,"-docs-lifecycle-surround":1477},[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":1471,"extension":1472,"meta":1473,"navigation":1474,"path":44,"seo":1475,"stem":45,"__hash__":1476},"content/1.docs/50.lifecycle.md",{"type":380,"value":381,"toc":1454,"icon":46},"minimark",[382,387,391,1063,1067,1070,1087,1188,1195,1198,1244,1257,1261,1268,1344,1348,1358,1437,1445,1450],[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,763,769,775,779,789,793,800,831,837,844,919,924,927,930,935,941,951,1056],"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\";\n\nexport default defineHandler((event) => {\n  event.context.info = { name: \"Nitro\" };\n});\n","middleware/info.ts",[399,705,706,719,723,742,759],{"__ignoreMap":5},[424,707,708,710,713,715,717],{"class":426,"line":427},[424,709,431],{"class":430},[424,711,712],{"class":434}," { defineHandler } ",[424,714,438],{"class":430},[424,716,442],{"class":441},[424,718,445],{"class":434},[424,720,721],{"class":426,"line":448},[424,722,452],{"emptyLinePlaceholder":451},[424,724,725,727,729,732,734,736,738,740],{"class":426,"line":455},[424,726,458],{"class":430},[424,728,461],{"class":430},[424,730,731],{"class":464}," defineHandler",[424,733,468],{"class":434},[424,735,502],{"class":471},[424,737,475],{"class":434},[424,739,478],{"class":430},[424,741,481],{"class":434},[424,743,744,747,750,753,756],{"class":426,"line":484},[424,745,746],{"class":434},"  event.context.info ",[424,748,749],{"class":430},"=",[424,751,752],{"class":434}," { name: ",[424,754,755],{"class":441},"\"Nitro\"",[424,757,758],{"class":434}," };\n",[424,760,761],{"class":426,"line":511},[424,762,548],{"class":434},[764,765,766],"warning",{},[388,767,768],{},"Returning from a middleware will close the request and should be avoided when possible.",[685,770,772],{"to":771},"/docs/routing#middleware",[388,773,774],{},"Learn more about Nitro middleware.",[395,776,778],{"id":777},"routed-middleware","Routed middleware",[388,780,781,782,785,786,788],{},"Middleware that targets a specific route pattern (defined with a ",[399,783,784],{},"route"," in ",[399,787,698],{},") runs after global middleware but before the matched route handler.",[395,790,792],{"id":791},"routes","Routes",[388,794,795,796,799],{},"Nitro will look at defined routes in the ",[399,797,798],{},"routes/"," folder to match the incoming request.",[415,801,804],{"className":417,"code":802,"filename":803,"language":420,"meta":5,"style":5},"export default (event) => ({ world: true })\n","routes/api/hello.ts",[399,805,806],{"__ignoreMap":5},[424,807,808,810,812,815,817,819,821,824,828],{"class":426,"line":427},[424,809,458],{"class":430},[424,811,461],{"class":430},[424,813,814],{"class":434}," (",[424,816,502],{"class":471},[424,818,475],{"class":434},[424,820,478],{"class":430},[424,822,823],{"class":434}," ({ world: ",[424,825,827],{"class":826},"suiK_","true",[424,829,830],{"class":434}," })\n",[685,832,834],{"to":833},"/docs/routing#filesystem-routing",[388,835,836],{},"Learn more about Nitro file-system routing.",[388,838,839,840,843],{},"If serverEntry is defined it will catch all requests not matching any other route acting as ",[399,841,842],{},"/**"," route handler.",[415,845,848],{"className":417,"code":846,"filename":847,"language":420,"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",[399,849,850,862,866,884,901,911,915],{"__ignoreMap":5},[424,851,852,854,856,858,860],{"class":426,"line":427},[424,853,431],{"class":430},[424,855,712],{"class":434},[424,857,438],{"class":430},[424,859,442],{"class":441},[424,861,445],{"class":434},[424,863,864],{"class":426,"line":448},[424,865,452],{"emptyLinePlaceholder":451},[424,867,868,870,872,874,876,878,880,882],{"class":426,"line":455},[424,869,458],{"class":430},[424,871,461],{"class":430},[424,873,731],{"class":464},[424,875,468],{"class":434},[424,877,502],{"class":471},[424,879,475],{"class":434},[424,881,478],{"class":430},[424,883,481],{"class":434},[424,885,886,889,892,895,898],{"class":426,"line":484},[424,887,888],{"class":430},"  if",[424,890,891],{"class":434}," (event.path ",[424,893,894],{"class":430},"===",[424,896,897],{"class":441}," \"/\"",[424,899,900],{"class":434},") {\n",[424,902,903,906,909],{"class":426,"line":511},[424,904,905],{"class":430},"    return",[424,907,908],{"class":441}," \"Home page\"",[424,910,445],{"class":434},[424,912,913],{"class":426,"line":539},[424,914,678],{"class":434},[424,916,917],{"class":426,"line":545},[424,918,548],{"class":434},[685,920,921],{"to":59},[388,922,923],{},"Learn more about Nitro server entry.",[395,925,18],{"id":926},"renderer",[388,928,929],{},"If no route is matched, Nitro will look for a renderer handler (defined or auto-detected) to handle the request.",[685,931,932],{"to":19},[388,933,934],{},"Learn more about Nitro renderer.",[395,936,938,402],{"id":937},"response-hook",[399,939,940],{},"response",[388,942,943,944,946,947,950],{},"After the response is created (from any of the layers above), the ",[399,945,940],{}," hook runs. This hook receives the final ",[399,948,949],{},"Response"," object and the event, and can be used to inspect or modify response headers:",[415,952,955],{"className":417,"code":953,"filename":954,"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,956,957,969,973,991,1017,1048,1052],{"__ignoreMap":5},[424,958,959,961,963,965,967],{"class":426,"line":427},[424,960,431],{"class":430},[424,962,435],{"class":434},[424,964,438],{"class":430},[424,966,442],{"class":441},[424,968,445],{"class":434},[424,970,971],{"class":426,"line":448},[424,972,452],{"emptyLinePlaceholder":451},[424,974,975,977,979,981,983,985,987,989],{"class":426,"line":455},[424,976,458],{"class":430},[424,978,461],{"class":430},[424,980,465],{"class":464},[424,982,468],{"class":434},[424,984,472],{"class":471},[424,986,475],{"class":434},[424,988,478],{"class":430},[424,990,481],{"class":434},[424,992,993,995,997,999,1002,1004,1007,1009,1011,1013,1015],{"class":426,"line":484},[424,994,487],{"class":434},[424,996,490],{"class":464},[424,998,493],{"class":434},[424,1000,1001],{"class":441},"\"response\"",[424,1003,499],{"class":434},[424,1005,1006],{"class":471},"res",[424,1008,587],{"class":434},[424,1010,502],{"class":471},[424,1012,475],{"class":434},[424,1014,478],{"class":430},[424,1016,481],{"class":434},[424,1018,1019,1021,1023,1025,1028,1030,1032,1035,1038,1040,1042,1044,1046],{"class":426,"line":511},[424,1020,514],{"class":434},[424,1022,517],{"class":464},[424,1024,493],{"class":434},[424,1026,1027],{"class":441},"`Response ${",[424,1029,1006],{"class":434},[424,1031,527],{"class":441},[424,1033,1034],{"class":434},"status",[424,1036,1037],{"class":441},"} for ${",[424,1039,502],{"class":434},[424,1041,527],{"class":441},[424,1043,530],{"class":434},[424,1045,533],{"class":441},[424,1047,536],{"class":434},[424,1049,1050],{"class":426,"line":539},[424,1051,542],{"class":434},[424,1053,1054],{"class":426,"line":545},[424,1055,548],{"class":434},[550,1057,1058],{},[388,1059,405,1060,1062],{},[399,1061,940],{}," hook runs for every response, including static assets, middleware-terminated requests, and error responses.",[383,1064,1066],{"id":1065},"error-handling","Error handling",[388,1068,1069],{},"When an error occurs at any point in the request lifecycle, Nitro:",[392,1071,1073,1080],{"level":1072},"4",[1074,1075,1076,1077,1079],"h4",{},"Calls the ",[399,1078,563],{}," hook with the error and context (including the event and source tags).",[1074,1081,1082,1083,1086],{},"Passes the error to the ",[577,1084,1085],{},"error handler"," which converts it into an HTTP response.",[415,1088,1091],{"className":417,"code":1089,"filename":1090,"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,1092,1093,1105,1109,1127,1153,1167,1173,1178,1183],{"__ignoreMap":5},[424,1094,1095,1097,1099,1101,1103],{"class":426,"line":427},[424,1096,431],{"class":430},[424,1098,435],{"class":434},[424,1100,438],{"class":430},[424,1102,442],{"class":441},[424,1104,445],{"class":434},[424,1106,1107],{"class":426,"line":448},[424,1108,452],{"emptyLinePlaceholder":451},[424,1110,1111,1113,1115,1117,1119,1121,1123,1125],{"class":426,"line":455},[424,1112,458],{"class":430},[424,1114,461],{"class":430},[424,1116,465],{"class":464},[424,1118,468],{"class":434},[424,1120,472],{"class":471},[424,1122,475],{"class":434},[424,1124,478],{"class":430},[424,1126,481],{"class":434},[424,1128,1129,1131,1133,1135,1138,1140,1142,1144,1147,1149,1151],{"class":426,"line":484},[424,1130,487],{"class":434},[424,1132,490],{"class":464},[424,1134,493],{"class":434},[424,1136,1137],{"class":441},"\"error\"",[424,1139,499],{"class":434},[424,1141,563],{"class":471},[424,1143,587],{"class":434},[424,1145,1146],{"class":471},"context",[424,1148,475],{"class":434},[424,1150,478],{"class":430},[424,1152,481],{"class":434},[424,1154,1155,1157,1159,1161,1164],{"class":426,"line":511},[424,1156,514],{"class":434},[424,1158,563],{"class":464},[424,1160,493],{"class":434},[424,1162,1163],{"class":441},"\"Captured error:\"",[424,1165,1166],{"class":434},", error);\n",[424,1168,1169],{"class":426,"line":539},[424,1170,1172],{"class":1171},"sCsY4","    // context.event - the H3 event (if available)\n",[424,1174,1175],{"class":426,"line":545},[424,1176,1177],{"class":1171},"    // context.tags  - error source tags like \"request\", \"response\", \"plugin\"\n",[424,1179,1181],{"class":426,"line":1180},8,[424,1182,542],{"class":434},[424,1184,1186],{"class":426,"line":1185},9,[424,1187,548],{"class":434},[388,1189,1190,1191,1194],{},"Errors are also tracked per-request in ",[399,1192,1193],{},"event.req.context.nitro.errors"," for inspection in later hooks.",[388,1196,1197],{},"You can provide a custom error handler in the Nitro config to control error response formatting:",[415,1199,1201],{"className":417,"code":1200,"filename":616,"language":420,"meta":5,"style":5},"import { defineNitroConfig } from \"nitro/config\";\n\nexport default defineNitroConfig({\n  errorHandler: \"~/error\",\n})\n",[399,1202,1203,1215,1219,1229,1240],{"__ignoreMap":5},[424,1204,1205,1207,1209,1211,1213],{"class":426,"line":427},[424,1206,431],{"class":430},[424,1208,625],{"class":434},[424,1210,438],{"class":430},[424,1212,630],{"class":441},[424,1214,445],{"class":434},[424,1216,1217],{"class":426,"line":448},[424,1218,452],{"emptyLinePlaceholder":451},[424,1220,1221,1223,1225,1227],{"class":426,"line":455},[424,1222,458],{"class":430},[424,1224,461],{"class":430},[424,1226,645],{"class":464},[424,1228,648],{"class":434},[424,1230,1231,1234,1237],{"class":426,"line":484},[424,1232,1233],{"class":434},"  errorHandler: ",[424,1235,1236],{"class":441},"\"~/error\"",[424,1238,1239],{"class":434},",\n",[424,1241,1242],{"class":426,"line":511},[424,1243,683],{"class":434},[388,1245,1246,1247,1249,1250,1253,1254,527],{},"Additionally, unhandled promise rejections and uncaught exceptions at the process level are automatically captured into the ",[399,1248,563],{}," hook with the tags ",[399,1251,1252],{},"\"unhandledRejection\""," and ",[399,1255,1256],{},"\"uncaughtException\"",[383,1258,1260],{"id":1259},"server-shutdown","Server shutdown",[388,1262,1263,1264,1267],{},"When the Nitro server is shutting down, the ",[399,1265,1266],{},"close"," hook is called. Use this to clean up resources such as database connections, timers, or external service handles:",[415,1269,1272],{"className":417,"code":1270,"filename":1271,"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,1273,1274,1286,1290,1308,1331,1336,1340],{"__ignoreMap":5},[424,1275,1276,1278,1280,1282,1284],{"class":426,"line":427},[424,1277,431],{"class":430},[424,1279,435],{"class":434},[424,1281,438],{"class":430},[424,1283,442],{"class":441},[424,1285,445],{"class":434},[424,1287,1288],{"class":426,"line":448},[424,1289,452],{"emptyLinePlaceholder":451},[424,1291,1292,1294,1296,1298,1300,1302,1304,1306],{"class":426,"line":455},[424,1293,458],{"class":430},[424,1295,461],{"class":430},[424,1297,465],{"class":464},[424,1299,468],{"class":434},[424,1301,472],{"class":471},[424,1303,475],{"class":434},[424,1305,478],{"class":430},[424,1307,481],{"class":434},[424,1309,1310,1312,1314,1316,1319,1321,1324,1327,1329],{"class":426,"line":484},[424,1311,487],{"class":434},[424,1313,490],{"class":464},[424,1315,493],{"class":434},[424,1317,1318],{"class":441},"\"close\"",[424,1320,587],{"class":434},[424,1322,1323],{"class":430},"async",[424,1325,1326],{"class":434}," () ",[424,1328,478],{"class":430},[424,1330,481],{"class":434},[424,1332,1333],{"class":426,"line":511},[424,1334,1335],{"class":1171},"    // Clean up resources\n",[424,1337,1338],{"class":426,"line":539},[424,1339,542],{"class":434},[424,1341,1342],{"class":426,"line":545},[424,1343,548],{"class":434},[383,1345,1347],{"id":1346},"hooks-reference","Hooks reference",[388,1349,1350,1351,1354,1355,527],{},"All runtime hooks are registered through ",[410,1352,1353],{"href":49},"server plugins"," using ",[399,1356,1357],{},"nitroApp.hooks.hook()",[1359,1360,1361,1377],"table",{},[1362,1363,1364],"thead",{},[1365,1366,1367,1371,1374],"tr",{},[1368,1369,1370],"th",{},"Hook",[1368,1372,1373],{},"Signature",[1368,1375,1376],{},"When it runs",[1378,1379,1380,1395,1409,1423],"tbody",{},[1365,1381,1382,1387,1392],{},[1383,1384,1385],"td",{},[399,1386,401],{},[1383,1388,1389],{},[399,1390,1391],{},"(event: HTTPEvent) => void | Promise\u003Cvoid>",[1383,1393,1394],{},"Start of each request, before routing.",[1365,1396,1397,1401,1406],{},[1383,1398,1399],{},[399,1400,940],{},[1383,1402,1403],{},[399,1404,1405],{},"(res: Response, event: HTTPEvent) => void | Promise\u003Cvoid>",[1383,1407,1408],{},"After the response is created, before it is sent.",[1365,1410,1411,1415,1420],{},[1383,1412,1413],{},[399,1414,563],{},[1383,1416,1417],{},[399,1418,1419],{},"(error: Error, context: { event?, tags? }) => void",[1383,1421,1422],{},"When any error is captured during the lifecycle.",[1365,1424,1425,1429,1434],{},[1383,1426,1427],{},[399,1428,1266],{},[1383,1430,1431],{},[399,1432,1433],{},"() => void",[1383,1435,1436],{},"When the Nitro server is shutting down.",[550,1438,1439],{},[388,1440,405,1441,1444],{},[399,1442,1443],{},"NitroRuntimeHooks"," interface is augmentable. Deployment presets (such as Cloudflare) can extend it with platform-specific hooks.",[685,1446,1447],{"to":49},[388,1448,1449],{},"Learn more about Nitro plugins and hook usage examples.",[1451,1452,1453],"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":1455},[1456,1468,1469,1470],{"id":385,"depth":448,"text":386,"children":1457},[1458,1460,1461,1462,1463,1464,1465,1466],{"id":397,"depth":455,"text":1459},"request hook",{"id":567,"depth":455,"text":568},{"id":608,"depth":455,"text":609},{"id":691,"depth":455,"text":692},{"id":777,"depth":455,"text":778},{"id":791,"depth":455,"text":792},{"id":926,"depth":455,"text":18},{"id":937,"depth":455,"text":1467},"response hook",{"id":1065,"depth":448,"text":1066},{"id":1259,"depth":448,"text":1260},{"id":1346,"depth":448,"text":1347},"Understand how Nitro runs and serves incoming requests to your application.","md",{"icon":46},{"icon":46},{"title":43,"description":1471},"I3k2q5hn5JekuCe722O32DlzGxy-G-p-uoxLbIYOz2k",[1478,1480],{"title":38,"path":39,"stem":40,"description":1479,"icon":41,"children":-1},"Nitro provides a built-in and lightweight SQL database layer.",{"title":48,"path":49,"stem":50,"description":1481,"icon":51,"children":-1},"Use plugins to extend Nitro's runtime behavior.",1773242047696]