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