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