[{"data":1,"prerenderedAt":1833},["ShallowReactive",2],{"navigation":3,"-docs-server-entry":402,"-docs-server-entry-surround":1828},[4,93,226,232,387,399],{"title":5,"path":6,"stem":7,"children":8,"icon":92},"","/docs","1.docs/1.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","/docs/quick-start","1.docs/2.quick-start","i-lucide-zap",{"title":18,"path":19,"stem":20,"icon":21},"Renderer","/docs/renderer","1.docs/4.renderer","ri:layout-masonry-line",{"title":23,"path":24,"stem":25,"icon":26},"Routing","/docs/routing","1.docs/5.routing","ri:direction-line",{"title":28,"path":29,"stem":30,"icon":31},"Assets","/docs/assets","1.docs/50.assets","ri:image-2-line",{"title":33,"path":34,"stem":35,"icon":36},"Configuration","/docs/configuration","1.docs/50.configuration","ri:settings-3-line",{"title":38,"path":39,"stem":40,"icon":41},"Database","/docs/database","1.docs/50.database","ri:database-2-line",{"title":43,"path":44,"stem":45,"icon":46},"Lifecycle","/docs/lifecycle","1.docs/50.lifecycle","i-lucide-layers",{"title":48,"path":49,"stem":50,"icon":51},"OpenAPI","/docs/openapi","1.docs/50.openapi","ri:contract-line",{"title":53,"path":54,"stem":55,"icon":56},"Plugins","/docs/plugins","1.docs/50.plugins","ri:plug-line",{"title":58,"path":59,"stem":60,"icon":61},"Tasks","/docs/tasks","1.docs/50.tasks","codicon:run-all",{"title":63,"path":64,"stem":65,"icon":66},"WebSocket","/docs/websocket","1.docs/50.websocket","ri:broadcast-fill",{"title":68,"path":69,"stem":70,"icon":71},"Server Entry","/docs/server-entry","1.docs/6.server-entry","ri:server-line",{"title":73,"path":74,"stem":75,"icon":76},"Cache","/docs/cache","1.docs/7.cache","ri:speed-line",{"title":78,"path":79,"stem":80,"icon":81},"KV Storage","/docs/storage","1.docs/8.storage","carbon:datastore",{"title":83,"path":84,"stem":85,"icon":86},"Migration Guide","/docs/migration","1.docs/99.migration","ri:arrow-right-up-line",{"title":88,"path":89,"stem":90,"icon":91},"Nightly Channel","/docs/nightly","1.docs/99.nightly","ri:moon-fill","i-lucide-book-open",{"title":94,"path":95,"stem":96,"children":97,"icon":99},"Deploy","/deploy","2.deploy/0.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","/deploy/runtimes","2.deploy/10.runtimes",[105,110,115],{"title":106,"path":107,"stem":108,"icon":109},"Node.js","/deploy/runtimes/node","2.deploy/10.runtimes/1.node","akar-icons:node-fill",{"title":111,"path":112,"stem":113,"icon":114},"Bun","/deploy/runtimes/bun","2.deploy/10.runtimes/bun","simple-icons:bun",{"title":116,"path":117,"stem":118,"icon":119},"Deno","/deploy/runtimes/deno","2.deploy/10.runtimes/deno","simple-icons:deno",false,{"title":122,"path":123,"stem":124,"children":125,"page":120},"Providers","/deploy/providers","2.deploy/20.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","/deploy/providers/alwaysdata","2.deploy/20.providers/alwaysdata",{"title":131,"path":132,"stem":133},"AWS Lambda","/deploy/providers/aws","2.deploy/20.providers/aws",{"title":135,"path":136,"stem":137},"AWS Amplify","/deploy/providers/aws-amplify","2.deploy/20.providers/aws-amplify",{"title":139,"path":140,"stem":141},"Azure","/deploy/providers/azure","2.deploy/20.providers/azure",{"title":143,"path":144,"stem":145},"Cleavr","/deploy/providers/cleavr","2.deploy/20.providers/cleavr",{"title":147,"path":148,"stem":149},"Cloudflare","/deploy/providers/cloudflare","2.deploy/20.providers/cloudflare",{"title":151,"path":152,"stem":153},"Deno Deploy","/deploy/providers/deno-deploy","2.deploy/20.providers/deno-deploy",{"title":155,"path":156,"stem":157},"DigitalOcean","/deploy/providers/digitalocean","2.deploy/20.providers/digitalocean",{"title":159,"path":160,"stem":161},"EdgeOne Pages","/deploy/providers/edgeone","2.deploy/20.providers/edgeone",{"title":163,"path":164,"stem":165},"Firebase","/deploy/providers/firebase","2.deploy/20.providers/firebase",{"title":167,"path":168,"stem":169},"Flightcontrol","/deploy/providers/flightcontrol","2.deploy/20.providers/flightcontrol",{"title":171,"path":172,"stem":173},"Genezio","/deploy/providers/genezio","2.deploy/20.providers/genezio",{"title":175,"path":176,"stem":177},"GitHub Pages","/deploy/providers/github-pages","2.deploy/20.providers/github-pages",{"title":179,"path":180,"stem":181},"GitLab Pages","/deploy/providers/gitlab-pages","2.deploy/20.providers/gitlab-pages",{"title":183,"path":184,"stem":185},"Heroku","/deploy/providers/heroku","2.deploy/20.providers/heroku",{"title":187,"path":188,"stem":189},"IIS","/deploy/providers/iis","2.deploy/20.providers/iis",{"title":191,"path":192,"stem":193},"Koyeb","/deploy/providers/koyeb","2.deploy/20.providers/koyeb",{"title":195,"path":196,"stem":197},"Netlify","/deploy/providers/netlify","2.deploy/20.providers/netlify",{"title":199,"path":200,"stem":201},"Platform.sh","/deploy/providers/platform-sh","2.deploy/20.providers/platform-sh",{"title":203,"path":204,"stem":205},"Render.com","/deploy/providers/render","2.deploy/20.providers/render",{"title":207,"path":208,"stem":209},"StormKit","/deploy/providers/stormkit","2.deploy/20.providers/stormkit",{"title":211,"path":212,"stem":213},"Vercel","/deploy/providers/vercel","2.deploy/20.providers/vercel",{"title":215,"path":216,"stem":217},"Zeabur","/deploy/providers/zeabur","2.deploy/20.providers/zeabur",{"title":219,"path":220,"stem":221},"Zephyr Cloud","/deploy/providers/zephyr","2.deploy/20.providers/zephyr",{"title":223,"path":224,"stem":225},"Zerops","/deploy/providers/zerops","2.deploy/20.providers/zerops",{"title":227,"path":228,"stem":229,"children":230,"icon":36},"Config","/config","3.config/0.index",[231],{"title":227,"path":228,"stem":229,"icon":36},{"title":233,"path":234,"stem":235,"children":236,"icon":238},"Examples","/examples","4.examples/0.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,359,364,369,373,378,383],{"title":233,"path":234,"stem":235,"icon":238},"i-lucide-folder-code",{"title":240,"path":241,"stem":242,"icon":243},"API Routes","/examples/api-routes","4.examples/api-routes","i-lucide-route",{"title":245,"path":246,"stem":247,"icon":248},"Auto Imports","/examples/auto-imports","4.examples/auto-imports","i-lucide-import",{"title":250,"path":251,"stem":252,"icon":253},"Cached Handler","/examples/cached-handler","4.examples/cached-handler","i-lucide-clock",{"title":255,"path":256,"stem":257,"icon":258},"Custom Error Handler","/examples/custom-error-handler","4.examples/custom-error-handler","i-lucide-alert-circle",{"title":38,"path":260,"stem":261,"icon":262},"/examples/database","4.examples/database","i-lucide-database",{"title":264,"path":265,"stem":266,"icon":267},"Elysia","/examples/elysia","4.examples/elysia","i-skill-icons-elysia-dark",{"title":269,"path":270,"stem":271,"icon":272},"Express","/examples/express","4.examples/express","i-simple-icons-express",{"title":274,"path":275,"stem":276,"icon":277},"Fastify","/examples/fastify","4.examples/fastify","i-simple-icons-fastify",{"title":279,"path":280,"stem":281,"icon":282},"Hello World","/examples/hello-world","4.examples/hello-world","i-lucide-sparkles",{"title":284,"path":285,"stem":286,"icon":287},"Hono","/examples/hono","4.examples/hono","i-logos-hono",{"title":289,"path":290,"stem":291,"icon":292},"Import Alias","/examples/import-alias","4.examples/import-alias","i-lucide-at-sign",{"title":294,"path":295,"stem":296,"icon":46},"Middleware","/examples/middleware","4.examples/middleware",{"title":298,"path":299,"stem":300,"icon":301},"Mono JSX","/examples/mono-jsx","4.examples/mono-jsx","i-lucide-brackets",{"title":303,"path":304,"stem":305,"icon":301},"Nano JSX","/examples/nano-jsx","4.examples/nano-jsx",{"title":53,"path":307,"stem":308,"icon":309},"/examples/plugins","4.examples/plugins","i-lucide-plug",{"title":311,"path":312,"stem":313,"icon":314},"Custom Renderer","/examples/renderer","4.examples/renderer","i-lucide-code",{"title":316,"path":317,"stem":318,"icon":319},"Runtime Config","/examples/runtime-config","4.examples/runtime-config","i-lucide-settings",{"title":321,"path":322,"stem":323,"icon":324},"Server Fetch","/examples/server-fetch","4.examples/server-fetch","i-lucide-arrow-right-left",{"title":326,"path":327,"stem":328,"icon":329},"Shiki","/examples/shiki","4.examples/shiki","i-lucide-highlighter",{"title":331,"path":332,"stem":333,"icon":334},"Virtual Routes","/examples/virtual-routes","4.examples/virtual-routes","i-lucide-box",{"title":336,"path":337,"stem":338,"icon":339},"Vite Nitro Plugin","/examples/vite-nitro-plugin","4.examples/vite-nitro-plugin","i-logos-vitejs",{"title":341,"path":342,"stem":343,"icon":344},"Vite RSC","/examples/vite-rsc","4.examples/vite-rsc","i-logos-react",{"title":346,"path":347,"stem":348,"icon":349},"Vite SSR HTML","/examples/vite-ssr-html","4.examples/vite-ssr-html","i-logos-html-5",{"title":351,"path":352,"stem":353,"icon":354},"SSR with Preact","/examples/vite-ssr-preact","4.examples/vite-ssr-preact","i-logos-preact",{"title":356,"path":357,"stem":358,"icon":344},"SSR with React","/examples/vite-ssr-react","4.examples/vite-ssr-react",{"title":360,"path":361,"stem":362,"icon":363},"SSR with SolidJS","/examples/vite-ssr-solid","4.examples/vite-ssr-solid","i-logos-solidjs-icon",{"title":365,"path":366,"stem":367,"icon":368},"SSR with TanStack Router","/examples/vite-ssr-tsr-react","4.examples/vite-ssr-tsr-react","i-simple-icons-tanstack",{"title":370,"path":371,"stem":372,"icon":368},"SSR with TanStack Start","/examples/vite-ssr-tss-react","4.examples/vite-ssr-tss-react",{"title":374,"path":375,"stem":376,"icon":377},"SSR with Vue Router","/examples/vite-ssr-vue-router","4.examples/vite-ssr-vue-router","i-logos-vue",{"title":379,"path":380,"stem":381,"icon":382},"Vite + tRPC","/examples/vite-trpc","4.examples/vite-trpc","i-simple-icons-trpc",{"title":63,"path":384,"stem":385,"icon":386},"/examples/websocket","4.examples/websocket","i-lucide-radio",{"title":388,"path":389,"stem":390,"children":391},"Blog","/blog","9.blog",[392,395],{"title":388,"path":389,"stem":393,"icon":394},"9.blog/index","i-lucide-file-text",{"title":396,"path":397,"stem":398,"icon":394},"Nitro v3 Beta is here!","/blog/v3-beta","9.blog/1.v3-beta",{"title":5,"path":400,"stem":401},"/","index",{"id":403,"title":404,"body":405,"description":1823,"extension":1702,"meta":1824,"navigation":1825,"path":69,"seo":1826,"stem":70,"__hash__":1827},"content/1.docs/6.server-entry.md","Nitro Server Entry",{"type":406,"value":407,"toc":1806,"icon":71},"minimark",[408,412,421,444,447,713,726,729,751,755,762,767,776,1040,1044,1082,1274,1277,1281,1288,1336,1347,1412,1416,1422,1446,1460,1464,1474,1516,1520,1527,1674,1684,1688,1698,1755,1758,1762,1765,1769,1802],[409,410,411],"p",{},"The server entry is a special handler in Nitro that acts as a global middleware, running for every incoming request before routes are matched. It's commonly used for cross-cutting concerns like authentication, logging, request preprocessing, or creating custom routing logic.",[413,414,416,417],"h2",{"id":415},"auto-detected-serverts","Auto-detected ",[418,419,420],"code",{},"server.ts",[409,422,423,424,426,427,430,431,430,434,430,437,430,440,443],{},"By default, Nitro automatically looks for a ",[418,425,420],{}," (or ",[418,428,429],{},".js",", ",[418,432,433],{},".mjs",[418,435,436],{},".mts",[418,438,439],{},".tsx",[418,441,442],{},".jsx",") file in your project root directory.",[409,445,446],{},"If found, Nitro will use it as the server entry and run it for all incoming requests.",[448,449,450,644],"code-group",{},[451,452,456],"pre",{"className":453,"code":454,"filename":420,"language":455,"meta":5,"style":5},"language-ts shiki shiki-themes github-light github-dark github-dark","export default {\n  async fetch(req: Request) {\n    const url = new URL(req.url);\n\n    // Handle specific routes\n    if (url.pathname === \"/health\") {\n      return new Response(\"OK\", {\n        status: 200,\n        headers: { \"content-type\": \"text/plain\" }\n      });\n    }\n\n    // Add custom headers to all requests\n    // Return nothing to continue to the next handler\n  }\n}\n","ts",[418,457,458,474,500,522,529,536,554,573,585,603,609,615,620,626,632,638],{"__ignoreMap":5},[459,460,463,467,470],"span",{"class":461,"line":462},"line",1,[459,464,466],{"class":465},"so5gQ","export",[459,468,469],{"class":465}," default",[459,471,473],{"class":472},"slsVL"," {\n",[459,475,477,480,484,487,491,494,497],{"class":461,"line":476},2,[459,478,479],{"class":465},"  async",[459,481,483],{"class":482},"shcOC"," fetch",[459,485,486],{"class":472},"(",[459,488,490],{"class":489},"sQHwn","req",[459,492,493],{"class":465},":",[459,495,496],{"class":482}," Request",[459,498,499],{"class":472},") {\n",[459,501,503,506,510,513,516,519],{"class":461,"line":502},3,[459,504,505],{"class":465},"    const",[459,507,509],{"class":508},"suiK_"," url",[459,511,512],{"class":465}," =",[459,514,515],{"class":465}," new",[459,517,518],{"class":482}," URL",[459,520,521],{"class":472},"(req.url);\n",[459,523,525],{"class":461,"line":524},4,[459,526,528],{"emptyLinePlaceholder":527},true,"\n",[459,530,532],{"class":461,"line":531},5,[459,533,535],{"class":534},"sCsY4","    // Handle specific routes\n",[459,537,539,542,545,548,552],{"class":461,"line":538},6,[459,540,541],{"class":465},"    if",[459,543,544],{"class":472}," (url.pathname ",[459,546,547],{"class":465},"===",[459,549,551],{"class":550},"sfrk1"," \"/health\"",[459,553,499],{"class":472},[459,555,557,560,562,565,567,570],{"class":461,"line":556},7,[459,558,559],{"class":465},"      return",[459,561,515],{"class":465},[459,563,564],{"class":482}," Response",[459,566,486],{"class":472},[459,568,569],{"class":550},"\"OK\"",[459,571,572],{"class":472},", {\n",[459,574,576,579,582],{"class":461,"line":575},8,[459,577,578],{"class":472},"        status: ",[459,580,581],{"class":508},"200",[459,583,584],{"class":472},",\n",[459,586,588,591,594,597,600],{"class":461,"line":587},9,[459,589,590],{"class":472},"        headers: { ",[459,592,593],{"class":550},"\"content-type\"",[459,595,596],{"class":472},": ",[459,598,599],{"class":550},"\"text/plain\"",[459,601,602],{"class":472}," }\n",[459,604,606],{"class":461,"line":605},10,[459,607,608],{"class":472},"      });\n",[459,610,612],{"class":461,"line":611},11,[459,613,614],{"class":472},"    }\n",[459,616,618],{"class":461,"line":617},12,[459,619,528],{"emptyLinePlaceholder":527},[459,621,623],{"class":461,"line":622},13,[459,624,625],{"class":534},"    // Add custom headers to all requests\n",[459,627,629],{"class":461,"line":628},14,[459,630,631],{"class":534},"    // Return nothing to continue to the next handler\n",[459,633,635],{"class":461,"line":634},15,[459,636,637],{"class":472},"  }\n",[459,639,641],{"class":461,"line":640},16,[459,642,643],{"class":472},"}\n",[451,645,648],{"className":453,"code":646,"filename":647,"language":455,"meta":5,"style":5},"import { defineHandler } from \"nitro\";\n\nexport default defineHandler((event) => {\n  return { hello: \"API\" };\n});\n","routes/api/hello.ts",[418,649,650,667,671,694,708],{"__ignoreMap":5},[459,651,652,655,658,661,664],{"class":461,"line":462},[459,653,654],{"class":465},"import",[459,656,657],{"class":472}," { defineHandler } ",[459,659,660],{"class":465},"from",[459,662,663],{"class":550}," \"nitro\"",[459,665,666],{"class":472},";\n",[459,668,669],{"class":461,"line":476},[459,670,528],{"emptyLinePlaceholder":527},[459,672,673,675,677,680,683,686,689,692],{"class":461,"line":502},[459,674,466],{"class":465},[459,676,469],{"class":465},[459,678,679],{"class":482}," defineHandler",[459,681,682],{"class":472},"((",[459,684,685],{"class":489},"event",[459,687,688],{"class":472},") ",[459,690,691],{"class":465},"=>",[459,693,473],{"class":472},[459,695,696,699,702,705],{"class":461,"line":524},[459,697,698],{"class":465},"  return",[459,700,701],{"class":472}," { hello: ",[459,703,704],{"class":550},"\"API\"",[459,706,707],{"class":472}," };\n",[459,709,710],{"class":461,"line":531},[459,711,712],{"class":472},"});\n",[714,715,716],"tip",{},[409,717,718,719,721,722,725],{},"When ",[418,720,420],{}," is detected, Nitro will log in the terminal: ",[418,723,724],{},"Detected \\","server.ts` as server entry.`",[409,727,728],{},"With this setup:",[730,731,732,739,745],"ul",{},[733,734,735,738],"li",{},[418,736,737],{},"/health"," → Handled by server entry (returns a response)",[733,740,741,744],{},[418,742,743],{},"/api/hello"," → Handled by the API route handler directly",[733,746,747,750],{},[418,748,749],{},"/about",", etc. → Server entry runs first, then continues to the renderer if no response is returned",[413,752,754],{"id":753},"framework-compatibility","Framework compatibility",[409,756,757,758,761],{},"The server entry is a great way to integrate with other frameworks. Any framework that exposes a standard Web ",[418,759,760],{},"fetch(request: Request): Response"," interface can be used as a server entry.",[763,764,766],"h3",{"id":765},"web-compatible-frameworks","Web-compatible frameworks",[409,768,769,770,773,774,493],{},"Frameworks that implement the Web ",[418,771,772],{},"fetch"," API work directly with ",[418,775,420],{},[777,778,779,866,958],"tabs",{},[780,781,784],"tabs-item",{"label":782,"icon":783},"H3","i-undocs-h3",[451,785,787],{"className":453,"code":786,"filename":420,"language":455,"meta":5,"style":5},"import { H3 } from \"h3\";\n\nconst app = new H3()\n\napp.get(\"/\", () => \"⚡️ Hello from H3!\");\n\nexport default app;\n",[418,788,789,803,807,825,829,853,857],{"__ignoreMap":5},[459,790,791,793,796,798,801],{"class":461,"line":462},[459,792,654],{"class":465},[459,794,795],{"class":472}," { H3 } ",[459,797,660],{"class":465},[459,799,800],{"class":550}," \"h3\"",[459,802,666],{"class":472},[459,804,805],{"class":461,"line":476},[459,806,528],{"emptyLinePlaceholder":527},[459,808,809,812,815,817,819,822],{"class":461,"line":502},[459,810,811],{"class":465},"const",[459,813,814],{"class":508}," app",[459,816,512],{"class":465},[459,818,515],{"class":465},[459,820,821],{"class":482}," H3",[459,823,824],{"class":472},"()\n",[459,826,827],{"class":461,"line":524},[459,828,528],{"emptyLinePlaceholder":527},[459,830,831,834,837,839,842,845,847,850],{"class":461,"line":531},[459,832,833],{"class":472},"app.",[459,835,836],{"class":482},"get",[459,838,486],{"class":472},[459,840,841],{"class":550},"\"/\"",[459,843,844],{"class":472},", () ",[459,846,691],{"class":465},[459,848,849],{"class":550}," \"⚡️ Hello from H3!\"",[459,851,852],{"class":472},");\n",[459,854,855],{"class":461,"line":538},[459,856,528],{"emptyLinePlaceholder":527},[459,858,859,861,863],{"class":461,"line":556},[459,860,466],{"class":465},[459,862,469],{"class":465},[459,864,865],{"class":472}," app;\n",[780,867,869],{"label":284,"icon":868},"i-undocs-hono",[451,870,872],{"className":453,"code":871,"filename":420,"language":455,"meta":5,"style":5},"import { Hono } from \"hono\";\n\nconst app = new Hono();\n\napp.get(\"/\", (c) => c.text(\"🔥 Hello from Hono!\"));\n\nexport default app;\n",[418,873,874,888,892,908,912,946,950],{"__ignoreMap":5},[459,875,876,878,881,883,886],{"class":461,"line":462},[459,877,654],{"class":465},[459,879,880],{"class":472}," { Hono } ",[459,882,660],{"class":465},[459,884,885],{"class":550}," \"hono\"",[459,887,666],{"class":472},[459,889,890],{"class":461,"line":476},[459,891,528],{"emptyLinePlaceholder":527},[459,893,894,896,898,900,902,905],{"class":461,"line":502},[459,895,811],{"class":465},[459,897,814],{"class":508},[459,899,512],{"class":465},[459,901,515],{"class":465},[459,903,904],{"class":482}," Hono",[459,906,907],{"class":472},"();\n",[459,909,910],{"class":461,"line":524},[459,911,528],{"emptyLinePlaceholder":527},[459,913,914,916,918,920,922,925,928,930,932,935,938,940,943],{"class":461,"line":531},[459,915,833],{"class":472},[459,917,836],{"class":482},[459,919,486],{"class":472},[459,921,841],{"class":550},[459,923,924],{"class":472},", (",[459,926,927],{"class":489},"c",[459,929,688],{"class":472},[459,931,691],{"class":465},[459,933,934],{"class":472}," c.",[459,936,937],{"class":482},"text",[459,939,486],{"class":472},[459,941,942],{"class":550},"\"🔥 Hello from Hono!\"",[459,944,945],{"class":472},"));\n",[459,947,948],{"class":461,"line":538},[459,949,528],{"emptyLinePlaceholder":527},[459,951,952,954,956],{"class":461,"line":556},[459,953,466],{"class":465},[459,955,469],{"class":465},[459,957,865],{"class":472},[780,959,961],{"label":264,"icon":960},"i-undocs-elysia",[451,962,964],{"className":453,"code":963,"filename":420,"language":455,"meta":5,"style":5},"import { Elysia } from \"elysia\";\n\nconst app = new Elysia();\n\napp.get(\"/\", () => \"🦊 Hello from Elysia!\");\n\nexport default app.compile();\n",[418,965,966,980,984,999,1003,1022,1026],{"__ignoreMap":5},[459,967,968,970,973,975,978],{"class":461,"line":462},[459,969,654],{"class":465},[459,971,972],{"class":472}," { Elysia } ",[459,974,660],{"class":465},[459,976,977],{"class":550}," \"elysia\"",[459,979,666],{"class":472},[459,981,982],{"class":461,"line":476},[459,983,528],{"emptyLinePlaceholder":527},[459,985,986,988,990,992,994,997],{"class":461,"line":502},[459,987,811],{"class":465},[459,989,814],{"class":508},[459,991,512],{"class":465},[459,993,515],{"class":465},[459,995,996],{"class":482}," Elysia",[459,998,907],{"class":472},[459,1000,1001],{"class":461,"line":524},[459,1002,528],{"emptyLinePlaceholder":527},[459,1004,1005,1007,1009,1011,1013,1015,1017,1020],{"class":461,"line":531},[459,1006,833],{"class":472},[459,1008,836],{"class":482},[459,1010,486],{"class":472},[459,1012,841],{"class":550},[459,1014,844],{"class":472},[459,1016,691],{"class":465},[459,1018,1019],{"class":550}," \"🦊 Hello from Elysia!\"",[459,1021,852],{"class":472},[459,1023,1024],{"class":461,"line":538},[459,1025,528],{"emptyLinePlaceholder":527},[459,1027,1028,1030,1032,1035,1038],{"class":461,"line":556},[459,1029,466],{"class":465},[459,1031,469],{"class":465},[459,1033,1034],{"class":472}," app.",[459,1036,1037],{"class":482},"compile",[459,1039,907],{"class":472},[763,1041,1043],{"id":1042},"nodejs-frameworks","Node.js frameworks",[409,1045,1046,1047,1050,1051,1057,1058,1062,1063,1066,1067,1069,1070,1073,1074,1081],{},"For Node.js frameworks that use ",[418,1048,1049],{},"(req, res)"," style handlers (like ",[1052,1053,269],"a",{"href":1054,"rel":1055},"https://expressjs.com/",[1056],"nofollow"," or ",[1052,1059,274],{"href":1060,"rel":1061},"https://fastify.dev/",[1056],"), name your server entry file ",[418,1064,1065],{},"server.node.ts"," instead of ",[418,1068,420],{},". Nitro will automatically detect the ",[418,1071,1072],{},".node."," suffix and convert the Node.js handler to a web-compatible fetch handler using ",[1052,1075,1078],{"href":1076,"rel":1077},"https://srvx.h3.dev/",[1056],[418,1079,1080],{},"srvx",".",[777,1083,1084,1184],{},[780,1085,1086],{"label":269},[451,1087,1089],{"className":453,"code":1088,"filename":1065,"language":455,"meta":5,"style":5},"import Express from \"express\";\n\nconst app = Express();\n\napp.use(\"/\", (_req, res) => {\n  res.send(\"Hello from Express with Nitro!\");\n});\n\nexport default app;\n",[418,1090,1091,1105,1109,1122,1126,1153,1168,1172,1176],{"__ignoreMap":5},[459,1092,1093,1095,1098,1100,1103],{"class":461,"line":462},[459,1094,654],{"class":465},[459,1096,1097],{"class":472}," Express ",[459,1099,660],{"class":465},[459,1101,1102],{"class":550}," \"express\"",[459,1104,666],{"class":472},[459,1106,1107],{"class":461,"line":476},[459,1108,528],{"emptyLinePlaceholder":527},[459,1110,1111,1113,1115,1117,1120],{"class":461,"line":502},[459,1112,811],{"class":465},[459,1114,814],{"class":508},[459,1116,512],{"class":465},[459,1118,1119],{"class":482}," Express",[459,1121,907],{"class":472},[459,1123,1124],{"class":461,"line":524},[459,1125,528],{"emptyLinePlaceholder":527},[459,1127,1128,1130,1133,1135,1137,1139,1142,1144,1147,1149,1151],{"class":461,"line":531},[459,1129,833],{"class":472},[459,1131,1132],{"class":482},"use",[459,1134,486],{"class":472},[459,1136,841],{"class":550},[459,1138,924],{"class":472},[459,1140,1141],{"class":489},"_req",[459,1143,430],{"class":472},[459,1145,1146],{"class":489},"res",[459,1148,688],{"class":472},[459,1150,691],{"class":465},[459,1152,473],{"class":472},[459,1154,1155,1158,1161,1163,1166],{"class":461,"line":538},[459,1156,1157],{"class":472},"  res.",[459,1159,1160],{"class":482},"send",[459,1162,486],{"class":472},[459,1164,1165],{"class":550},"\"Hello from Express with Nitro!\"",[459,1167,852],{"class":472},[459,1169,1170],{"class":461,"line":556},[459,1171,712],{"class":472},[459,1173,1174],{"class":461,"line":575},[459,1175,528],{"emptyLinePlaceholder":527},[459,1177,1178,1180,1182],{"class":461,"line":587},[459,1179,466],{"class":465},[459,1181,469],{"class":465},[459,1183,865],{"class":472},[780,1185,1186],{"label":274},[451,1187,1189],{"className":453,"code":1188,"filename":1065,"language":455,"meta":5,"style":5},"import Fastify from \"fastify\";\n\nconst app = Fastify();\n\napp.get(\"/\", () => \"Hello, Fastify with Nitro!\");\n\nawait app.ready();\n\nexport default app.routing;\n",[418,1190,1191,1205,1209,1222,1226,1245,1249,1261,1265],{"__ignoreMap":5},[459,1192,1193,1195,1198,1200,1203],{"class":461,"line":462},[459,1194,654],{"class":465},[459,1196,1197],{"class":472}," Fastify ",[459,1199,660],{"class":465},[459,1201,1202],{"class":550}," \"fastify\"",[459,1204,666],{"class":472},[459,1206,1207],{"class":461,"line":476},[459,1208,528],{"emptyLinePlaceholder":527},[459,1210,1211,1213,1215,1217,1220],{"class":461,"line":502},[459,1212,811],{"class":465},[459,1214,814],{"class":508},[459,1216,512],{"class":465},[459,1218,1219],{"class":482}," Fastify",[459,1221,907],{"class":472},[459,1223,1224],{"class":461,"line":524},[459,1225,528],{"emptyLinePlaceholder":527},[459,1227,1228,1230,1232,1234,1236,1238,1240,1243],{"class":461,"line":531},[459,1229,833],{"class":472},[459,1231,836],{"class":482},[459,1233,486],{"class":472},[459,1235,841],{"class":550},[459,1237,844],{"class":472},[459,1239,691],{"class":465},[459,1241,1242],{"class":550}," \"Hello, Fastify with Nitro!\"",[459,1244,852],{"class":472},[459,1246,1247],{"class":461,"line":538},[459,1248,528],{"emptyLinePlaceholder":527},[459,1250,1251,1254,1256,1259],{"class":461,"line":556},[459,1252,1253],{"class":465},"await",[459,1255,1034],{"class":472},[459,1257,1258],{"class":482},"ready",[459,1260,907],{"class":472},[459,1262,1263],{"class":461,"line":575},[459,1264,528],{"emptyLinePlaceholder":527},[459,1266,1267,1269,1271],{"class":461,"line":587},[459,1268,466],{"class":465},[459,1270,469],{"class":465},[459,1272,1273],{"class":472}," app.routing;\n",[413,1275,33],{"id":1276},"configuration",[763,1278,1280],{"id":1279},"custom-server-entry-file","Custom server entry file",[409,1282,1283,1284,1287],{},"You can specify a custom server entry file using the ",[418,1285,1286],{},"serverEntry"," option in your Nitro configuration:",[451,1289,1292],{"className":453,"code":1290,"filename":1291,"language":455,"meta":5,"style":5},"import { defineConfig } from \"nitro\";\n\nexport default defineConfig({\n  serverEntry: \"./nitro.server.ts\"\n})\n","nitro.config.ts",[418,1293,1294,1307,1311,1323,1331],{"__ignoreMap":5},[459,1295,1296,1298,1301,1303,1305],{"class":461,"line":462},[459,1297,654],{"class":465},[459,1299,1300],{"class":472}," { defineConfig } ",[459,1302,660],{"class":465},[459,1304,663],{"class":550},[459,1306,666],{"class":472},[459,1308,1309],{"class":461,"line":476},[459,1310,528],{"emptyLinePlaceholder":527},[459,1312,1313,1315,1317,1320],{"class":461,"line":502},[459,1314,466],{"class":465},[459,1316,469],{"class":465},[459,1318,1319],{"class":482}," defineConfig",[459,1321,1322],{"class":472},"({\n",[459,1324,1325,1328],{"class":461,"line":524},[459,1326,1327],{"class":472},"  serverEntry: ",[459,1329,1330],{"class":550},"\"./nitro.server.ts\"\n",[459,1332,1333],{"class":461,"line":531},[459,1334,1335],{"class":472},"})\n",[409,1337,1338,1339,1342,1343,1346],{},"You can also provide an object with ",[418,1340,1341],{},"handler"," and ",[418,1344,1345],{},"format"," options:",[451,1348,1350],{"className":453,"code":1349,"filename":1291,"language":455,"meta":5,"style":5},"import { defineConfig } from \"nitro\";\n\nexport default defineConfig({\n  serverEntry: {\n    handler: \"./server.ts\",\n    format: \"node\" // \"web\" (default) or \"node\"\n  }\n})\n",[418,1351,1352,1364,1368,1378,1383,1393,1404,1408],{"__ignoreMap":5},[459,1353,1354,1356,1358,1360,1362],{"class":461,"line":462},[459,1355,654],{"class":465},[459,1357,1300],{"class":472},[459,1359,660],{"class":465},[459,1361,663],{"class":550},[459,1363,666],{"class":472},[459,1365,1366],{"class":461,"line":476},[459,1367,528],{"emptyLinePlaceholder":527},[459,1369,1370,1372,1374,1376],{"class":461,"line":502},[459,1371,466],{"class":465},[459,1373,469],{"class":465},[459,1375,1319],{"class":482},[459,1377,1322],{"class":472},[459,1379,1380],{"class":461,"line":524},[459,1381,1382],{"class":472},"  serverEntry: {\n",[459,1384,1385,1388,1391],{"class":461,"line":531},[459,1386,1387],{"class":472},"    handler: ",[459,1389,1390],{"class":550},"\"./server.ts\"",[459,1392,584],{"class":472},[459,1394,1395,1398,1401],{"class":461,"line":538},[459,1396,1397],{"class":472},"    format: ",[459,1399,1400],{"class":550},"\"node\"",[459,1402,1403],{"class":534}," // \"web\" (default) or \"node\"\n",[459,1405,1406],{"class":461,"line":556},[459,1407,637],{"class":472},[459,1409,1410],{"class":461,"line":575},[459,1411,1335],{"class":472},[763,1413,1415],{"id":1414},"handler-format","Handler format",[409,1417,1418,1419,1421],{},"The ",[418,1420,1345],{}," option controls how Nitro treats the default export of your server entry:",[730,1423,1424,1436],{},[733,1425,1426,1432,1433,1435],{},[1427,1428,1429],"strong",{},[418,1430,1431],{},"\"web\""," (default) — Expects a Web-compatible handler with a ",[418,1434,760],{}," method.",[733,1437,1438,1442,1443,1445],{},[1427,1439,1440],{},[418,1441,1400],{}," — Expects a Node.js-style ",[418,1444,1049],{}," handler. Nitro automatically converts it to a web-compatible handler.",[409,1447,1448,1449,1451,1452,1454,1455,1451,1457,1459],{},"When auto-detecting, the format is determined by the filename: ",[418,1450,1065],{}," uses ",[418,1453,1400],{}," format, while ",[418,1456,420],{},[418,1458,1431],{}," format.",[763,1461,1463],{"id":1462},"disabling-server-entry","Disabling server entry",[409,1465,1466,1467,1469,1470,1473],{},"Set ",[418,1468,1286],{}," to ",[418,1471,1472],{},"false"," to disable auto-detection and prevent Nitro from using any server entry:",[451,1475,1477],{"className":453,"code":1476,"filename":1291,"language":455,"meta":5,"style":5},"import { defineConfig } from \"nitro\";\n\nexport default defineConfig({\n  serverEntry: false\n})\n",[418,1478,1479,1491,1495,1505,1512],{"__ignoreMap":5},[459,1480,1481,1483,1485,1487,1489],{"class":461,"line":462},[459,1482,654],{"class":465},[459,1484,1300],{"class":472},[459,1486,660],{"class":465},[459,1488,663],{"class":550},[459,1490,666],{"class":472},[459,1492,1493],{"class":461,"line":476},[459,1494,528],{"emptyLinePlaceholder":527},[459,1496,1497,1499,1501,1503],{"class":461,"line":502},[459,1498,466],{"class":465},[459,1500,469],{"class":465},[459,1502,1319],{"class":482},[459,1504,1322],{"class":472},[459,1506,1507,1509],{"class":461,"line":524},[459,1508,1327],{"class":472},[459,1510,1511],{"class":508},"false\n",[459,1513,1514],{"class":461,"line":531},[459,1515,1335],{"class":472},[413,1517,1519],{"id":1518},"using-event-handler","Using event handler",[409,1521,1522,1523,1526],{},"You can also export an event handler using ",[418,1524,1525],{},"defineHandler"," for better type inference and access to the h3 event object:",[451,1528,1530],{"className":453,"code":1529,"filename":420,"language":455,"meta":5,"style":5},"import { defineHandler } from \"nitro\";\n\nexport default defineHandler((event) => {\n  // Add custom context\n  event.context.requestId = crypto.randomUUID();\n  event.context.timestamp = Date.now();\n\n  // Log the request\n  console.log(`[${event.context.requestId}] ${event.method} ${event.path}`);\n\n  // Continue to the next handler (don't return anything)\n});\n",[418,1531,1532,1544,1548,1566,1571,1587,1602,1606,1611,1661,1665,1670],{"__ignoreMap":5},[459,1533,1534,1536,1538,1540,1542],{"class":461,"line":462},[459,1535,654],{"class":465},[459,1537,657],{"class":472},[459,1539,660],{"class":465},[459,1541,663],{"class":550},[459,1543,666],{"class":472},[459,1545,1546],{"class":461,"line":476},[459,1547,528],{"emptyLinePlaceholder":527},[459,1549,1550,1552,1554,1556,1558,1560,1562,1564],{"class":461,"line":502},[459,1551,466],{"class":465},[459,1553,469],{"class":465},[459,1555,679],{"class":482},[459,1557,682],{"class":472},[459,1559,685],{"class":489},[459,1561,688],{"class":472},[459,1563,691],{"class":465},[459,1565,473],{"class":472},[459,1567,1568],{"class":461,"line":524},[459,1569,1570],{"class":534},"  // Add custom context\n",[459,1572,1573,1576,1579,1582,1585],{"class":461,"line":531},[459,1574,1575],{"class":472},"  event.context.requestId ",[459,1577,1578],{"class":465},"=",[459,1580,1581],{"class":472}," crypto.",[459,1583,1584],{"class":482},"randomUUID",[459,1586,907],{"class":472},[459,1588,1589,1592,1594,1597,1600],{"class":461,"line":538},[459,1590,1591],{"class":472},"  event.context.timestamp ",[459,1593,1578],{"class":465},[459,1595,1596],{"class":472}," Date.",[459,1598,1599],{"class":482},"now",[459,1601,907],{"class":472},[459,1603,1604],{"class":461,"line":556},[459,1605,528],{"emptyLinePlaceholder":527},[459,1607,1608],{"class":461,"line":575},[459,1609,1610],{"class":534},"  // Log the request\n",[459,1612,1613,1616,1619,1621,1624,1626,1628,1631,1633,1636,1639,1641,1643,1646,1649,1651,1653,1656,1659],{"class":461,"line":587},[459,1614,1615],{"class":472},"  console.",[459,1617,1618],{"class":482},"log",[459,1620,486],{"class":472},[459,1622,1623],{"class":550},"`[${",[459,1625,685],{"class":472},[459,1627,1081],{"class":550},[459,1629,1630],{"class":472},"context",[459,1632,1081],{"class":550},[459,1634,1635],{"class":472},"requestId",[459,1637,1638],{"class":550},"}] ${",[459,1640,685],{"class":472},[459,1642,1081],{"class":550},[459,1644,1645],{"class":472},"method",[459,1647,1648],{"class":550},"} ${",[459,1650,685],{"class":472},[459,1652,1081],{"class":550},[459,1654,1655],{"class":472},"path",[459,1657,1658],{"class":550},"}`",[459,1660,852],{"class":472},[459,1662,1663],{"class":461,"line":605},[459,1664,528],{"emptyLinePlaceholder":527},[459,1666,1667],{"class":461,"line":611},[459,1668,1669],{"class":534},"  // Continue to the next handler (don't return anything)\n",[459,1671,1672],{"class":461,"line":617},[459,1673,712],{"class":472},[1675,1676,1677],"important",{},[409,1678,1679,1680,1683],{},"If your server entry returns ",[418,1681,1682],{},"undefined"," or doesn't return anything, the request will continue to be processed by routes and the renderer. If it returns a response, the request lifecycle stops there.",[413,1685,1687],{"id":1686},"request-lifecycle","Request lifecycle",[409,1689,1690,1691,1694,1695,1697],{},"The server entry is registered as a catch-all (",[418,1692,1693],{},"/**",") route handler. When a specific route (like ",[418,1696,743],{},") matches a request, that route handler takes priority. For requests that don't match any specific route, the server entry runs before the renderer:",[451,1699,1703],{"className":1700,"code":1701,"language":1702,"meta":5,"style":5},"language-md shiki shiki-themes github-light github-dark github-dark","1. Server hook: `request`\n2. Route rules (headers, redirects, etc.)\n3. Global middleware (middleware/)\n4. Route matching:\n   a. Specific routes (routes/) ← if matched, handles the request\n   b. Server entry ← runs for unmatched routes\n   c. Renderer (renderer.ts or index.html)\n","md",[418,1704,1705,1716,1724,1732,1740,1745,1750],{"__ignoreMap":5},[459,1706,1707,1710,1713],{"class":461,"line":462},[459,1708,1709],{"class":489},"1.",[459,1711,1712],{"class":472}," Server hook: ",[459,1714,1715],{"class":508},"`request`\n",[459,1717,1718,1721],{"class":461,"line":476},[459,1719,1720],{"class":489},"2.",[459,1722,1723],{"class":472}," Route rules (headers, redirects, etc.)\n",[459,1725,1726,1729],{"class":461,"line":502},[459,1727,1728],{"class":489},"3.",[459,1730,1731],{"class":472}," Global middleware (middleware/)\n",[459,1733,1734,1737],{"class":461,"line":524},[459,1735,1736],{"class":489},"4.",[459,1738,1739],{"class":472}," Route matching:\n",[459,1741,1742],{"class":461,"line":531},[459,1743,1744],{"class":472},"   a. Specific routes (routes/) ← if matched, handles the request\n",[459,1746,1747],{"class":461,"line":538},[459,1748,1749],{"class":472},"   b. Server entry ← runs for unmatched routes\n",[459,1751,1752],{"class":461,"line":556},[459,1753,1754],{"class":472},"   c. Renderer (renderer.ts or index.html)\n",[409,1756,1757],{},"When both a server entry and a renderer exist, they are chained: the server entry runs first, and if it doesn't return a response, the renderer handles the request.",[413,1759,1761],{"id":1760},"development-mode","Development mode",[409,1763,1764],{},"During development, Nitro watches for changes to your server entry file. When the file is created, modified, or deleted, the dev server automatically reloads to pick up the changes.",[413,1766,1768],{"id":1767},"best-practices","Best practices",[730,1770,1771,1777,1783,1786,1789,1796,1799],{},[733,1772,1773,1774],{},"Use server entry for cross-cutting concerns that affect ",[1427,1775,1776],{},"all routes",[733,1778,1779,1780,1782],{},"Return ",[418,1781,1682],{}," to continue processing, return a response to terminate",[733,1784,1785],{},"Keep server entry logic lightweight for better performance",[733,1787,1788],{},"Use global middleware for modular concerns instead of one large server entry",[733,1790,1791,1792,1795],{},"Consider using ",[1052,1793,1794],{"href":54},"Nitro plugins"," for initialization logic",[733,1797,1798],{},"Avoid heavy computation in server entry (it runs for every request)",[733,1800,1801],{},"Don't use server entry for route-specific logic (use route handlers instead as they are more performant)",[1803,1804,1805],"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 .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 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}html pre.shiki code .sfrk1, html code.shiki .sfrk1{--shiki-light:#032F62;--shiki-default:#9ECBFF;--shiki-dark:#9ECBFF}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);}",{"title":5,"searchDepth":476,"depth":476,"links":1807},[1808,1810,1814,1819,1820,1821,1822],{"id":415,"depth":476,"text":1809},"Auto-detected server.ts",{"id":753,"depth":476,"text":754,"children":1811},[1812,1813],{"id":765,"depth":502,"text":766},{"id":1042,"depth":502,"text":1043},{"id":1276,"depth":476,"text":33,"children":1815},[1816,1817,1818],{"id":1279,"depth":502,"text":1280},{"id":1414,"depth":502,"text":1415},{"id":1462,"depth":502,"text":1463},{"id":1518,"depth":476,"text":1519},{"id":1686,"depth":476,"text":1687},{"id":1760,"depth":476,"text":1761},{"id":1767,"depth":476,"text":1768},"Use a server entry to create a global middleware that runs for all routes before they are matched.",{"icon":71},{"title":68,"icon":71},{"title":404,"description":1823},"2vT-x67m5i87V63-fSajv7cQHGKTu7waSNduJPTpMVQ",[1829,1831],{"title":63,"path":64,"stem":65,"description":1830,"icon":66,"children":-1},"Nitro provides cross-platform WebSocket support powered by CrossWS and H3.",{"title":73,"path":74,"stem":75,"description":1832,"icon":76,"children":-1},"Nitro provides a caching system built on top of the storage layer, powered by ocache.",1776373821982]