[{"data":1,"prerenderedAt":1660},["ShallowReactive",2],{"navigation":3,"-docs-plugins":407,"-docs-plugins-surround":1655},[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":53,"body":409,"description":1649,"extension":1650,"meta":1651,"navigation":1652,"path":54,"seo":1653,"stem":55,"__hash__":1654},"content\u002F1.docs\u002F50.plugins.md",{"type":410,"value":411,"toc":1634,"icon":56},"minimark",[412,426,437,442,533,540,590,598,604,699,703,710,714,796,800,876,894,898,904,1011,1014,1018,1021,1126,1154,1158,1164,1245,1249,1255,1327,1331,1334,1469,1473,1630],[413,414,415,416,420,421,425],"p",{},"Nitro plugins are ",[417,418,419],"strong",{},"executed once"," during server startup in order to allow extending Nitro's runtime behavior.\nThey receive ",[422,423,424],"code",{},"nitroApp"," context, which can be used to hook into lifecycle events.",[413,427,428,429,432,433,436],{},"Plugins are auto-registered from the ",[422,430,431],{},"plugins\u002F"," directory and run synchronously by file name order on the first Nitro initialization. Plugin functions themselves must be synchronous (return ",[422,434,435],{},"void","), but the hooks they register can be async.",[413,438,439],{},[417,440,441],{},"Example:",[443,444,449],"pre",{"className":445,"code":446,"filename":447,"language":448,"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  console.log('Nitro plugin', nitroApp)\n})\n","plugins\u002Ftest.ts","ts",[422,450,451,474,481,509,527],{"__ignoreMap":5},[452,453,456,460,464,467,471],"span",{"class":454,"line":455},"line",1,[452,457,459],{"class":458},"so5gQ","import",[452,461,463],{"class":462},"slsVL"," { definePlugin } ",[452,465,466],{"class":458},"from",[452,468,470],{"class":469},"sfrk1"," \"nitro\"",[452,472,473],{"class":462},";\n",[452,475,477],{"class":454,"line":476},2,[452,478,480],{"emptyLinePlaceholder":479},true,"\n",[452,482,484,487,490,494,497,500,503,506],{"class":454,"line":483},3,[452,485,486],{"class":458},"export",[452,488,489],{"class":458}," default",[452,491,493],{"class":492},"shcOC"," definePlugin",[452,495,496],{"class":462},"((",[452,498,424],{"class":499},"sQHwn",[452,501,502],{"class":462},") ",[452,504,505],{"class":458},"=>",[452,507,508],{"class":462}," {\n",[452,510,512,515,518,521,524],{"class":454,"line":511},4,[452,513,514],{"class":462},"  console.",[452,516,517],{"class":492},"log",[452,519,520],{"class":462},"(",[452,522,523],{"class":469},"'Nitro plugin'",[452,525,526],{"class":462},", nitroApp)\n",[452,528,530],{"class":454,"line":529},5,[452,531,532],{"class":462},"})\n",[413,534,535,536,539],{},"If you have plugins in another directory, you can use the ",[422,537,538],{},"plugins"," option:",[443,541,544],{"className":445,"code":542,"filename":543,"language":448,"meta":5,"style":5},"import { defineConfig } from \"nitro\";\n\nexport default defineConfig({\n  plugins: ['my-plugins\u002Fhello.ts']\n})\n","nitro.config.ts",[422,545,546,559,563,575,586],{"__ignoreMap":5},[452,547,548,550,553,555,557],{"class":454,"line":455},[452,549,459],{"class":458},[452,551,552],{"class":462}," { defineConfig } ",[452,554,466],{"class":458},[452,556,470],{"class":469},[452,558,473],{"class":462},[452,560,561],{"class":454,"line":476},[452,562,480],{"emptyLinePlaceholder":479},[452,564,565,567,569,572],{"class":454,"line":483},[452,566,486],{"class":458},[452,568,489],{"class":458},[452,570,571],{"class":492}," defineConfig",[452,573,574],{"class":462},"({\n",[452,576,577,580,583],{"class":454,"line":511},[452,578,579],{"class":462},"  plugins: [",[452,581,582],{"class":469},"'my-plugins\u002Fhello.ts'",[452,584,585],{"class":462},"]\n",[452,587,588],{"class":454,"line":529},[452,589,532],{"class":462},[591,592,594,595,597],"h2",{"id":593},"the-nitroapp-context","The ",[422,596,424],{}," context",[413,599,600,601,603],{},"The plugin function receives a ",[422,602,424],{}," object with the following properties:",[605,606,607,623],"table",{},[608,609,610],"thead",{},[611,612,613,617,620],"tr",{},[614,615,616],"th",{},"Property",[614,618,619],{},"Type",[614,621,622],{},"Description",[624,625,626,648,669,684],"tbody",{},[611,627,628,634,645],{},[629,630,631],"td",{},[422,632,633],{},"hooks",[629,635,636],{},[637,638,642],"a",{"href":639,"rel":640},"https:\u002F\u002Fgithub.com\u002Funjs\u002Fhookable",[641],"nofollow",[422,643,644],{},"HookableCore",[629,646,647],{},"Hook system for registering lifecycle callbacks.",[611,649,650,655,660],{},[629,651,652],{},[422,653,654],{},"h3",[629,656,657],{},[422,658,659],{},"H3Core",[629,661,662,663,668],{},"The underlying ",[637,664,667],{"href":665,"rel":666},"https:\u002F\u002Fgithub.com\u002Fh3js\u002Fh3",[641],"H3"," application instance.",[611,670,671,676,681],{},[629,672,673],{},[422,674,675],{},"fetch",[629,677,678],{},[422,679,680],{},"(req: Request) => Response | Promise\u003CResponse>",[629,682,683],{},"The app's internal fetch handler.",[611,685,686,691,696],{},[629,687,688],{},[422,689,690],{},"captureError",[629,692,693],{},[422,694,695],{},"(error: Error, context) => void",[629,697,698],{},"Programmatically capture errors into the error hook pipeline.",[591,700,702],{"id":701},"nitro-runtime-hooks","Nitro runtime hooks",[413,704,705,706,709],{},"You can use Nitro ",[637,707,633],{"href":639,"rel":708},[641]," to extend the default runtime behaviour of Nitro by registering custom functions to the lifecycle events within plugins.",[413,711,712],{},[417,713,441],{},[443,715,717],{"className":445,"code":716,"language":448,"meta":5,"style":5},"import { definePlugin } from \"nitro\";\n\nexport default definePlugin((nitroApp) => {\n  nitroApp.hooks.hook(\"close\", async () => {\n    \u002F\u002F Will run when nitro is being closed\n  });\n})\n",[422,718,719,731,735,753,779,785,791],{"__ignoreMap":5},[452,720,721,723,725,727,729],{"class":454,"line":455},[452,722,459],{"class":458},[452,724,463],{"class":462},[452,726,466],{"class":458},[452,728,470],{"class":469},[452,730,473],{"class":462},[452,732,733],{"class":454,"line":476},[452,734,480],{"emptyLinePlaceholder":479},[452,736,737,739,741,743,745,747,749,751],{"class":454,"line":483},[452,738,486],{"class":458},[452,740,489],{"class":458},[452,742,493],{"class":492},[452,744,496],{"class":462},[452,746,424],{"class":499},[452,748,502],{"class":462},[452,750,505],{"class":458},[452,752,508],{"class":462},[452,754,755,758,761,763,766,769,772,775,777],{"class":454,"line":511},[452,756,757],{"class":462},"  nitroApp.hooks.",[452,759,760],{"class":492},"hook",[452,762,520],{"class":462},[452,764,765],{"class":469},"\"close\"",[452,767,768],{"class":462},", ",[452,770,771],{"class":458},"async",[452,773,774],{"class":462}," () ",[452,776,505],{"class":458},[452,778,508],{"class":462},[452,780,781],{"class":454,"line":529},[452,782,784],{"class":783},"sCsY4","    \u002F\u002F Will run when nitro is being closed\n",[452,786,788],{"class":454,"line":787},6,[452,789,790],{"class":462},"  });\n",[452,792,794],{"class":454,"line":793},7,[452,795,532],{"class":462},[654,797,799],{"id":798},"available-hooks","Available hooks",[605,801,802,814],{},[608,803,804],{},[611,805,806,809,812],{},[614,807,808],{},"Hook",[614,810,811],{},"Signature",[614,813,622],{},[624,815,816,831,846,861],{},[611,817,818,823,828],{},[629,819,820],{},[422,821,822],{},"request",[629,824,825],{},[422,826,827],{},"(event: HTTPEvent) => void | Promise\u003Cvoid>",[629,829,830],{},"Called at the start of each request.",[611,832,833,838,843],{},[629,834,835],{},[422,836,837],{},"response",[629,839,840],{},[422,841,842],{},"(res: Response, event: HTTPEvent) => void | Promise\u003Cvoid>",[629,844,845],{},"Called after the response is created.",[611,847,848,853,858],{},[629,849,850],{},[422,851,852],{},"error",[629,854,855],{},[422,856,857],{},"(error: Error, context: { event?: HTTPEvent, tags?: string[] }) => void",[629,859,860],{},"Called when an error is captured.",[611,862,863,868,873],{},[629,864,865],{},[422,866,867],{},"close",[629,869,870],{},[422,871,872],{},"() => void",[629,874,875],{},"Called when the Nitro server is shutting down.",[877,878,879],"note",{},[413,880,881,882,885,886,889,890,893],{},"\nThe ",[422,883,884],{},"NitroRuntimeHooks"," interface is augmentable. Deployment presets (such as Cloudflare) can extend it with platform-specific hooks like ",[422,887,888],{},"cloudflare:scheduled"," and ",[422,891,892],{},"cloudflare:email",".",[654,895,897],{"id":896},"unregistering-hooks","Unregistering hooks",[413,899,594,900,903],{},[422,901,902],{},"hook()"," method returns an unregister function that can be called to remove the hook:",[443,905,907],{"className":445,"code":906,"language":448,"meta":5,"style":5},"import { definePlugin } from \"nitro\";\n\nexport default definePlugin((nitroApp) => {\n  const unregister = nitroApp.hooks.hook(\"request\", (event) => {\n    \u002F\u002F ...\n  });\n\n  \u002F\u002F Later, remove the hook\n  unregister();\n});\n",[422,908,909,921,925,943,977,982,986,990,996,1005],{"__ignoreMap":5},[452,910,911,913,915,917,919],{"class":454,"line":455},[452,912,459],{"class":458},[452,914,463],{"class":462},[452,916,466],{"class":458},[452,918,470],{"class":469},[452,920,473],{"class":462},[452,922,923],{"class":454,"line":476},[452,924,480],{"emptyLinePlaceholder":479},[452,926,927,929,931,933,935,937,939,941],{"class":454,"line":483},[452,928,486],{"class":458},[452,930,489],{"class":458},[452,932,493],{"class":492},[452,934,496],{"class":462},[452,936,424],{"class":499},[452,938,502],{"class":462},[452,940,505],{"class":458},[452,942,508],{"class":462},[452,944,945,948,952,955,958,960,962,965,968,971,973,975],{"class":454,"line":511},[452,946,947],{"class":458},"  const",[452,949,951],{"class":950},"suiK_"," unregister",[452,953,954],{"class":458}," =",[452,956,957],{"class":462}," nitroApp.hooks.",[452,959,760],{"class":492},[452,961,520],{"class":462},[452,963,964],{"class":469},"\"request\"",[452,966,967],{"class":462},", (",[452,969,970],{"class":499},"event",[452,972,502],{"class":462},[452,974,505],{"class":458},[452,976,508],{"class":462},[452,978,979],{"class":454,"line":529},[452,980,981],{"class":783},"    \u002F\u002F ...\n",[452,983,984],{"class":454,"line":787},[452,985,790],{"class":462},[452,987,988],{"class":454,"line":793},[452,989,480],{"emptyLinePlaceholder":479},[452,991,993],{"class":454,"line":992},8,[452,994,995],{"class":783},"  \u002F\u002F Later, remove the hook\n",[452,997,999,1002],{"class":454,"line":998},9,[452,1000,1001],{"class":492},"  unregister",[452,1003,1004],{"class":462},"();\n",[452,1006,1008],{"class":454,"line":1007},10,[452,1009,1010],{"class":462},"});\n",[591,1012,233],{"id":1013},"examples",[654,1015,1017],{"id":1016},"capturing-errors","Capturing errors",[413,1019,1020],{},"You can use plugins to capture all application errors.",[443,1022,1024],{"className":445,"code":1023,"language":448,"meta":5,"style":5},"import { definePlugin } from \"nitro\";\n\nexport default definePlugin((nitroApp) => {\n  nitroApp.hooks.hook(\"error\", async (error, { event }) => {\n    console.error(`${event?.path} Application error:`, error)\n  });\n})\n",[422,1025,1026,1038,1042,1060,1092,1118,1122],{"__ignoreMap":5},[452,1027,1028,1030,1032,1034,1036],{"class":454,"line":455},[452,1029,459],{"class":458},[452,1031,463],{"class":462},[452,1033,466],{"class":458},[452,1035,470],{"class":469},[452,1037,473],{"class":462},[452,1039,1040],{"class":454,"line":476},[452,1041,480],{"emptyLinePlaceholder":479},[452,1043,1044,1046,1048,1050,1052,1054,1056,1058],{"class":454,"line":483},[452,1045,486],{"class":458},[452,1047,489],{"class":458},[452,1049,493],{"class":492},[452,1051,496],{"class":462},[452,1053,424],{"class":499},[452,1055,502],{"class":462},[452,1057,505],{"class":458},[452,1059,508],{"class":462},[452,1061,1062,1064,1066,1068,1071,1073,1075,1078,1080,1083,1085,1088,1090],{"class":454,"line":511},[452,1063,757],{"class":462},[452,1065,760],{"class":492},[452,1067,520],{"class":462},[452,1069,1070],{"class":469},"\"error\"",[452,1072,768],{"class":462},[452,1074,771],{"class":458},[452,1076,1077],{"class":462}," (",[452,1079,852],{"class":499},[452,1081,1082],{"class":462},", { ",[452,1084,970],{"class":499},[452,1086,1087],{"class":462}," }) ",[452,1089,505],{"class":458},[452,1091,508],{"class":462},[452,1093,1094,1097,1099,1101,1104,1106,1109,1112,1115],{"class":454,"line":529},[452,1095,1096],{"class":462},"    console.",[452,1098,852],{"class":492},[452,1100,520],{"class":462},[452,1102,1103],{"class":469},"`${",[452,1105,970],{"class":462},[452,1107,1108],{"class":469},"?.",[452,1110,1111],{"class":462},"path",[452,1113,1114],{"class":469},"} Application error:`",[452,1116,1117],{"class":462},", error)\n",[452,1119,1120],{"class":454,"line":787},[452,1121,790],{"class":462},[452,1123,1124],{"class":454,"line":793},[452,1125,532],{"class":462},[413,1127,594,1128,1131,1132,1135,1136,768,1138,768,1141,768,1144,768,1147,768,1150,1153],{},[422,1129,1130],{},"context"," object includes an optional ",[422,1133,1134],{},"tags"," array that identifies the error source (e.g., ",[422,1137,964],{},[422,1139,1140],{},"\"response\"",[422,1142,1143],{},"\"cache\"",[422,1145,1146],{},"\"plugin\"",[422,1148,1149],{},"\"unhandledRejection\"",[422,1151,1152],{},"\"uncaughtException\"",").",[654,1155,1157],{"id":1156},"programmatic-error-capture","Programmatic error capture",[413,1159,1160,1161,1163],{},"You can use ",[422,1162,690],{}," to manually feed errors into the error hook pipeline:",[443,1165,1167],{"className":445,"code":1166,"language":448,"meta":5,"style":5},"import { definePlugin } from \"nitro\";\n\nexport default definePlugin((nitroApp) => {\n  nitroApp.captureError(new Error(\"something went wrong\"), {\n    tags: [\"startup\"],\n  });\n});\n",[422,1168,1169,1181,1185,1203,1226,1237,1241],{"__ignoreMap":5},[452,1170,1171,1173,1175,1177,1179],{"class":454,"line":455},[452,1172,459],{"class":458},[452,1174,463],{"class":462},[452,1176,466],{"class":458},[452,1178,470],{"class":469},[452,1180,473],{"class":462},[452,1182,1183],{"class":454,"line":476},[452,1184,480],{"emptyLinePlaceholder":479},[452,1186,1187,1189,1191,1193,1195,1197,1199,1201],{"class":454,"line":483},[452,1188,486],{"class":458},[452,1190,489],{"class":458},[452,1192,493],{"class":492},[452,1194,496],{"class":462},[452,1196,424],{"class":499},[452,1198,502],{"class":462},[452,1200,505],{"class":458},[452,1202,508],{"class":462},[452,1204,1205,1208,1210,1212,1215,1218,1220,1223],{"class":454,"line":511},[452,1206,1207],{"class":462},"  nitroApp.",[452,1209,690],{"class":492},[452,1211,520],{"class":462},[452,1213,1214],{"class":458},"new",[452,1216,1217],{"class":492}," Error",[452,1219,520],{"class":462},[452,1221,1222],{"class":469},"\"something went wrong\"",[452,1224,1225],{"class":462},"), {\n",[452,1227,1228,1231,1234],{"class":454,"line":529},[452,1229,1230],{"class":462},"    tags: [",[452,1232,1233],{"class":469},"\"startup\"",[452,1235,1236],{"class":462},"],\n",[452,1238,1239],{"class":454,"line":787},[452,1240,790],{"class":462},[452,1242,1243],{"class":454,"line":793},[452,1244,1010],{"class":462},[654,1246,1248],{"id":1247},"graceful-shutdown","Graceful shutdown",[413,1250,1251,1252,893],{},"Server will gracefully shutdown and wait for any background pending tasks initiated by ",[422,1253,1254],{},"event.waitUntil",[443,1256,1258],{"className":445,"code":1257,"language":448,"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, close connections, etc.\n  });\n});\n",[422,1259,1260,1272,1276,1294,1314,1319,1323],{"__ignoreMap":5},[452,1261,1262,1264,1266,1268,1270],{"class":454,"line":455},[452,1263,459],{"class":458},[452,1265,463],{"class":462},[452,1267,466],{"class":458},[452,1269,470],{"class":469},[452,1271,473],{"class":462},[452,1273,1274],{"class":454,"line":476},[452,1275,480],{"emptyLinePlaceholder":479},[452,1277,1278,1280,1282,1284,1286,1288,1290,1292],{"class":454,"line":483},[452,1279,486],{"class":458},[452,1281,489],{"class":458},[452,1283,493],{"class":492},[452,1285,496],{"class":462},[452,1287,424],{"class":499},[452,1289,502],{"class":462},[452,1291,505],{"class":458},[452,1293,508],{"class":462},[452,1295,1296,1298,1300,1302,1304,1306,1308,1310,1312],{"class":454,"line":511},[452,1297,757],{"class":462},[452,1299,760],{"class":492},[452,1301,520],{"class":462},[452,1303,765],{"class":469},[452,1305,768],{"class":462},[452,1307,771],{"class":458},[452,1309,774],{"class":462},[452,1311,505],{"class":458},[452,1313,508],{"class":462},[452,1315,1316],{"class":454,"line":529},[452,1317,1318],{"class":783},"    \u002F\u002F Clean up resources, close connections, etc.\n",[452,1320,1321],{"class":454,"line":787},[452,1322,790],{"class":462},[452,1324,1325],{"class":454,"line":793},[452,1326,1010],{"class":462},[654,1328,1330],{"id":1329},"request-and-response-lifecycle","Request and response lifecycle",[413,1332,1333],{},"You can use plugins to register hooks that run on the request lifecycle:",[443,1335,1337],{"className":445,"code":1336,"language":448,"meta":5,"style":5},"import { definePlugin } from \"nitro\";\n\nexport default definePlugin((nitroApp) => {\n  nitroApp.hooks.hook(\"request\", (event) => {\n    console.log(\"on request\", event.path);\n  });\n\n  nitroApp.hooks.hook(\"response\", (res, event) => {\n    \u002F\u002F Modify or inspect the response\n    console.log(\"on response\", res.status);\n  });\n});\n",[422,1338,1339,1351,1355,1373,1393,1407,1411,1415,1440,1445,1459,1464],{"__ignoreMap":5},[452,1340,1341,1343,1345,1347,1349],{"class":454,"line":455},[452,1342,459],{"class":458},[452,1344,463],{"class":462},[452,1346,466],{"class":458},[452,1348,470],{"class":469},[452,1350,473],{"class":462},[452,1352,1353],{"class":454,"line":476},[452,1354,480],{"emptyLinePlaceholder":479},[452,1356,1357,1359,1361,1363,1365,1367,1369,1371],{"class":454,"line":483},[452,1358,486],{"class":458},[452,1360,489],{"class":458},[452,1362,493],{"class":492},[452,1364,496],{"class":462},[452,1366,424],{"class":499},[452,1368,502],{"class":462},[452,1370,505],{"class":458},[452,1372,508],{"class":462},[452,1374,1375,1377,1379,1381,1383,1385,1387,1389,1391],{"class":454,"line":511},[452,1376,757],{"class":462},[452,1378,760],{"class":492},[452,1380,520],{"class":462},[452,1382,964],{"class":469},[452,1384,967],{"class":462},[452,1386,970],{"class":499},[452,1388,502],{"class":462},[452,1390,505],{"class":458},[452,1392,508],{"class":462},[452,1394,1395,1397,1399,1401,1404],{"class":454,"line":529},[452,1396,1096],{"class":462},[452,1398,517],{"class":492},[452,1400,520],{"class":462},[452,1402,1403],{"class":469},"\"on request\"",[452,1405,1406],{"class":462},", event.path);\n",[452,1408,1409],{"class":454,"line":787},[452,1410,790],{"class":462},[452,1412,1413],{"class":454,"line":793},[452,1414,480],{"emptyLinePlaceholder":479},[452,1416,1417,1419,1421,1423,1425,1427,1430,1432,1434,1436,1438],{"class":454,"line":992},[452,1418,757],{"class":462},[452,1420,760],{"class":492},[452,1422,520],{"class":462},[452,1424,1140],{"class":469},[452,1426,967],{"class":462},[452,1428,1429],{"class":499},"res",[452,1431,768],{"class":462},[452,1433,970],{"class":499},[452,1435,502],{"class":462},[452,1437,505],{"class":458},[452,1439,508],{"class":462},[452,1441,1442],{"class":454,"line":998},[452,1443,1444],{"class":783},"    \u002F\u002F Modify or inspect the response\n",[452,1446,1447,1449,1451,1453,1456],{"class":454,"line":1007},[452,1448,1096],{"class":462},[452,1450,517],{"class":492},[452,1452,520],{"class":462},[452,1454,1455],{"class":469},"\"on response\"",[452,1457,1458],{"class":462},", res.status);\n",[452,1460,1462],{"class":454,"line":1461},11,[452,1463,790],{"class":462},[452,1465,1467],{"class":454,"line":1466},12,[452,1468,1010],{"class":462},[654,1470,1472],{"id":1471},"modifying-response-headers","Modifying response headers",[443,1474,1476],{"className":445,"code":1475,"language":448,"meta":5,"style":5},"import { definePlugin } from \"nitro\";\n\nexport default definePlugin((nitroApp) => {\n  nitroApp.hooks.hook(\"response\", (res, event) => {\n    const { pathname } = new URL(event.req.url);\n    if (pathname.endsWith(\".css\") || pathname.endsWith(\".js\")) {\n      res.headers.append(\"Vary\", \"Origin\");\n    }\n  });\n});\n",[422,1477,1478,1490,1494,1512,1536,1562,1596,1617,1622,1626],{"__ignoreMap":5},[452,1479,1480,1482,1484,1486,1488],{"class":454,"line":455},[452,1481,459],{"class":458},[452,1483,463],{"class":462},[452,1485,466],{"class":458},[452,1487,470],{"class":469},[452,1489,473],{"class":462},[452,1491,1492],{"class":454,"line":476},[452,1493,480],{"emptyLinePlaceholder":479},[452,1495,1496,1498,1500,1502,1504,1506,1508,1510],{"class":454,"line":483},[452,1497,486],{"class":458},[452,1499,489],{"class":458},[452,1501,493],{"class":492},[452,1503,496],{"class":462},[452,1505,424],{"class":499},[452,1507,502],{"class":462},[452,1509,505],{"class":458},[452,1511,508],{"class":462},[452,1513,1514,1516,1518,1520,1522,1524,1526,1528,1530,1532,1534],{"class":454,"line":511},[452,1515,757],{"class":462},[452,1517,760],{"class":492},[452,1519,520],{"class":462},[452,1521,1140],{"class":469},[452,1523,967],{"class":462},[452,1525,1429],{"class":499},[452,1527,768],{"class":462},[452,1529,970],{"class":499},[452,1531,502],{"class":462},[452,1533,505],{"class":458},[452,1535,508],{"class":462},[452,1537,1538,1541,1544,1547,1550,1553,1556,1559],{"class":454,"line":529},[452,1539,1540],{"class":458},"    const",[452,1542,1543],{"class":462}," { ",[452,1545,1546],{"class":950},"pathname",[452,1548,1549],{"class":462}," } ",[452,1551,1552],{"class":458},"=",[452,1554,1555],{"class":458}," new",[452,1557,1558],{"class":492}," URL",[452,1560,1561],{"class":462},"(event.req.url);\n",[452,1563,1564,1567,1570,1573,1575,1578,1580,1583,1586,1588,1590,1593],{"class":454,"line":787},[452,1565,1566],{"class":458},"    if",[452,1568,1569],{"class":462}," (pathname.",[452,1571,1572],{"class":492},"endsWith",[452,1574,520],{"class":462},[452,1576,1577],{"class":469},"\".css\"",[452,1579,502],{"class":462},[452,1581,1582],{"class":458},"||",[452,1584,1585],{"class":462}," pathname.",[452,1587,1572],{"class":492},[452,1589,520],{"class":462},[452,1591,1592],{"class":469},"\".js\"",[452,1594,1595],{"class":462},")) {\n",[452,1597,1598,1601,1604,1606,1609,1611,1614],{"class":454,"line":793},[452,1599,1600],{"class":462},"      res.headers.",[452,1602,1603],{"class":492},"append",[452,1605,520],{"class":462},[452,1607,1608],{"class":469},"\"Vary\"",[452,1610,768],{"class":462},[452,1612,1613],{"class":469},"\"Origin\"",[452,1615,1616],{"class":462},");\n",[452,1618,1619],{"class":454,"line":992},[452,1620,1621],{"class":462},"    }\n",[452,1623,1624],{"class":454,"line":998},[452,1625,790],{"class":462},[452,1627,1628],{"class":454,"line":1007},[452,1629,1010],{"class":462},[1631,1632,1633],"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 .sCsY4, html code.shiki .sCsY4{--shiki-light:#6A737D;--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .suiK_, html code.shiki .suiK_{--shiki-light:#005CC5;--shiki-default:#79B8FF;--shiki-dark:#79B8FF}",{"title":5,"searchDepth":476,"depth":476,"links":1635},[1636,1638,1642],{"id":593,"depth":476,"text":1637},"The nitroApp context",{"id":701,"depth":476,"text":702,"children":1639},[1640,1641],{"id":798,"depth":483,"text":799},{"id":896,"depth":483,"text":897},{"id":1013,"depth":476,"text":233,"children":1643},[1644,1645,1646,1647,1648],{"id":1016,"depth":483,"text":1017},{"id":1156,"depth":483,"text":1157},{"id":1247,"depth":483,"text":1248},{"id":1329,"depth":483,"text":1330},{"id":1471,"depth":483,"text":1472},"Use plugins to extend Nitro's runtime behavior.","md",{"icon":56},{"icon":56},{"title":53,"description":1649},"_GTo-n3BA4c0a3nUJ6nx8EuxQ2IMQiLn8lFCpitAwb8",[1656,1658],{"title":48,"path":49,"stem":50,"description":1657,"icon":51,"children":-1},"Nitro can automatically generate an OpenAPI specification from your route handlers and serve interactive API documentation.",{"title":58,"path":59,"stem":60,"description":1659,"icon":61,"children":-1},"Nitro tasks allow on-off operations in runtime.",1784141727160]