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