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