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