[{"data":1,"prerenderedAt":1498},["ShallowReactive",2],{"navigation":3,"-docs-lifecycle":393,"-docs-lifecycle-surround":1493},[4,88,217,223,378,390],{"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},"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},"WebSocket","/docs/websocket","1.docs/50.websocket","ri:broadcast-fill",{"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":48,"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":58,"path":375,"stem":376,"icon":377},"/examples/websocket","4.examples/websocket","i-lucide-radio",{"title":379,"path":380,"stem":381,"children":382},"Blog","/blog","9.blog",[383,386],{"title":379,"path":380,"stem":384,"icon":385},"9.blog/index","i-lucide-file-text",{"title":387,"path":388,"stem":389,"icon":385},"Nitro v3 Beta is here!","/blog/v3-beta","9.blog/1.v3-beta",{"title":5,"path":391,"stem":392},"/","index",{"id":394,"title":43,"body":395,"description":1487,"extension":1488,"meta":1489,"navigation":1490,"path":44,"seo":1491,"stem":45,"__hash__":1492},"content/1.docs/50.lifecycle.md",{"type":396,"value":397,"toc":1470,"icon":46},"minimark",[398,403,407,1079,1083,1086,1103,1204,1211,1214,1260,1273,1277,1284,1360,1364,1374,1453,1461,1466],[399,400,402],"h2",{"id":401},"request-lifecycle","Request lifecycle",[404,405,406],"p",{},"A request can be intercepted and terminated (with or without a response) from any of these layers, in this order:",[408,409,410,419,430,565,581,585,597,615,622,626,629,700,705,709,716,779,785,791,795,805,809,816,847,853,860,935,940,943,946,951,957,967,1072],"steps",{},[411,412,414,418],"h3",{"id":413},"request-hook",[415,416,417],"code",{},"request"," hook",[404,420,421,422,424,425,429],{},"The ",[415,423,417],{}," hook is the first code that runs for every incoming request. It is registered via a ",[426,427,428],"a",{"href":49},"server plugin",":",[431,432,437],"pre",{"className":433,"code":434,"filename":435,"language":436,"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",[415,438,439,462,469,498,525,553,559],{"__ignoreMap":5},[440,441,444,448,452,455,459],"span",{"class":442,"line":443},"line",1,[440,445,447],{"class":446},"so5gQ","import",[440,449,451],{"class":450},"slsVL"," { definePlugin } ",[440,453,454],{"class":446},"from",[440,456,458],{"class":457},"sfrk1"," \"nitro\"",[440,460,461],{"class":450},";\n",[440,463,465],{"class":442,"line":464},2,[440,466,468],{"emptyLinePlaceholder":467},true,"\n",[440,470,472,475,478,482,485,489,492,495],{"class":442,"line":471},3,[440,473,474],{"class":446},"export",[440,476,477],{"class":446}," default",[440,479,481],{"class":480},"shcOC"," definePlugin",[440,483,484],{"class":450},"((",[440,486,488],{"class":487},"sQHwn","nitroApp",[440,490,491],{"class":450},") ",[440,493,494],{"class":446},"=>",[440,496,497],{"class":450}," {\n",[440,499,501,504,507,510,513,516,519,521,523],{"class":442,"line":500},4,[440,502,503],{"class":450},"  nitroApp.hooks.",[440,505,506],{"class":480},"hook",[440,508,509],{"class":450},"(",[440,511,512],{"class":457},"\"request\"",[440,514,515],{"class":450},", (",[440,517,518],{"class":487},"event",[440,520,491],{"class":450},[440,522,494],{"class":446},[440,524,497],{"class":450},[440,526,528,531,534,536,539,541,544,547,550],{"class":442,"line":527},5,[440,529,530],{"class":450},"    console.",[440,532,533],{"class":480},"log",[440,535,509],{"class":450},[440,537,538],{"class":457},"`Incoming request on ${",[440,540,518],{"class":450},[440,542,543],{"class":457},".",[440,545,546],{"class":450},"path",[440,548,549],{"class":457},"}`",[440,551,552],{"class":450},");\n",[440,554,556],{"class":442,"line":555},6,[440,557,558],{"class":450},"  });\n",[440,560,562],{"class":442,"line":561},7,[440,563,564],{"class":450},"});\n",[566,567,568],"note",{},[404,569,570,571,573,574,580],{},"Errors thrown inside the ",[415,572,417],{}," hook are captured by the ",[426,575,577,418],{"href":576},"#error-handling",[415,578,579],{},"error"," and do not terminate the request pipeline.",[411,582,584],{"id":583},"static-assets","Static assets",[404,586,587,588,591,592,596],{},"When static asset serving is enabled (the default for most presets), Nitro checks if the request matches a file in the ",[415,589,590],{},"public/"," directory ",[593,594,595],"strong",{},"before"," any other middleware or route handler runs.",[404,598,599,600,603,604,603,607,610,611,614],{},"If a match is found, the static file is served immediately with appropriate ",[415,601,602],{},"Content-Type",", ",[415,605,606],{},"ETag",[415,608,609],{},"Last-Modified",", and ",[415,612,613],{},"Cache-Control"," headers. The request is terminated and no further middleware or routes are executed.",[404,616,617,618,621],{},"Static assets also support content negotiation for pre-compressed files (gzip, brotli, zstd) via the ",[415,619,620],{},"Accept-Encoding"," header.",[411,623,625],{"id":624},"route-rules","Route rules",[404,627,628],{},"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).",[431,630,633],{"className":433,"code":631,"filename":632,"language":436,"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",[415,634,635,649,653,665,670,690,695],{"__ignoreMap":5},[440,636,637,639,642,644,647],{"class":442,"line":443},[440,638,447],{"class":446},[440,640,641],{"class":450}," { defineNitroConfig } ",[440,643,454],{"class":446},[440,645,646],{"class":457}," \"nitro/config\"",[440,648,461],{"class":450},[440,650,651],{"class":442,"line":464},[440,652,468],{"emptyLinePlaceholder":467},[440,654,655,657,659,662],{"class":442,"line":471},[440,656,474],{"class":446},[440,658,477],{"class":446},[440,660,661],{"class":480}," defineNitroConfig",[440,663,664],{"class":450},"({\n",[440,666,667],{"class":442,"line":500},[440,668,669],{"class":450},"  routeRules: {\n",[440,671,672,675,678,681,684,687],{"class":442,"line":527},[440,673,674],{"class":457},"    '/**'",[440,676,677],{"class":450},": { headers: { ",[440,679,680],{"class":457},"'x-nitro'",[440,682,683],{"class":450},": ",[440,685,686],{"class":457},"'first'",[440,688,689],{"class":450}," } }\n",[440,691,692],{"class":442,"line":555},[440,693,694],{"class":450},"  }\n",[440,696,697],{"class":442,"line":561},[440,698,699],{"class":450},"})\n",[701,702],"read-more",{"to":703,"title":704},"/docs/routing#route-rules","Routing > Route rules",[411,706,708],{"id":707},"global-middleware","Global middleware",[404,710,711,712,715],{},"Any global middleware defined in the ",[415,713,714],{},"middleware/"," directory will be run:",[431,717,720],{"className":433,"code":718,"filename":719,"language":436,"meta":5,"style":5},"import { defineHandler } from \"nitro\";\n\nexport default defineHandler((event) => {\n  event.context.info = { name: \"Nitro\" };\n});\n","middleware/info.ts",[415,721,722,735,739,758,775],{"__ignoreMap":5},[440,723,724,726,729,731,733],{"class":442,"line":443},[440,725,447],{"class":446},[440,727,728],{"class":450}," { defineHandler } ",[440,730,454],{"class":446},[440,732,458],{"class":457},[440,734,461],{"class":450},[440,736,737],{"class":442,"line":464},[440,738,468],{"emptyLinePlaceholder":467},[440,740,741,743,745,748,750,752,754,756],{"class":442,"line":471},[440,742,474],{"class":446},[440,744,477],{"class":446},[440,746,747],{"class":480}," defineHandler",[440,749,484],{"class":450},[440,751,518],{"class":487},[440,753,491],{"class":450},[440,755,494],{"class":446},[440,757,497],{"class":450},[440,759,760,763,766,769,772],{"class":442,"line":500},[440,761,762],{"class":450},"  event.context.info ",[440,764,765],{"class":446},"=",[440,767,768],{"class":450}," { name: ",[440,770,771],{"class":457},"\"Nitro\"",[440,773,774],{"class":450}," };\n",[440,776,777],{"class":442,"line":527},[440,778,564],{"class":450},[780,781,782],"warning",{},[404,783,784],{},"Returning from a middleware will close the request and should be avoided when possible.",[701,786,788],{"to":787},"/docs/routing#middleware",[404,789,790],{},"Learn more about Nitro middleware.",[411,792,794],{"id":793},"routed-middleware","Routed middleware",[404,796,797,798,801,802,804],{},"Middleware that targets a specific route pattern (defined with a ",[415,799,800],{},"route"," in ",[415,803,714],{},") runs after global middleware but before the matched route handler.",[411,806,808],{"id":807},"routes","Routes",[404,810,811,812,815],{},"Nitro will look at defined routes in the ",[415,813,814],{},"routes/"," folder to match the incoming request.",[431,817,820],{"className":433,"code":818,"filename":819,"language":436,"meta":5,"style":5},"export default (event) => ({ world: true })\n","routes/api/hello.ts",[415,821,822],{"__ignoreMap":5},[440,823,824,826,828,831,833,835,837,840,844],{"class":442,"line":443},[440,825,474],{"class":446},[440,827,477],{"class":446},[440,829,830],{"class":450}," (",[440,832,518],{"class":487},[440,834,491],{"class":450},[440,836,494],{"class":446},[440,838,839],{"class":450}," ({ world: ",[440,841,843],{"class":842},"suiK_","true",[440,845,846],{"class":450}," })\n",[701,848,850],{"to":849},"/docs/routing#filesystem-routing",[404,851,852],{},"Learn more about Nitro file-system routing.",[404,854,855,856,859],{},"If serverEntry is defined it will catch all requests not matching any other route acting as ",[415,857,858],{},"/**"," route handler.",[431,861,864],{"className":433,"code":862,"filename":863,"language":436,"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",[415,865,866,878,882,900,917,927,931],{"__ignoreMap":5},[440,867,868,870,872,874,876],{"class":442,"line":443},[440,869,447],{"class":446},[440,871,728],{"class":450},[440,873,454],{"class":446},[440,875,458],{"class":457},[440,877,461],{"class":450},[440,879,880],{"class":442,"line":464},[440,881,468],{"emptyLinePlaceholder":467},[440,883,884,886,888,890,892,894,896,898],{"class":442,"line":471},[440,885,474],{"class":446},[440,887,477],{"class":446},[440,889,747],{"class":480},[440,891,484],{"class":450},[440,893,518],{"class":487},[440,895,491],{"class":450},[440,897,494],{"class":446},[440,899,497],{"class":450},[440,901,902,905,908,911,914],{"class":442,"line":500},[440,903,904],{"class":446},"  if",[440,906,907],{"class":450}," (event.path ",[440,909,910],{"class":446},"===",[440,912,913],{"class":457}," \"/\"",[440,915,916],{"class":450},") {\n",[440,918,919,922,925],{"class":442,"line":527},[440,920,921],{"class":446},"    return",[440,923,924],{"class":457}," \"Home page\"",[440,926,461],{"class":450},[440,928,929],{"class":442,"line":555},[440,930,694],{"class":450},[440,932,933],{"class":442,"line":561},[440,934,564],{"class":450},[701,936,937],{"to":64},[404,938,939],{},"Learn more about Nitro server entry.",[411,941,18],{"id":942},"renderer",[404,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},[404,949,950],{},"Learn more about Nitro renderer.",[411,952,954,418],{"id":953},"response-hook",[415,955,956],{},"response",[404,958,959,960,962,963,966],{},"After the response is created (from any of the layers above), the ",[415,961,956],{}," hook runs. This hook receives the final ",[415,964,965],{},"Response"," object and the event, and can be used to inspect or modify response headers:",[431,968,971],{"className":433,"code":969,"filename":970,"language":436,"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",[415,972,973,985,989,1007,1033,1064,1068],{"__ignoreMap":5},[440,974,975,977,979,981,983],{"class":442,"line":443},[440,976,447],{"class":446},[440,978,451],{"class":450},[440,980,454],{"class":446},[440,982,458],{"class":457},[440,984,461],{"class":450},[440,986,987],{"class":442,"line":464},[440,988,468],{"emptyLinePlaceholder":467},[440,990,991,993,995,997,999,1001,1003,1005],{"class":442,"line":471},[440,992,474],{"class":446},[440,994,477],{"class":446},[440,996,481],{"class":480},[440,998,484],{"class":450},[440,1000,488],{"class":487},[440,1002,491],{"class":450},[440,1004,494],{"class":446},[440,1006,497],{"class":450},[440,1008,1009,1011,1013,1015,1018,1020,1023,1025,1027,1029,1031],{"class":442,"line":500},[440,1010,503],{"class":450},[440,1012,506],{"class":480},[440,1014,509],{"class":450},[440,1016,1017],{"class":457},"\"response\"",[440,1019,515],{"class":450},[440,1021,1022],{"class":487},"res",[440,1024,603],{"class":450},[440,1026,518],{"class":487},[440,1028,491],{"class":450},[440,1030,494],{"class":446},[440,1032,497],{"class":450},[440,1034,1035,1037,1039,1041,1044,1046,1048,1051,1054,1056,1058,1060,1062],{"class":442,"line":527},[440,1036,530],{"class":450},[440,1038,533],{"class":480},[440,1040,509],{"class":450},[440,1042,1043],{"class":457},"`Response ${",[440,1045,1022],{"class":450},[440,1047,543],{"class":457},[440,1049,1050],{"class":450},"status",[440,1052,1053],{"class":457},"} for ${",[440,1055,518],{"class":450},[440,1057,543],{"class":457},[440,1059,546],{"class":450},[440,1061,549],{"class":457},[440,1063,552],{"class":450},[440,1065,1066],{"class":442,"line":555},[440,1067,558],{"class":450},[440,1069,1070],{"class":442,"line":561},[440,1071,564],{"class":450},[566,1073,1074],{},[404,1075,421,1076,1078],{},[415,1077,956],{}," hook runs for every response, including static assets, middleware-terminated requests, and error responses.",[399,1080,1082],{"id":1081},"error-handling","Error handling",[404,1084,1085],{},"When an error occurs at any point in the request lifecycle, Nitro:",[408,1087,1089,1096],{"level":1088},"4",[1090,1091,1092,1093,1095],"h4",{},"Calls the ",[415,1094,579],{}," hook with the error and context (including the event and source tags).",[1090,1097,1098,1099,1102],{},"Passes the error to the ",[593,1100,1101],{},"error handler"," which converts it into an HTTP response.",[431,1104,1107],{"className":433,"code":1105,"filename":1106,"language":436,"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",[415,1108,1109,1121,1125,1143,1169,1183,1189,1194,1199],{"__ignoreMap":5},[440,1110,1111,1113,1115,1117,1119],{"class":442,"line":443},[440,1112,447],{"class":446},[440,1114,451],{"class":450},[440,1116,454],{"class":446},[440,1118,458],{"class":457},[440,1120,461],{"class":450},[440,1122,1123],{"class":442,"line":464},[440,1124,468],{"emptyLinePlaceholder":467},[440,1126,1127,1129,1131,1133,1135,1137,1139,1141],{"class":442,"line":471},[440,1128,474],{"class":446},[440,1130,477],{"class":446},[440,1132,481],{"class":480},[440,1134,484],{"class":450},[440,1136,488],{"class":487},[440,1138,491],{"class":450},[440,1140,494],{"class":446},[440,1142,497],{"class":450},[440,1144,1145,1147,1149,1151,1154,1156,1158,1160,1163,1165,1167],{"class":442,"line":500},[440,1146,503],{"class":450},[440,1148,506],{"class":480},[440,1150,509],{"class":450},[440,1152,1153],{"class":457},"\"error\"",[440,1155,515],{"class":450},[440,1157,579],{"class":487},[440,1159,603],{"class":450},[440,1161,1162],{"class":487},"context",[440,1164,491],{"class":450},[440,1166,494],{"class":446},[440,1168,497],{"class":450},[440,1170,1171,1173,1175,1177,1180],{"class":442,"line":527},[440,1172,530],{"class":450},[440,1174,579],{"class":480},[440,1176,509],{"class":450},[440,1178,1179],{"class":457},"\"Captured error:\"",[440,1181,1182],{"class":450},", error);\n",[440,1184,1185],{"class":442,"line":555},[440,1186,1188],{"class":1187},"sCsY4","    // context.event - the H3 event (if available)\n",[440,1190,1191],{"class":442,"line":561},[440,1192,1193],{"class":1187},"    // context.tags  - error source tags like \"request\", \"response\", \"plugin\"\n",[440,1195,1197],{"class":442,"line":1196},8,[440,1198,558],{"class":450},[440,1200,1202],{"class":442,"line":1201},9,[440,1203,564],{"class":450},[404,1205,1206,1207,1210],{},"Errors are also tracked per-request in ",[415,1208,1209],{},"event.req.context.nitro.errors"," for inspection in later hooks.",[404,1212,1213],{},"You can provide a custom error handler in the Nitro config to control error response formatting:",[431,1215,1217],{"className":433,"code":1216,"filename":632,"language":436,"meta":5,"style":5},"import { defineNitroConfig } from \"nitro/config\";\n\nexport default defineNitroConfig({\n  errorHandler: \"~/error\",\n})\n",[415,1218,1219,1231,1235,1245,1256],{"__ignoreMap":5},[440,1220,1221,1223,1225,1227,1229],{"class":442,"line":443},[440,1222,447],{"class":446},[440,1224,641],{"class":450},[440,1226,454],{"class":446},[440,1228,646],{"class":457},[440,1230,461],{"class":450},[440,1232,1233],{"class":442,"line":464},[440,1234,468],{"emptyLinePlaceholder":467},[440,1236,1237,1239,1241,1243],{"class":442,"line":471},[440,1238,474],{"class":446},[440,1240,477],{"class":446},[440,1242,661],{"class":480},[440,1244,664],{"class":450},[440,1246,1247,1250,1253],{"class":442,"line":500},[440,1248,1249],{"class":450},"  errorHandler: ",[440,1251,1252],{"class":457},"\"~/error\"",[440,1254,1255],{"class":450},",\n",[440,1257,1258],{"class":442,"line":527},[440,1259,699],{"class":450},[404,1261,1262,1263,1265,1266,1269,1270,543],{},"Additionally, unhandled promise rejections and uncaught exceptions at the process level are automatically captured into the ",[415,1264,579],{}," hook with the tags ",[415,1267,1268],{},"\"unhandledRejection\""," and ",[415,1271,1272],{},"\"uncaughtException\"",[399,1274,1276],{"id":1275},"server-shutdown","Server shutdown",[404,1278,1279,1280,1283],{},"When the Nitro server is shutting down, the ",[415,1281,1282],{},"close"," hook is called. Use this to clean up resources such as database connections, timers, or external service handles:",[431,1285,1288],{"className":433,"code":1286,"filename":1287,"language":436,"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",[415,1289,1290,1302,1306,1324,1347,1352,1356],{"__ignoreMap":5},[440,1291,1292,1294,1296,1298,1300],{"class":442,"line":443},[440,1293,447],{"class":446},[440,1295,451],{"class":450},[440,1297,454],{"class":446},[440,1299,458],{"class":457},[440,1301,461],{"class":450},[440,1303,1304],{"class":442,"line":464},[440,1305,468],{"emptyLinePlaceholder":467},[440,1307,1308,1310,1312,1314,1316,1318,1320,1322],{"class":442,"line":471},[440,1309,474],{"class":446},[440,1311,477],{"class":446},[440,1313,481],{"class":480},[440,1315,484],{"class":450},[440,1317,488],{"class":487},[440,1319,491],{"class":450},[440,1321,494],{"class":446},[440,1323,497],{"class":450},[440,1325,1326,1328,1330,1332,1335,1337,1340,1343,1345],{"class":442,"line":500},[440,1327,503],{"class":450},[440,1329,506],{"class":480},[440,1331,509],{"class":450},[440,1333,1334],{"class":457},"\"close\"",[440,1336,603],{"class":450},[440,1338,1339],{"class":446},"async",[440,1341,1342],{"class":450}," () ",[440,1344,494],{"class":446},[440,1346,497],{"class":450},[440,1348,1349],{"class":442,"line":527},[440,1350,1351],{"class":1187},"    // Clean up resources\n",[440,1353,1354],{"class":442,"line":555},[440,1355,558],{"class":450},[440,1357,1358],{"class":442,"line":561},[440,1359,564],{"class":450},[399,1361,1363],{"id":1362},"hooks-reference","Hooks reference",[404,1365,1366,1367,1370,1371,543],{},"All runtime hooks are registered through ",[426,1368,1369],{"href":49},"server plugins"," using ",[415,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",{},[415,1402,417],{},[1399,1404,1405],{},[415,1406,1407],{},"(event: HTTPEvent) => void | Promise\u003Cvoid>",[1399,1409,1410],{},"Start of each request, before routing.",[1381,1412,1413,1417,1422],{},[1399,1414,1415],{},[415,1416,956],{},[1399,1418,1419],{},[415,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],{},[415,1430,579],{},[1399,1432,1433],{},[415,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],{},[415,1444,1282],{},[1399,1446,1447],{},[415,1448,1449],{},"() => void",[1399,1451,1452],{},"When the Nitro server is shutting down.",[566,1454,1455],{},[404,1456,421,1457,1460],{},[415,1458,1459],{},"NitroRuntimeHooks"," interface is augmentable. Deployment presets (such as Cloudflare) can extend it with platform-specific hooks.",[701,1462,1463],{"to":49},[404,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":464,"depth":464,"links":1471},[1472,1484,1485,1486],{"id":401,"depth":464,"text":402,"children":1473},[1474,1476,1477,1478,1479,1480,1481,1482],{"id":413,"depth":471,"text":1475},"request hook",{"id":583,"depth":471,"text":584},{"id":624,"depth":471,"text":625},{"id":707,"depth":471,"text":708},{"id":793,"depth":471,"text":794},{"id":807,"depth":471,"text":808},{"id":942,"depth":471,"text":18},{"id":953,"depth":471,"text":1483},"response hook",{"id":1081,"depth":464,"text":1082},{"id":1275,"depth":464,"text":1276},{"id":1362,"depth":464,"text":1363},"Understand how Nitro runs and serves incoming requests to your application.","md",{"icon":46},{"icon":46},{"title":43,"description":1487},"I3k2q5hn5JekuCe722O32DlzGxy-G-p-uoxLbIYOz2k",[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},"Use plugins to extend Nitro's runtime behavior.",1775753662487]