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