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