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