[{"data":1,"prerenderedAt":1221},["ShallowReactive",2],{"navigation":3,"-docs-server-entry":217,"-docs-server-entry-surround":1216},[4,83,208,214],{"title":5,"path":6,"stem":7,"children":8,"icon":82},"","/docs","1.docs/1.index",[9,12,17,22,27,32,37,42,47,52,57,62,67,72,77],{"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},"Plugins","/docs/plugins","1.docs/50.plugins","ri:plug-line",{"title":53,"path":54,"stem":55,"icon":56},"Tasks","/docs/tasks","1.docs/50.tasks","codicon:run-all",{"title":58,"path":59,"stem":60,"icon":61},"Server Entry","/docs/server-entry","1.docs/6.server-entry","ri:server-line",{"title":63,"path":64,"stem":65,"icon":66},"Cache","/docs/cache","1.docs/7.cache","ri:speed-line",{"title":68,"path":69,"stem":70,"icon":71},"KV Storage","/docs/storage","1.docs/8.storage","carbon:datastore",{"title":73,"path":74,"stem":75,"icon":76},"Migration Guide","/docs/migration","1.docs/99.migration","ri:arrow-right-up-line",{"title":78,"path":79,"stem":80,"icon":81},"Nightly Channel","/docs/nightly","1.docs/99.nightly","ri:moon-fill","i-lucide-book-open",{"title":84,"path":85,"stem":86,"children":87,"icon":89},"Deploy","/deploy","2.deploy/0.index",[88,90,111],{"title":84,"path":85,"stem":86,"icon":89},"ri:upload-cloud-2-line",{"title":91,"path":92,"stem":93,"children":94,"page":110},"Runtimes","/deploy/runtimes","2.deploy/10.runtimes",[95,100,105],{"title":96,"path":97,"stem":98,"icon":99},"Node.js","/deploy/runtimes/node","2.deploy/10.runtimes/1.node","akar-icons:node-fill",{"title":101,"path":102,"stem":103,"icon":104},"Bun","/deploy/runtimes/bun","2.deploy/10.runtimes/bun","simple-icons:bun",{"title":106,"path":107,"stem":108,"icon":109},"Deno","/deploy/runtimes/deno","2.deploy/10.runtimes/deno","simple-icons:deno",false,{"title":112,"path":113,"stem":114,"children":115,"page":110},"Providers","/deploy/providers","2.deploy/20.providers",[116,120,124,128,132,136,140,144,148,152,156,160,164,168,172,176,180,184,188,192,196,200,204],{"title":117,"path":118,"stem":119},"Alwaysdata","/deploy/providers/alwaysdata","2.deploy/20.providers/alwaysdata",{"title":121,"path":122,"stem":123},"AWS Lambda","/deploy/providers/aws","2.deploy/20.providers/aws",{"title":125,"path":126,"stem":127},"AWS Amplify","/deploy/providers/aws-amplify","2.deploy/20.providers/aws-amplify",{"title":129,"path":130,"stem":131},"Azure","/deploy/providers/azure","2.deploy/20.providers/azure",{"title":133,"path":134,"stem":135},"Cleavr","/deploy/providers/cleavr","2.deploy/20.providers/cleavr",{"title":137,"path":138,"stem":139},"Cloudflare","/deploy/providers/cloudflare","2.deploy/20.providers/cloudflare",{"title":141,"path":142,"stem":143},"Deno Deploy","/deploy/providers/deno-deploy","2.deploy/20.providers/deno-deploy",{"title":145,"path":146,"stem":147},"DigitalOcean","/deploy/providers/digitalocean","2.deploy/20.providers/digitalocean",{"title":149,"path":150,"stem":151},"Firebase","/deploy/providers/firebase","2.deploy/20.providers/firebase",{"title":153,"path":154,"stem":155},"Flightcontrol","/deploy/providers/flightcontrol","2.deploy/20.providers/flightcontrol",{"title":157,"path":158,"stem":159},"Genezio","/deploy/providers/genezio","2.deploy/20.providers/genezio",{"title":161,"path":162,"stem":163},"GitHub Pages","/deploy/providers/github-pages","2.deploy/20.providers/github-pages",{"title":165,"path":166,"stem":167},"GitLab Pages","/deploy/providers/gitlab-pages","2.deploy/20.providers/gitlab-pages",{"title":169,"path":170,"stem":171},"Heroku","/deploy/providers/heroku","2.deploy/20.providers/heroku",{"title":173,"path":174,"stem":175},"IIS","/deploy/providers/iis","2.deploy/20.providers/iis",{"title":177,"path":178,"stem":179},"Koyeb","/deploy/providers/koyeb","2.deploy/20.providers/koyeb",{"title":181,"path":182,"stem":183},"Netlify","/deploy/providers/netlify","2.deploy/20.providers/netlify",{"title":185,"path":186,"stem":187},"Platform.sh","/deploy/providers/platform-sh","2.deploy/20.providers/platform-sh",{"title":189,"path":190,"stem":191},"Render.com","/deploy/providers/render","2.deploy/20.providers/render",{"title":193,"path":194,"stem":195},"StormKit","/deploy/providers/stormkit","2.deploy/20.providers/stormkit",{"title":197,"path":198,"stem":199},"Vercel","/deploy/providers/vercel","2.deploy/20.providers/vercel",{"title":201,"path":202,"stem":203},"Zeabur","/deploy/providers/zeabur","2.deploy/20.providers/zeabur",{"title":205,"path":206,"stem":207},"Zerops","/deploy/providers/zerops","2.deploy/20.providers/zerops",{"title":209,"path":210,"stem":211,"children":212,"icon":36},"Config","/config","3.config/0.index",[213],{"title":209,"path":210,"stem":211,"icon":36},{"title":5,"path":215,"stem":216},"/","index",{"id":218,"title":219,"body":220,"description":1211,"extension":1095,"meta":1212,"navigation":1213,"path":59,"seo":1214,"stem":60,"__hash__":1215},"content/1.docs/6.server-entry.md","Nitro Server Entry",{"type":221,"value":222,"toc":1202,"icon":61},"minimark",[223,230,239,248,265,268,534,547,550,572,576,597,858,862,869,916,920,927,1074,1084,1088,1091,1149,1157,1161,1165,1198],[224,225,226],"warning",{},[227,228,229],"p",{},"Nitro v3 Alpha docs are a work in progress — expect updates, rough edges, and occasional inaccuracies.",[227,231,232,233,238],{},"The server entry is a special handler in Nitro that acts as a global middleware, running for every incoming request before routes are matched (see ",[234,235,237],"a",{"href":236},"/docs/architecture#request-lifecycle","request lifecycle","). It's commonly used for cross-cutting concerns like authentication, logging, request preprocessing, or creating custom routing logic.",[240,241,243,244],"h2",{"id":242},"auto-detected-serverts","Auto-detected ",[245,246,247],"code",{},"server.ts",[227,249,250,251,253,254,257,258,257,261,264],{},"By default, Nitro automatically looks for a ",[245,252,247],{}," (or ",[245,255,256],{},".js",", ",[245,259,260],{},".mjs",[245,262,263],{},".tsx",", etc.) file in your project root or scan directories.",[227,266,267],{},"If found, Nitro will use it as the server entry and run it for all incoming requests.",[269,270,271,465],"code-group",{},[272,273,277],"pre",{"className":274,"code":275,"filename":247,"language":276,"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",[245,278,279,295,321,343,350,357,375,394,406,424,430,436,441,447,453,459],{"__ignoreMap":5},[280,281,284,288,291],"span",{"class":282,"line":283},"line",1,[280,285,287],{"class":286},"so5gQ","export",[280,289,290],{"class":286}," default",[280,292,294],{"class":293},"slsVL"," {\n",[280,296,298,301,305,308,312,315,318],{"class":282,"line":297},2,[280,299,300],{"class":286},"  async",[280,302,304],{"class":303},"shcOC"," fetch",[280,306,307],{"class":293},"(",[280,309,311],{"class":310},"sQHwn","req",[280,313,314],{"class":286},":",[280,316,317],{"class":303}," Request",[280,319,320],{"class":293},") {\n",[280,322,324,327,331,334,337,340],{"class":282,"line":323},3,[280,325,326],{"class":286},"    const",[280,328,330],{"class":329},"suiK_"," url",[280,332,333],{"class":286}," =",[280,335,336],{"class":286}," new",[280,338,339],{"class":303}," URL",[280,341,342],{"class":293},"(req.url);\n",[280,344,346],{"class":282,"line":345},4,[280,347,349],{"emptyLinePlaceholder":348},true,"\n",[280,351,353],{"class":282,"line":352},5,[280,354,356],{"class":355},"sCsY4","    // Handle specific routes\n",[280,358,360,363,366,369,373],{"class":282,"line":359},6,[280,361,362],{"class":286},"    if",[280,364,365],{"class":293}," (url.pathname ",[280,367,368],{"class":286},"===",[280,370,372],{"class":371},"sfrk1"," \"/health\"",[280,374,320],{"class":293},[280,376,378,381,383,386,388,391],{"class":282,"line":377},7,[280,379,380],{"class":286},"      return",[280,382,336],{"class":286},[280,384,385],{"class":303}," Response",[280,387,307],{"class":293},[280,389,390],{"class":371},"\"OK\"",[280,392,393],{"class":293},", {\n",[280,395,397,400,403],{"class":282,"line":396},8,[280,398,399],{"class":293},"        status: ",[280,401,402],{"class":329},"200",[280,404,405],{"class":293},",\n",[280,407,409,412,415,418,421],{"class":282,"line":408},9,[280,410,411],{"class":293},"        headers: { ",[280,413,414],{"class":371},"\"content-type\"",[280,416,417],{"class":293},": ",[280,419,420],{"class":371},"\"text/plain\"",[280,422,423],{"class":293}," }\n",[280,425,427],{"class":282,"line":426},10,[280,428,429],{"class":293},"      });\n",[280,431,433],{"class":282,"line":432},11,[280,434,435],{"class":293},"    }\n",[280,437,439],{"class":282,"line":438},12,[280,440,349],{"emptyLinePlaceholder":348},[280,442,444],{"class":282,"line":443},13,[280,445,446],{"class":355},"    // Add custom headers to all requests\n",[280,448,450],{"class":282,"line":449},14,[280,451,452],{"class":355},"    // Return nothing to continue to the next handler\n",[280,454,456],{"class":282,"line":455},15,[280,457,458],{"class":293},"  }\n",[280,460,462],{"class":282,"line":461},16,[280,463,464],{"class":293},"}\n",[272,466,469],{"className":274,"code":467,"filename":468,"language":276,"meta":5,"style":5},"import { defineHandler } from \"nitro/h3\";\n\nexport default defineHandler((event) => {\n  return { hello: \"API\" };\n});\n","routes/api/hello.ts",[245,470,471,488,492,515,529],{"__ignoreMap":5},[280,472,473,476,479,482,485],{"class":282,"line":283},[280,474,475],{"class":286},"import",[280,477,478],{"class":293}," { defineHandler } ",[280,480,481],{"class":286},"from",[280,483,484],{"class":371}," \"nitro/h3\"",[280,486,487],{"class":293},";\n",[280,489,490],{"class":282,"line":297},[280,491,349],{"emptyLinePlaceholder":348},[280,493,494,496,498,501,504,507,510,513],{"class":282,"line":323},[280,495,287],{"class":286},[280,497,290],{"class":286},[280,499,500],{"class":303}," defineHandler",[280,502,503],{"class":293},"((",[280,505,506],{"class":310},"event",[280,508,509],{"class":293},") ",[280,511,512],{"class":286},"=>",[280,514,294],{"class":293},[280,516,517,520,523,526],{"class":282,"line":345},[280,518,519],{"class":286},"  return",[280,521,522],{"class":293}," { hello: ",[280,524,525],{"class":371},"\"API\"",[280,527,528],{"class":293}," };\n",[280,530,531],{"class":282,"line":352},[280,532,533],{"class":293},"});\n",[535,536,537],"tip",{},[227,538,539,540,542,543,546],{},"When ",[245,541,247],{}," is detected, Nitro will automatically log in the terminal: ",[245,544,545],{},"Using \\","server.ts` as server entry.`",[227,548,549],{},"With this setup:",[551,552,553,560,566],"ul",{},[554,555,556,559],"li",{},[245,557,558],{},"/health"," → Handled by server entry",[554,561,562,565],{},[245,563,564],{},"/api/hello"," → Server entry runs first, then the API route",[554,567,568,571],{},[245,569,570],{},"/about",", etc. → Server entry runs first, then continues to routes or renderer",[240,573,575],{"id":574},"framework-compatibility","Framework compatibility",[227,577,578,579,257,585,590,591,596],{},"The server entry is a great way to integrate with other frameworks such as ",[234,580,584],{"href":581,"rel":582},"https://elysiajs.com/",[583],"nofollow","Elysia",[234,586,589],{"href":587,"rel":588},"https://hono.dev/",[583],"Hono"," or ",[234,592,595],{"href":593,"rel":594},"https://h3.dev/",[583],"H3",".",[598,599,600,686,778],"tabs",{},[601,602,604],"tabs-item",{"icon":603,"label":595},"i-undocs-h3",[272,605,607],{"className":274,"code":606,"filename":247,"language":276,"meta":5,"style":5},"import { H3 } from \"h3\";\n\nconst app = new H3()\n\napp.get(\"/\", () => \"⚡️ Hello from H3!\");\n\nexport default app;\n",[245,608,609,623,627,645,649,673,677],{"__ignoreMap":5},[280,610,611,613,616,618,621],{"class":282,"line":283},[280,612,475],{"class":286},[280,614,615],{"class":293}," { H3 } ",[280,617,481],{"class":286},[280,619,620],{"class":371}," \"h3\"",[280,622,487],{"class":293},[280,624,625],{"class":282,"line":297},[280,626,349],{"emptyLinePlaceholder":348},[280,628,629,632,635,637,639,642],{"class":282,"line":323},[280,630,631],{"class":286},"const",[280,633,634],{"class":329}," app",[280,636,333],{"class":286},[280,638,336],{"class":286},[280,640,641],{"class":303}," H3",[280,643,644],{"class":293},"()\n",[280,646,647],{"class":282,"line":345},[280,648,349],{"emptyLinePlaceholder":348},[280,650,651,654,657,659,662,665,667,670],{"class":282,"line":352},[280,652,653],{"class":293},"app.",[280,655,656],{"class":303},"get",[280,658,307],{"class":293},[280,660,661],{"class":371},"\"/\"",[280,663,664],{"class":293},", () ",[280,666,512],{"class":286},[280,668,669],{"class":371}," \"⚡️ Hello from H3!\"",[280,671,672],{"class":293},");\n",[280,674,675],{"class":282,"line":359},[280,676,349],{"emptyLinePlaceholder":348},[280,678,679,681,683],{"class":282,"line":377},[280,680,287],{"class":286},[280,682,290],{"class":286},[280,684,685],{"class":293}," app;\n",[601,687,689],{"icon":688,"label":589},"i-undocs-hono",[272,690,692],{"className":274,"code":691,"filename":247,"language":276,"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",[245,693,694,708,712,728,732,766,770],{"__ignoreMap":5},[280,695,696,698,701,703,706],{"class":282,"line":283},[280,697,475],{"class":286},[280,699,700],{"class":293}," { Hono } ",[280,702,481],{"class":286},[280,704,705],{"class":371}," \"hono\"",[280,707,487],{"class":293},[280,709,710],{"class":282,"line":297},[280,711,349],{"emptyLinePlaceholder":348},[280,713,714,716,718,720,722,725],{"class":282,"line":323},[280,715,631],{"class":286},[280,717,634],{"class":329},[280,719,333],{"class":286},[280,721,336],{"class":286},[280,723,724],{"class":303}," Hono",[280,726,727],{"class":293},"();\n",[280,729,730],{"class":282,"line":345},[280,731,349],{"emptyLinePlaceholder":348},[280,733,734,736,738,740,742,745,748,750,752,755,758,760,763],{"class":282,"line":352},[280,735,653],{"class":293},[280,737,656],{"class":303},[280,739,307],{"class":293},[280,741,661],{"class":371},[280,743,744],{"class":293},", (",[280,746,747],{"class":310},"c",[280,749,509],{"class":293},[280,751,512],{"class":286},[280,753,754],{"class":293}," c.",[280,756,757],{"class":303},"text",[280,759,307],{"class":293},[280,761,762],{"class":371},"\"🔥 Hello from Hono!\"",[280,764,765],{"class":293},"));\n",[280,767,768],{"class":282,"line":359},[280,769,349],{"emptyLinePlaceholder":348},[280,771,772,774,776],{"class":282,"line":377},[280,773,287],{"class":286},[280,775,290],{"class":286},[280,777,685],{"class":293},[601,779,781],{"icon":780,"label":584},"i-undocs-elysia",[272,782,784],{"className":274,"code":783,"filename":247,"language":276,"meta":5,"style":5},"import { Elysia } from \"elysia\";\n\nconst app = new Elysia();\n\napp.get(\"/\", (c) => \"🦊 Hello from Elysia!\");\n\nexport default app;\n",[245,785,786,800,804,819,823,846,850],{"__ignoreMap":5},[280,787,788,790,793,795,798],{"class":282,"line":283},[280,789,475],{"class":286},[280,791,792],{"class":293}," { Elysia } ",[280,794,481],{"class":286},[280,796,797],{"class":371}," \"elysia\"",[280,799,487],{"class":293},[280,801,802],{"class":282,"line":297},[280,803,349],{"emptyLinePlaceholder":348},[280,805,806,808,810,812,814,817],{"class":282,"line":323},[280,807,631],{"class":286},[280,809,634],{"class":329},[280,811,333],{"class":286},[280,813,336],{"class":286},[280,815,816],{"class":303}," Elysia",[280,818,727],{"class":293},[280,820,821],{"class":282,"line":345},[280,822,349],{"emptyLinePlaceholder":348},[280,824,825,827,829,831,833,835,837,839,841,844],{"class":282,"line":352},[280,826,653],{"class":293},[280,828,656],{"class":303},[280,830,307],{"class":293},[280,832,661],{"class":371},[280,834,744],{"class":293},[280,836,747],{"class":310},[280,838,509],{"class":293},[280,840,512],{"class":286},[280,842,843],{"class":371}," \"🦊 Hello from Elysia!\"",[280,845,672],{"class":293},[280,847,848],{"class":282,"line":359},[280,849,349],{"emptyLinePlaceholder":348},[280,851,852,854,856],{"class":282,"line":377},[280,853,287],{"class":286},[280,855,290],{"class":286},[280,857,685],{"class":293},[240,859,861],{"id":860},"custom-server-entry-file","Custom server entry file",[227,863,864,865,868],{},"You can specify a custom server entry file using the ",[245,866,867],{},"serverEntry"," option in your Nitro configuration.",[272,870,873],{"className":274,"code":871,"filename":872,"language":276,"meta":5,"style":5},"import { defineNitroConfig } from 'nitro/config'\n\nexport default defineNitroConfig({\n  serverEntry: './nitro.server.ts'\n})\n","nitro.config.ts",[245,874,875,887,891,903,911],{"__ignoreMap":5},[280,876,877,879,882,884],{"class":282,"line":283},[280,878,475],{"class":286},[280,880,881],{"class":293}," { defineNitroConfig } ",[280,883,481],{"class":286},[280,885,886],{"class":371}," 'nitro/config'\n",[280,888,889],{"class":282,"line":297},[280,890,349],{"emptyLinePlaceholder":348},[280,892,893,895,897,900],{"class":282,"line":323},[280,894,287],{"class":286},[280,896,290],{"class":286},[280,898,899],{"class":303}," defineNitroConfig",[280,901,902],{"class":293},"({\n",[280,904,905,908],{"class":282,"line":345},[280,906,907],{"class":293},"  serverEntry: ",[280,909,910],{"class":371},"'./nitro.server.ts'\n",[280,912,913],{"class":282,"line":352},[280,914,915],{"class":293},"})\n",[240,917,919],{"id":918},"using-event-handler","Using event handler",[227,921,922,923,926],{},"You can also export an event handler using ",[245,924,925],{},"defineHandler"," for better type inference and access to the h3 event object:",[272,928,930],{"className":274,"code":929,"filename":247,"language":276,"meta":5,"style":5},"import { defineHandler } from \"nitro/h3\";\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",[245,931,932,944,948,966,971,987,1002,1006,1011,1061,1065,1070],{"__ignoreMap":5},[280,933,934,936,938,940,942],{"class":282,"line":283},[280,935,475],{"class":286},[280,937,478],{"class":293},[280,939,481],{"class":286},[280,941,484],{"class":371},[280,943,487],{"class":293},[280,945,946],{"class":282,"line":297},[280,947,349],{"emptyLinePlaceholder":348},[280,949,950,952,954,956,958,960,962,964],{"class":282,"line":323},[280,951,287],{"class":286},[280,953,290],{"class":286},[280,955,500],{"class":303},[280,957,503],{"class":293},[280,959,506],{"class":310},[280,961,509],{"class":293},[280,963,512],{"class":286},[280,965,294],{"class":293},[280,967,968],{"class":282,"line":345},[280,969,970],{"class":355},"  // Add custom context\n",[280,972,973,976,979,982,985],{"class":282,"line":352},[280,974,975],{"class":293},"  event.context.requestId ",[280,977,978],{"class":286},"=",[280,980,981],{"class":293}," crypto.",[280,983,984],{"class":303},"randomUUID",[280,986,727],{"class":293},[280,988,989,992,994,997,1000],{"class":282,"line":359},[280,990,991],{"class":293},"  event.context.timestamp ",[280,993,978],{"class":286},[280,995,996],{"class":293}," Date.",[280,998,999],{"class":303},"now",[280,1001,727],{"class":293},[280,1003,1004],{"class":282,"line":377},[280,1005,349],{"emptyLinePlaceholder":348},[280,1007,1008],{"class":282,"line":396},[280,1009,1010],{"class":355},"  // Log the request\n",[280,1012,1013,1016,1019,1021,1024,1026,1028,1031,1033,1036,1039,1041,1043,1046,1049,1051,1053,1056,1059],{"class":282,"line":408},[280,1014,1015],{"class":293},"  console.",[280,1017,1018],{"class":303},"log",[280,1020,307],{"class":293},[280,1022,1023],{"class":371},"`[${",[280,1025,506],{"class":293},[280,1027,596],{"class":371},[280,1029,1030],{"class":293},"context",[280,1032,596],{"class":371},[280,1034,1035],{"class":293},"requestId",[280,1037,1038],{"class":371},"}] ${",[280,1040,506],{"class":293},[280,1042,596],{"class":371},[280,1044,1045],{"class":293},"method",[280,1047,1048],{"class":371},"} ${",[280,1050,506],{"class":293},[280,1052,596],{"class":371},[280,1054,1055],{"class":293},"path",[280,1057,1058],{"class":371},"}`",[280,1060,672],{"class":293},[280,1062,1063],{"class":282,"line":426},[280,1064,349],{"emptyLinePlaceholder":348},[280,1066,1067],{"class":282,"line":432},[280,1068,1069],{"class":355},"  // Continue to the next handler (don't return anything)\n",[280,1071,1072],{"class":282,"line":438},[280,1073,533],{"class":293},[1075,1076,1077],"important",{},[227,1078,1079,1080,1083],{},"If your server entry returns ",[245,1081,1082],{},"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.",[240,1085,1087],{"id":1086},"request-lifecycle","Request lifecycle",[227,1089,1090],{},"The server entry is called as part of the global middleware stack, after route rules but before route handlers:",[272,1092,1096],{"className":1093,"code":1094,"language":1095,"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. Server entry ← You are here\n5. Routes (routes/)\n6. Renderer (renderer.ts or index.html)\n","md",[245,1097,1098,1109,1117,1125,1133,1141],{"__ignoreMap":5},[280,1099,1100,1103,1106],{"class":282,"line":283},[280,1101,1102],{"class":310},"1.",[280,1104,1105],{"class":293}," Server hook: ",[280,1107,1108],{"class":329},"`request`\n",[280,1110,1111,1114],{"class":282,"line":297},[280,1112,1113],{"class":310},"2.",[280,1115,1116],{"class":293}," Route rules (headers, redirects, etc.)\n",[280,1118,1119,1122],{"class":282,"line":323},[280,1120,1121],{"class":310},"3.",[280,1123,1124],{"class":293}," Global middleware (middleware/)\n",[280,1126,1127,1130],{"class":282,"line":345},[280,1128,1129],{"class":310},"4.",[280,1131,1132],{"class":293}," Server entry ← You are here\n",[280,1134,1135,1138],{"class":282,"line":352},[280,1136,1137],{"class":310},"5.",[280,1139,1140],{"class":293}," Routes (routes/)\n",[280,1142,1143,1146],{"class":282,"line":359},[280,1144,1145],{"class":310},"6.",[280,1147,1148],{"class":293}," Renderer (renderer.ts or index.html)\n",[227,1150,1151,1152,1156],{},"Think of the server entry as the ",[1153,1154,1155],"strong",{},"last global middleware"," to run before route matching.",[1158,1159],"read-more",{"title":1160,"to":236},"Architecture > Request lifecycle",[240,1162,1164],{"id":1163},"best-practices","Best practices",[551,1166,1167,1173,1179,1182,1185,1192,1195],{},[554,1168,1169,1170],{},"Use server entry for cross-cutting concerns that affect ",[1153,1171,1172],{},"all routes",[554,1174,1175,1176,1178],{},"Return ",[245,1177,1082],{}," to continue processing, return a response to terminate",[554,1180,1181],{},"Keep server entry logic lightweight for better performance",[554,1183,1184],{},"Use global middleware for modular concerns instead of one large server entry",[554,1186,1187,1188,1191],{},"Consider using ",[234,1189,1190],{"href":49},"Nitro plugins"," for initialization logic",[554,1193,1194],{},"Avoid heavy computation in server entry (it runs for every request)",[554,1196,1197],{},"Don't use server entry for route-specific logic (use route handlers instead as they are more performant)",[1199,1200,1201],"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":297,"depth":297,"links":1203},[1204,1206,1207,1208,1209,1210],{"id":242,"depth":297,"text":1205},"Auto-detected server.ts",{"id":574,"depth":297,"text":575},{"id":860,"depth":297,"text":861},{"id":918,"depth":297,"text":919},{"id":1086,"depth":297,"text":1087},{"id":1163,"depth":297,"text":1164},"Use a server entry to create a global middleware that runs for all routes before they are matched.",{"icon":61},{"title":58,"icon":61},{"title":219,"description":1211},"yK9J27aKNqPixbSy0VIX_tJTTmrMzS9FBiZnJ-Xi50E",[1217,1219],{"title":53,"path":54,"stem":55,"description":1218,"icon":56,"children":-1},"Nitro tasks allow on-off operations in runtime.",{"title":63,"path":64,"stem":65,"description":1220,"icon":66,"children":-1},"Nitro provides a caching system built on top of the storage layer.",1764005310936]