[{"data":1,"prerenderedAt":1740},["ShallowReactive",2],{"navigation":3,"-deploy-providers-cloudflare":225,"-deploy-providers-cloudflare-surround":1735},[4,76,219],{"title":5,"path":6,"stem":7,"children":8,"icon":10},"Docs","/guide","1.guide/0.index",[9,11,16,21,26,31,36,41,46,51,56,61,66,71],{"title":5,"path":6,"stem":7,"icon":10},"ph:book-open-duotone",{"title":12,"path":13,"stem":14,"icon":15},"Server Utils","/guide/utils","1.guide/1.utils","ri:tools-line",{"title":17,"path":18,"stem":19,"icon":20},"Tasks","/guide/tasks","1.guide/10.tasks","codicon:run-all",{"title":22,"path":23,"stem":24,"icon":25},"Server Routes","/guide/routing","1.guide/2.routing","ri:direction-line",{"title":27,"path":28,"stem":29,"icon":30},"WebSocket","/guide/websocket","1.guide/3.websocket","cib:socket-io",{"title":32,"path":33,"stem":34,"icon":35},"KV Storage","/guide/storage","1.guide/4.storage","carbon:datastore",{"title":37,"path":38,"stem":39,"icon":40},"SQL Database","/guide/database","1.guide/5.database","ri:database-2-line",{"title":42,"path":43,"stem":44,"icon":45},"Cache","/guide/cache","1.guide/6.cache","ri:speed-line",{"title":47,"path":48,"stem":49,"icon":50},"Fetch","/guide/fetch","1.guide/7.fetch","ri:global-line",{"title":52,"path":53,"stem":54,"icon":55},"Assets","/guide/assets","1.guide/8.assets","ri:image-2-line",{"title":57,"path":58,"stem":59,"icon":60},"Plugins","/guide/plugins","1.guide/9.plugins","ri:plug-line",{"title":62,"path":63,"stem":64,"icon":65},"Configuration","/guide/configuration","1.guide/97.configuration","ri:settings-3-line",{"title":67,"path":68,"stem":69,"icon":70},"TypeScript","/guide/typescript","1.guide/98.typescript","tabler:brand-typescript",{"title":72,"path":73,"stem":74,"icon":75},"Nightly Channel","/guide/nightly","1.guide/99.nightly","ri:moon-fill",{"title":77,"path":78,"stem":79,"children":80,"icon":82},"Deploy","/deploy","2.deploy/0.index",[81,83,87,113,118],{"title":77,"path":78,"stem":79,"icon":82},"ri:upload-cloud-2-line",{"title":84,"path":85,"stem":86,"icon":50},"Edge Workers","/deploy/workers","2.deploy/1.workers",{"title":88,"path":89,"stem":90,"children":91,"page":112},"Runtimes","/deploy/runtimes","2.deploy/10.runtimes",[92,97,102,107],{"title":93,"path":94,"stem":95,"icon":96},"Node.js","/deploy/runtimes/node","2.deploy/10.runtimes/1.node","akar-icons:node-fill",{"title":98,"path":99,"stem":100,"icon":101},"WinterJS","/deploy/runtimes/_winterjs","2.deploy/10.runtimes/_winterjs","game-icons:cold-heart",{"title":103,"path":104,"stem":105,"icon":106},"Bun","/deploy/runtimes/bun","2.deploy/10.runtimes/bun","simple-icons:bun",{"title":108,"path":109,"stem":110,"icon":111},"Deno","/deploy/runtimes/deno","2.deploy/10.runtimes/deno","simple-icons:deno",false,{"title":114,"path":115,"stem":116,"icon":117},"Custom Preset","/deploy/custom-presets","2.deploy/2.custom-presets","ri:file-code-line",{"title":119,"path":120,"stem":121,"children":122,"page":112},"Providers","/deploy/providers","2.deploy/20.providers",[123,127,131,135,139,143,147,151,155,159,163,167,171,175,179,183,187,191,195,199,203,207,211,215],{"title":124,"path":125,"stem":126},"Alwaysdata","/deploy/providers/alwaysdata","2.deploy/20.providers/alwaysdata",{"title":128,"path":129,"stem":130},"AWS Lambda","/deploy/providers/aws","2.deploy/20.providers/aws",{"title":132,"path":133,"stem":134},"AWS Amplify","/deploy/providers/aws-amplify","2.deploy/20.providers/aws-amplify",{"title":136,"path":137,"stem":138},"Azure","/deploy/providers/azure","2.deploy/20.providers/azure",{"title":140,"path":141,"stem":142},"Cleavr","/deploy/providers/cleavr","2.deploy/20.providers/cleavr",{"title":144,"path":145,"stem":146},"Cloudflare","/deploy/providers/cloudflare","2.deploy/20.providers/cloudflare",{"title":148,"path":149,"stem":150},"Deno Deploy","/deploy/providers/deno-deploy","2.deploy/20.providers/deno-deploy",{"title":152,"path":153,"stem":154},"DigitalOcean","/deploy/providers/digitalocean","2.deploy/20.providers/digitalocean",{"title":156,"path":157,"stem":158},"Edgio","/deploy/providers/edgio","2.deploy/20.providers/edgio",{"title":160,"path":161,"stem":162},"Firebase","/deploy/providers/firebase","2.deploy/20.providers/firebase",{"title":164,"path":165,"stem":166},"Flightcontrol","/deploy/providers/flightcontrol","2.deploy/20.providers/flightcontrol",{"title":168,"path":169,"stem":170},"Genezio","/deploy/providers/genezio","2.deploy/20.providers/genezio",{"title":172,"path":173,"stem":174},"GitHub Pages","/deploy/providers/github-pages","2.deploy/20.providers/github-pages",{"title":176,"path":177,"stem":178},"GitLab Pages","/deploy/providers/gitlab-pages","2.deploy/20.providers/gitlab-pages",{"title":180,"path":181,"stem":182},"Heroku","/deploy/providers/heroku","2.deploy/20.providers/heroku",{"title":184,"path":185,"stem":186},"IIS","/deploy/providers/iis","2.deploy/20.providers/iis",{"title":188,"path":189,"stem":190},"Koyeb","/deploy/providers/koyeb","2.deploy/20.providers/koyeb",{"title":192,"path":193,"stem":194},"Netlify","/deploy/providers/netlify","2.deploy/20.providers/netlify",{"title":196,"path":197,"stem":198},"Platform.sh","/deploy/providers/platform-sh","2.deploy/20.providers/platform-sh",{"title":200,"path":201,"stem":202},"Render.com","/deploy/providers/render","2.deploy/20.providers/render",{"title":204,"path":205,"stem":206},"StormKit","/deploy/providers/stormkit","2.deploy/20.providers/stormkit",{"title":208,"path":209,"stem":210},"Vercel","/deploy/providers/vercel","2.deploy/20.providers/vercel",{"title":212,"path":213,"stem":214},"Zeabur","/deploy/providers/zeabur","2.deploy/20.providers/zeabur",{"title":216,"path":217,"stem":218},"Zerops","/deploy/providers/zerops","2.deploy/20.providers/zerops",{"title":220,"path":221,"stem":222,"children":223,"icon":65},"Config","/config","3.config/0.index",[224],{"title":220,"path":221,"stem":222,"icon":65},{"id":226,"title":144,"body":227,"description":1729,"extension":1730,"meta":1731,"navigation":1732,"path":145,"seo":1733,"stem":146,"__hash__":1734},"content/2.deploy/20.providers/cloudflare.md",{"type":228,"value":229,"toc":1707},"minimark",[230,235,247,251,270,280,287,457,480,499,504,513,517,521,525,528,531,534,537,540,544,556,558,601,605,612,615,621,632,637,748,765,768,773,775,778,781,784,786,788,791,795,802,816,823,835,839,848,863,867,878,887,901,1005,1009,1016,1042,1056,1060,1083,1092,1102,1106,1117,1127,1135,1140,1144,1207,1211,1225,1239,1251,1254,1256,1263,1367,1371,1374,1385,1389,1392,1483,1486,1516,1531,1536,1588,1591,1689,1694,1703],[231,232,234],"h2",{"id":233},"cloudflare-workers","Cloudflare Workers",[236,237,238,242,243],"p",{},[239,240,241],"strong",{},"Preset:"," ",[244,245,246],"code",{},"cloudflare_module",[248,249],"read-more",{"to":250,"title":234},"https://developers.cloudflare.com/workers/",[252,253,254],"note",{},[236,255,256,257,262,263,269],{},"Integration with this provider is possible with ",[258,259,261],"a",{"href":260},"/deploy#zero-config-providers","zero configuration"," supporting ",[258,264,268],{"href":265,"rel":266},"https://developers.cloudflare.com/workers/ci-cd/builds/",[267],"nofollow","workers builds (beta)",".",[271,272,273],"important",{},[236,274,275,276,279],{},"To use Workers with Static Assets, you need a Nitro compatibility date set to ",[244,277,278],{},"2024-09-19"," or later.",[236,281,282,283,286],{},"The following shows an example ",[244,284,285],{},"nitro.config.ts"," file for deploying a Nitro app to Cloudflare Workers.",[288,289,290,382],"code-group",{},[291,292,297],"pre",{"className":293,"code":294,"filename":285,"language":295,"meta":296,"style":296},"language-ts shiki shiki-themes github-light github-dark github-dark","export default defineNitroConfig({\n    compatibilityDate: \"2024-09-19\",\n    preset: \"cloudflare_module\",\n    cloudflare: {\n      deployConfig: true,\n      nodeCompat: true\n    }\n})\n","ts","",[244,298,299,319,332,343,349,361,370,376],{"__ignoreMap":296},[300,301,304,308,311,315],"span",{"class":302,"line":303},"line",1,[300,305,307],{"class":306},"so5gQ","export",[300,309,310],{"class":306}," default",[300,312,314],{"class":313},"shcOC"," defineNitroConfig",[300,316,318],{"class":317},"slsVL","({\n",[300,320,322,325,329],{"class":302,"line":321},2,[300,323,324],{"class":317},"    compatibilityDate: ",[300,326,328],{"class":327},"sfrk1","\"2024-09-19\"",[300,330,331],{"class":317},",\n",[300,333,335,338,341],{"class":302,"line":334},3,[300,336,337],{"class":317},"    preset: ",[300,339,340],{"class":327},"\"cloudflare_module\"",[300,342,331],{"class":317},[300,344,346],{"class":302,"line":345},4,[300,347,348],{"class":317},"    cloudflare: {\n",[300,350,352,355,359],{"class":302,"line":351},5,[300,353,354],{"class":317},"      deployConfig: ",[300,356,358],{"class":357},"suiK_","true",[300,360,331],{"class":317},[300,362,364,367],{"class":302,"line":363},6,[300,365,366],{"class":317},"      nodeCompat: ",[300,368,369],{"class":357},"true\n",[300,371,373],{"class":302,"line":372},7,[300,374,375],{"class":317},"    }\n",[300,377,379],{"class":302,"line":378},8,[300,380,381],{"class":317},"})\n",[291,383,386],{"className":293,"code":384,"filename":385,"language":295,"meta":296,"style":296},"export default defineNuxtConfig({\n    compatibilityDate: \"2024-09-19\",\n    nitro: {\n      preset: \"cloudflare_module\",\n      cloudflare: {\n        deployConfig: true,\n        nodeCompat: true\n      }\n    }\n})\n","nuxt.config.ts",[244,387,388,399,407,412,421,426,435,442,447,452],{"__ignoreMap":296},[300,389,390,392,394,397],{"class":302,"line":303},[300,391,307],{"class":306},[300,393,310],{"class":306},[300,395,396],{"class":313}," defineNuxtConfig",[300,398,318],{"class":317},[300,400,401,403,405],{"class":302,"line":321},[300,402,324],{"class":317},[300,404,328],{"class":327},[300,406,331],{"class":317},[300,408,409],{"class":302,"line":334},[300,410,411],{"class":317},"    nitro: {\n",[300,413,414,417,419],{"class":302,"line":345},[300,415,416],{"class":317},"      preset: ",[300,418,340],{"class":327},[300,420,331],{"class":317},[300,422,423],{"class":302,"line":351},[300,424,425],{"class":317},"      cloudflare: {\n",[300,427,428,431,433],{"class":302,"line":363},[300,429,430],{"class":317},"        deployConfig: ",[300,432,358],{"class":357},[300,434,331],{"class":317},[300,436,437,440],{"class":302,"line":372},[300,438,439],{"class":317},"        nodeCompat: ",[300,441,369],{"class":357},[300,443,444],{"class":302,"line":378},[300,445,446],{"class":317},"      }\n",[300,448,450],{"class":302,"line":449},9,[300,451,375],{"class":317},[300,453,455],{"class":302,"line":454},10,[300,456,381],{"class":317},[236,458,459,460,463,464,467,468,473,474,479],{},"By setting ",[244,461,462],{},"deployConfig: true",", Nitro will automatically generate a ",[244,465,466],{},"wrangler.json"," for you with the correct configuration.\nIf you need to add ",[258,469,472],{"href":470,"rel":471},"https://developers.cloudflare.com/workers/wrangler/configuration/",[267],"Cloudflare Workers configuration",", such as ",[258,475,478],{"href":476,"rel":477},"https://developers.cloudflare.com/workers/runtime-apis/bindings/",[267],"bindings",", you can either:",[481,482,483,493],"ul",{},[484,485,486,487,490,491,269],"li",{},"Set these in your Nitro config under the ",[244,488,489],{},"cloudflare: { wrangler : {} }",". This has the same type as ",[244,492,466],{},[484,494,495,496,498],{},"Provide your own ",[244,497,466],{},". Nitro will merge your config with the appropriate settings, including pointing to the build output.",[500,501,503],"h3",{"id":502},"local-preview","Local Preview",[236,505,506,507,512],{},"You can use ",[258,508,511],{"href":509,"rel":510},"https://github.com/cloudflare/workers-sdk/tree/main/packages/wrangler",[267],"Wrangler"," to preview your app locally:",[514,515],"pm-run",{"script":516},"build",[518,519],"pm-x",{"command":520},"wrangler dev",[500,522,524],{"id":523},"manual-deploy","Manual Deploy",[236,526,527],{},"After having built your application you can manually deploy it with Wrangler.",[236,529,530],{},"First make sure to be logged into your Cloudflare account:",[518,532],{"command":533},"wrangler login",[236,535,536],{},"Then you can deploy the application with:",[518,538],{"command":539},"wrangler deploy",[500,541,543],{"id":542},"runtime-hooks","Runtime Hooks",[236,545,506,546,550,551,269],{},[258,547,549],{"href":548},"/guide/plugins#nitro-runtime-hooks","runtime hooks"," below in order to extend ",[258,552,555],{"href":553,"rel":554},"https://developers.cloudflare.com/workers/runtime-apis/handlers/",[267],"Worker handlers",[248,557],{"to":548},[481,559,560,569,578,587,596],{},[484,561,562],{},[258,563,566],{"href":564,"rel":565},"https://developers.cloudflare.com/workers/runtime-apis/handlers/scheduled/",[267],[244,567,568],{},"cloudflare:scheduled",[484,570,571],{},[258,572,575],{"href":573,"rel":574},"https://developers.cloudflare.com/email-routing/email-workers/runtime-api/",[267],[244,576,577],{},"cloudflare:email",[484,579,580],{},[258,581,584],{"href":582,"rel":583},"https://developers.cloudflare.com/queues/configuration/javascript-apis/#consumer",[267],[244,585,586],{},"cloudflare:queue",[484,588,589],{},[258,590,593],{"href":591,"rel":592},"https://developers.cloudflare.com/workers/runtime-apis/handlers/tail/",[267],[244,594,595],{},"cloudflare:tail",[484,597,598],{},[244,599,600],{},"cloudflare:trace",[231,602,604],{"id":603},"cloudflare-pages","Cloudflare Pages",[236,606,607,242,609],{},[239,608,241],{},[244,610,611],{},"cloudflare_pages",[248,613],{"to":614,"title":604},"https://pages.cloudflare.com/",[252,616,617],{},[236,618,256,619,269],{},[258,620,261],{"href":260},[622,623,624],"warning",{},[236,625,626,627,631],{},"Cloudflare ",[258,628,630],{"href":629},"#cloudflare-workers","Workers Module"," is the new recommended preset for deployments. Please consider using the pages only if you need specific features.",[236,633,282,634,636],{},[244,635,285],{}," file for deploying a Nitro app to Cloudflare Pages.",[288,638,639,690],{},[291,640,642],{"className":293,"code":641,"filename":285,"language":295,"meta":296,"style":296},"export default defineNitroConfig({\n    preset: \"cloudflare_pages\",\n    cloudflare: {\n      deployConfig: true,\n      nodeCompat:true\n    }\n})\n",[244,643,644,654,663,667,675,682,686],{"__ignoreMap":296},[300,645,646,648,650,652],{"class":302,"line":303},[300,647,307],{"class":306},[300,649,310],{"class":306},[300,651,314],{"class":313},[300,653,318],{"class":317},[300,655,656,658,661],{"class":302,"line":321},[300,657,337],{"class":317},[300,659,660],{"class":327},"\"cloudflare_pages\"",[300,662,331],{"class":317},[300,664,665],{"class":302,"line":334},[300,666,348],{"class":317},[300,668,669,671,673],{"class":302,"line":345},[300,670,354],{"class":317},[300,672,358],{"class":357},[300,674,331],{"class":317},[300,676,677,680],{"class":302,"line":351},[300,678,679],{"class":317},"      nodeCompat:",[300,681,369],{"class":357},[300,683,684],{"class":302,"line":363},[300,685,375],{"class":317},[300,687,688],{"class":302,"line":372},[300,689,381],{"class":317},[291,691,693],{"className":293,"code":692,"filename":385,"language":295,"meta":296,"style":296},"export default defineNuxtConfig({\n    nitro: {\n      preset: \"cloudflare_pages\",\n      cloudflare: {\n        deployConfig: true,\n        nodeCompat:true\n      }\n    }\n})\n",[244,694,695,705,709,717,721,729,736,740,744],{"__ignoreMap":296},[300,696,697,699,701,703],{"class":302,"line":303},[300,698,307],{"class":306},[300,700,310],{"class":306},[300,702,396],{"class":313},[300,704,318],{"class":317},[300,706,707],{"class":302,"line":321},[300,708,411],{"class":317},[300,710,711,713,715],{"class":302,"line":334},[300,712,416],{"class":317},[300,714,660],{"class":327},[300,716,331],{"class":317},[300,718,719],{"class":302,"line":345},[300,720,425],{"class":317},[300,722,723,725,727],{"class":302,"line":351},[300,724,430],{"class":317},[300,726,358],{"class":357},[300,728,331],{"class":317},[300,730,731,734],{"class":302,"line":363},[300,732,733],{"class":317},"        nodeCompat:",[300,735,369],{"class":357},[300,737,738],{"class":302,"line":372},[300,739,446],{"class":317},[300,741,742],{"class":302,"line":378},[300,743,375],{"class":317},[300,745,746],{"class":302,"line":449},[300,747,381],{"class":317},[236,749,750,751,754,755,758,759,764],{},"Nitro automatically generates a ",[244,752,753],{},"_routes.json"," file that controls which routes get served from files and which are served from the Worker script. The auto-generated routes file can be overridden with the config option ",[244,756,757],{},"cloudflare.pages.routes"," (",[258,760,763],{"href":761,"rel":762},"https://developers.cloudflare.com/pages/platform/functions/routing/#functions-invocation-routes",[267],"read more",").",[500,766,503],{"id":767},"local-preview-1",[236,769,506,770,512],{},[258,771,511],{"href":509,"rel":772},[267],[514,774],{"script":516},[518,776],{"command":777},"wrangler pages dev",[500,779,524],{"id":780},"manual-deploy-1",[236,782,783],{},"After having built your application you can manually deploy it with Wrangler, in order to do so first make sure to be\nlogged into your Cloudflare account:",[518,785],{"command":533},[236,787,536],{},[518,789],{"command":790},"wrangler pages deploy",[231,792,794],{"id":793},"cloudflare-service-workers","Cloudflare Service Workers",[236,796,797,242,799],{},[239,798,241],{},[244,800,801],{},"cloudflare",[252,803,804],{},[236,805,806,809,810,815],{},[239,807,808],{},"Note:"," This preset uses the ",[258,811,814],{"href":812,"rel":813},"https://developers.cloudflare.com/workers/learning/service-worker/",[267],"service worker syntax"," for deployment.",[622,817,818],{},[236,819,820,822],{},[239,821,808],{}," This preset is deprecated.",[236,824,825,826,828,829,834],{},"The way this preset works is identical to that of the ",[244,827,246],{}," one presented above, with the only difference being that such preset inherits all the ",[258,830,833],{"href":831,"rel":832},"https://developers.cloudflare.com/workers/reference/migrate-to-module-workers/#advantages-of-migrating",[267],"disadvantages"," that such syntax brings.",[231,836,838],{"id":837},"deploy-within-cicd-using-github-actions","Deploy within CI/CD using GitHub Actions",[236,840,841,842,847],{},"Regardless on whether you're using Cloudflare Pages or Cloudflare Workers, you can use the ",[258,843,846],{"href":844,"rel":845},"https://github.com/marketplace/actions/deploy-to-cloudflare-workers-with-wrangler",[267],"Wrangler GitHub actions"," to deploy your application.",[252,849,850],{},[236,851,852,854,855,859,860,862],{},[239,853,808],{}," Remember to ",[258,856,858],{"href":857},"/deploy#changing-the-deployment-preset","instruct Nitro to use the correct preset"," (note that this is necessary for all presets including the ",[244,861,611],{}," one).",[231,864,866],{"id":865},"environment-variables","Environment Variables",[236,868,869,870,873,874,877],{},"Nitro allows you to universally access environment variables using ",[244,871,872],{},"process.env"," or ",[244,875,876],{},"import.meta.env"," or the runtime config.",[252,879,880],{},[236,881,882,883,886],{},"Make sure to only access environment variables ",[239,884,885],{},"within the event lifecycle","  and not in global contexts since Cloudflare only makes them available during the request lifecycle and not before.",[236,888,889,892,893,896,897,900],{},[239,890,891],{},"Example:"," If you have set the ",[244,894,895],{},"SECRET"," and ",[244,898,899],{},"NITRO_HELLO_THERE"," environment variables set you can access them in the following way:",[291,902,904],{"className":293,"code":903,"language":295,"meta":296,"style":296},"console.log(process.env.SECRET) // note that this is in the global scope! so it doesn't actually work and the variable is undefined!\n\nexport default defineEventHandler((event) => {\n  // note that all the below are valid ways of accessing the above mentioned variables\n  useRuntimeConfig(event).helloThere\n  useRuntimeConfig(event).secret\n  process.env.NITRO_HELLO_THERE\n  import.meta.env.SECRET\n});\n",[244,905,906,926,932,956,961,969,976,984,1000],{"__ignoreMap":296},[300,907,908,911,914,917,919,922],{"class":302,"line":303},[300,909,910],{"class":317},"console.",[300,912,913],{"class":313},"log",[300,915,916],{"class":317},"(process.env.",[300,918,895],{"class":357},[300,920,921],{"class":317},") ",[300,923,925],{"class":924},"sCsY4","// note that this is in the global scope! so it doesn't actually work and the variable is undefined!\n",[300,927,928],{"class":302,"line":321},[300,929,931],{"emptyLinePlaceholder":930},true,"\n",[300,933,934,936,938,941,944,948,950,953],{"class":302,"line":334},[300,935,307],{"class":306},[300,937,310],{"class":306},[300,939,940],{"class":313}," defineEventHandler",[300,942,943],{"class":317},"((",[300,945,947],{"class":946},"sQHwn","event",[300,949,921],{"class":317},[300,951,952],{"class":306},"=>",[300,954,955],{"class":317}," {\n",[300,957,958],{"class":302,"line":345},[300,959,960],{"class":924},"  // note that all the below are valid ways of accessing the above mentioned variables\n",[300,962,963,966],{"class":302,"line":351},[300,964,965],{"class":313},"  useRuntimeConfig",[300,967,968],{"class":317},"(event).helloThere\n",[300,970,971,973],{"class":302,"line":363},[300,972,965],{"class":313},[300,974,975],{"class":317},"(event).secret\n",[300,977,978,981],{"class":302,"line":372},[300,979,980],{"class":317},"  process.env.",[300,982,983],{"class":357},"NITRO_HELLO_THERE\n",[300,985,986,989,991,994,997],{"class":302,"line":378},[300,987,988],{"class":306},"  import",[300,990,269],{"class":317},[300,992,993],{"class":357},"meta",[300,995,996],{"class":317},".env.",[300,998,999],{"class":357},"SECRET\n",[300,1001,1002],{"class":302,"line":449},[300,1003,1004],{"class":317},"});\n",[500,1006,1008],{"id":1007},"specify-variables-in-development-mode","Specify Variables in Development Mode",[236,1010,1011,1012,1015],{},"For development, you can use a ",[244,1013,1014],{},".env"," file to specify environment variables:",[291,1017,1021],{"className":1018,"code":1019,"language":1020,"meta":296,"style":296},"language-ini shiki shiki-themes github-light github-dark github-dark","NITRO_HELLO_THERE=\"captain\"\nSECRET=\"top-secret\"\n","ini",[244,1022,1023,1033],{"__ignoreMap":296},[300,1024,1025,1027,1030],{"class":302,"line":303},[300,1026,899],{"class":306},[300,1028,1029],{"class":317},"=",[300,1031,1032],{"class":327},"\"captain\"\n",[300,1034,1035,1037,1039],{"class":302,"line":321},[300,1036,895],{"class":306},[300,1038,1029],{"class":317},[300,1040,1041],{"class":327},"\"top-secret\"\n",[252,1043,1044],{},[236,1045,1046,1048,1049,1051,1052,1055],{},[239,1047,808],{}," Make sure you add ",[244,1050,1014],{}," to the ",[244,1053,1054],{},".gitignore"," file so that you don't commit it as it can contain sensitive information.",[500,1057,1059],{"id":1058},"specify-variables-for-local-previews","Specify Variables for local previews",[236,1061,1062,1063,873,1065,1067,1068,1071,1072,896,1077,1082],{},"After build, when you try out your project locally with ",[244,1064,520],{},[244,1066,777],{},", in order to have access to environment variables you will need to specify the in a ",[244,1069,1070],{},".dev.vars"," file in the root of your project (as presented in the ",[258,1073,1076],{"href":1074,"rel":1075},"https://developers.cloudflare.com/pages/functions/bindings/#interact-with-your-environment-variables-locally",[267],"Pages",[258,1078,1081],{"href":1079,"rel":1080},"https://developers.cloudflare.com/workers/configuration/environment-variables/#interact-with-environment-variables-locally",[267],"Workers"," documentation).",[236,1084,1085,1086,1088,1089,1091],{},"If you are using a ",[244,1087,1014],{}," file while developing, your ",[244,1090,1070],{}," should be identical to it.",[252,1093,1094],{},[236,1095,1096,1048,1098,1051,1100,1055],{},[239,1097,808],{},[244,1099,1070],{},[244,1101,1054],{},[500,1103,1105],{"id":1104},"specify-variables-for-production","Specify Variables for Production",[236,1107,1108,1109,1116],{},"For production, use the Cloudflare dashboard or the ",[258,1110,1113],{"href":1111,"rel":1112},"https://developers.cloudflare.com/workers/wrangler/commands/#secret",[267],[244,1114,1115],{},"wrangler secret"," command to set environment variables and secrets.",[500,1118,1120,1121,1124,1125],{"id":1119},"specify-variables-using-wranglertomlwranglerjson","Specify Variables using ",[244,1122,1123],{},"wrangler.toml","/",[244,1126,466],{},[236,1128,1129,1130,1124,1132,1134],{},"You can specify a custom ",[244,1131,1123],{},[244,1133,466],{}," file and define vars inside.",[622,1136,1137],{},[236,1138,1139],{},"Note that this isn't recommend for sensitive data like secrets.",[236,1141,1142],{},[239,1143,891],{},[291,1145,1147],{"className":1018,"code":1146,"filename":1123,"language":1020,"meta":296,"style":296},"# Shared\n[vars]\nNITRO_HELLO_THERE=\"general\"\nSECRET=\"secret\"\n\n# Override values for `--env production` usage\n[env.production.vars]\nNITRO_HELLO_THERE=\"captain\"\nSECRET=\"top-secret\"\n",[244,1148,1149,1154,1159,1168,1177,1181,1186,1191,1199],{"__ignoreMap":296},[300,1150,1151],{"class":302,"line":303},[300,1152,1153],{"class":924},"# Shared\n",[300,1155,1156],{"class":302,"line":321},[300,1157,1158],{"class":313},"[vars]\n",[300,1160,1161,1163,1165],{"class":302,"line":334},[300,1162,899],{"class":306},[300,1164,1029],{"class":317},[300,1166,1167],{"class":327},"\"general\"\n",[300,1169,1170,1172,1174],{"class":302,"line":345},[300,1171,895],{"class":306},[300,1173,1029],{"class":317},[300,1175,1176],{"class":327},"\"secret\"\n",[300,1178,1179],{"class":302,"line":351},[300,1180,931],{"emptyLinePlaceholder":930},[300,1182,1183],{"class":302,"line":363},[300,1184,1185],{"class":924},"# Override values for `--env production` usage\n",[300,1187,1188],{"class":302,"line":372},[300,1189,1190],{"class":313},"[env.production.vars]\n",[300,1192,1193,1195,1197],{"class":302,"line":378},[300,1194,899],{"class":306},[300,1196,1029],{"class":317},[300,1198,1032],{"class":327},[300,1200,1201,1203,1205],{"class":302,"line":449},[300,1202,895],{"class":306},[300,1204,1029],{"class":317},[300,1206,1041],{"class":327},[231,1208,1210],{"id":1209},"direct-access-to-cloudflare-bindings","Direct access to Cloudflare bindings",[236,1212,1213,1214,1219,1220,764],{},"Bindings are what allows you to interact with resources from the Cloudflare platform, examples of such resources are key-value data storages (",[258,1215,1218],{"href":1216,"rel":1217},"https://developers.cloudflare.com/kv/",[267],"KVs",") and serverless SQL databases (",[258,1221,1224],{"href":1222,"rel":1223},"https://developers.cloudflare.com/d1/",[267],"D1s",[248,1226,1227],{},[236,1228,1229,1230,896,1234,1238],{},"For more details on Bindings and how to use them please refer to the Cloudflare ",[258,1231,1076],{"href":1232,"rel":1233},"https://developers.cloudflare.com/pages/functions/bindings/",[267],[258,1235,1081],{"href":1236,"rel":1237},"https://developers.cloudflare.com/workers/configuration/bindings/#bindings",[267]," documentation.",[1240,1241,1242],"tip",{},[236,1243,1244,1245,896,1247,1250],{},"\nNitro provides high level API to interact with primitives such as ",[258,1246,32],{"href":33},[258,1248,1249],{"href":38},"Database"," and you are highly recommended to prefer using them instead of directly depending on low-level APIs for usage stability.",[248,1252],{"to":38,"title":1253},"Database Layer",[248,1255],{"to":33,"title":32},[236,1257,1258,1259,1262],{},"In runtime, you can access bindings from the request event, by accessing its ",[244,1260,1261],{},"context.cloudflare.env"," field, this is for example how you can access a D1 bindings:",[291,1264,1266],{"className":293,"code":1265,"language":295,"meta":296,"style":296},"defineEventHandler(async (event) => {\n  const { cloudflare } = event.context\n  const stmt = await cloudflare.env.MY_D1.prepare('SELECT id FROM table')\n  const { results } = await stmt.all()\n})\n",[244,1267,1268,1289,1307,1339,1363],{"__ignoreMap":296},[300,1269,1270,1273,1276,1279,1281,1283,1285,1287],{"class":302,"line":303},[300,1271,1272],{"class":313},"defineEventHandler",[300,1274,1275],{"class":317},"(",[300,1277,1278],{"class":306},"async",[300,1280,758],{"class":317},[300,1282,947],{"class":946},[300,1284,921],{"class":317},[300,1286,952],{"class":306},[300,1288,955],{"class":317},[300,1290,1291,1294,1297,1299,1302,1304],{"class":302,"line":321},[300,1292,1293],{"class":306},"  const",[300,1295,1296],{"class":317}," { ",[300,1298,801],{"class":357},[300,1300,1301],{"class":317}," } ",[300,1303,1029],{"class":306},[300,1305,1306],{"class":317}," event.context\n",[300,1308,1309,1311,1314,1317,1320,1323,1326,1328,1331,1333,1336],{"class":302,"line":334},[300,1310,1293],{"class":306},[300,1312,1313],{"class":357}," stmt",[300,1315,1316],{"class":306}," =",[300,1318,1319],{"class":306}," await",[300,1321,1322],{"class":317}," cloudflare.env.",[300,1324,1325],{"class":357},"MY_D1",[300,1327,269],{"class":317},[300,1329,1330],{"class":313},"prepare",[300,1332,1275],{"class":317},[300,1334,1335],{"class":327},"'SELECT id FROM table'",[300,1337,1338],{"class":317},")\n",[300,1340,1341,1343,1345,1348,1350,1352,1354,1357,1360],{"class":302,"line":345},[300,1342,1293],{"class":306},[300,1344,1296],{"class":317},[300,1346,1347],{"class":357},"results",[300,1349,1301],{"class":317},[300,1351,1029],{"class":306},[300,1353,1319],{"class":306},[300,1355,1356],{"class":317}," stmt.",[300,1358,1359],{"class":313},"all",[300,1361,1362],{"class":317},"()\n",[300,1364,1365],{"class":302,"line":351},[300,1366,381],{"class":317},[231,1368,1370],{"id":1369},"dev-preset","Dev Preset",[236,1372,1373],{},"Cloudflare preset can be enabled in development mode for production environment emulation and access to the bindings in local dev.",[236,1375,1376,1377,1384],{},"In order to enable dev preset, make sure using latest nitro version (>=2.12) and install ",[258,1378,1381],{"href":1379,"rel":1380},"https://npmjs.com/package/wrangler",[267],[244,1382,1383],{},"wrangler"," as a dependency.",[1386,1387],"pm-install",{"name":1388},"-D wrangler",[236,1390,1391],{},"Then, update config:",[1393,1394,1395,1437],"CodeGroup",{},[291,1396,1398],{"className":293,"code":1397,"filename":285,"language":295,"meta":296,"style":296},"export default defineNitroConfig({\n    compatibilityDate: \"2025-07-15\", // or \"latest\"\n    preset: \"cloudflare-module\" // or \"cloudflare-pages\"\n})\n",[244,1399,1400,1410,1423,1433],{"__ignoreMap":296},[300,1401,1402,1404,1406,1408],{"class":302,"line":303},[300,1403,307],{"class":306},[300,1405,310],{"class":306},[300,1407,314],{"class":313},[300,1409,318],{"class":317},[300,1411,1412,1414,1417,1420],{"class":302,"line":321},[300,1413,324],{"class":317},[300,1415,1416],{"class":327},"\"2025-07-15\"",[300,1418,1419],{"class":317},", ",[300,1421,1422],{"class":924},"// or \"latest\"\n",[300,1424,1425,1427,1430],{"class":302,"line":334},[300,1426,337],{"class":317},[300,1428,1429],{"class":327},"\"cloudflare-module\"",[300,1431,1432],{"class":924}," // or \"cloudflare-pages\"\n",[300,1434,1435],{"class":302,"line":345},[300,1436,381],{"class":317},[291,1438,1440],{"className":293,"code":1439,"filename":385,"language":295,"meta":296,"style":296},"export default defineNuxtConfig({\n    compatibilityDate: \"2025-07-15\", // or \"latest\"\n    nitro: {\n        preset: \"cloudflare-module\" // or \"cloudflare-pages\"\n    }\n})\n",[244,1441,1442,1452,1462,1466,1475,1479],{"__ignoreMap":296},[300,1443,1444,1446,1448,1450],{"class":302,"line":303},[300,1445,307],{"class":306},[300,1447,310],{"class":306},[300,1449,396],{"class":313},[300,1451,318],{"class":317},[300,1453,1454,1456,1458,1460],{"class":302,"line":321},[300,1455,324],{"class":317},[300,1457,1416],{"class":327},[300,1459,1419],{"class":317},[300,1461,1422],{"class":924},[300,1463,1464],{"class":302,"line":334},[300,1465,411],{"class":317},[300,1467,1468,1471,1473],{"class":302,"line":345},[300,1469,1470],{"class":317},"        preset: ",[300,1472,1429],{"class":327},[300,1474,1432],{"class":924},[300,1476,1477],{"class":302,"line":351},[300,1478,375],{"class":317},[300,1480,1481],{"class":302,"line":363},[300,1482,381],{"class":317},[236,1484,1485],{},"In development terminal, you should see a message like this:",[291,1487,1491],{"className":1488,"code":1489,"language":1490,"meta":296,"style":296},"language-sh shiki shiki-themes github-light github-dark github-dark","ℹ Using cloudflare-dev emulation in development mode.\n","sh",[244,1492,1493],{"__ignoreMap":296},[300,1494,1495,1498,1501,1504,1507,1510,1513],{"class":302,"line":303},[300,1496,1497],{"class":313},"ℹ",[300,1499,1500],{"class":327}," Using",[300,1502,1503],{"class":327}," cloudflare-dev",[300,1505,1506],{"class":327}," emulation",[300,1508,1509],{"class":327}," in",[300,1511,1512],{"class":327}," development",[300,1514,1515],{"class":327}," mode.\n",[236,1517,1518,1519,1124,1521,1524,1525,1528,1529,764],{},"In order to access bindings in dev mode we start by defining the bindings. You can do this in a ",[244,1520,1123],{},[244,1522,1523],{},"wrangler.jsonc"," file, or directly in your Nitro config under ",[244,1526,1527],{},"cloudflare.wrangler"," (accepts the same type as ",[244,1530,466],{},[236,1532,1533,1534],{},"For example to define a variable and a KV namespace in a ",[244,1535,1123],{},[291,1537,1539],{"className":1018,"code":1538,"filename":1123,"language":1020,"meta":296,"style":296},"[vars]\nMY_VARIABLE=\"my-value\"\n\n[[kv_namespaces]]\nbinding = \"MY_KV\"\nid = \"xxx\"\n",[244,1540,1541,1545,1555,1559,1567,1578],{"__ignoreMap":296},[300,1542,1543],{"class":302,"line":303},[300,1544,1158],{"class":313},[300,1546,1547,1550,1552],{"class":302,"line":321},[300,1548,1549],{"class":306},"MY_VARIABLE",[300,1551,1029],{"class":317},[300,1553,1554],{"class":327},"\"my-value\"\n",[300,1556,1557],{"class":302,"line":334},[300,1558,931],{"emptyLinePlaceholder":930},[300,1560,1561,1564],{"class":302,"line":345},[300,1562,1563],{"class":313},"[[kv_namespaces]",[300,1565,1566],{"class":317},"]\n",[300,1568,1569,1572,1575],{"class":302,"line":351},[300,1570,1571],{"class":306},"binding",[300,1573,1574],{"class":317}," = ",[300,1576,1577],{"class":327},"\"MY_KV\"\n",[300,1579,1580,1583,1585],{"class":302,"line":363},[300,1581,1582],{"class":306},"id",[300,1584,1574],{"class":317},[300,1586,1587],{"class":327},"\"xxx\"\n",[236,1589,1590],{},"Or in your Nitro config:",[291,1592,1597],{"className":1593,"code":1594,"filename":1595,"language":1596,"meta":296,"style":296},"language-js shiki shiki-themes github-light github-dark github-dark","export default defineNitroConfig({\n    cloudflare: {\n      wrangler: {\n        vars: {\n          MY_VARIABLE: \"my-value\"\n        },\n        kv_namespaces: [\n          {\n            binding: \"MY_KV\",\n            id: \"xxx\"\n          }\n        ]\n      }\n    }\n});\n","nitro.config.js","js",[244,1598,1599,1609,1613,1618,1623,1630,1635,1640,1645,1655,1662,1668,1674,1679,1684],{"__ignoreMap":296},[300,1600,1601,1603,1605,1607],{"class":302,"line":303},[300,1602,307],{"class":306},[300,1604,310],{"class":306},[300,1606,314],{"class":313},[300,1608,318],{"class":317},[300,1610,1611],{"class":302,"line":321},[300,1612,348],{"class":317},[300,1614,1615],{"class":302,"line":334},[300,1616,1617],{"class":317},"      wrangler: {\n",[300,1619,1620],{"class":302,"line":345},[300,1621,1622],{"class":317},"        vars: {\n",[300,1624,1625,1628],{"class":302,"line":351},[300,1626,1627],{"class":317},"          MY_VARIABLE: ",[300,1629,1554],{"class":327},[300,1631,1632],{"class":302,"line":363},[300,1633,1634],{"class":317},"        },\n",[300,1636,1637],{"class":302,"line":372},[300,1638,1639],{"class":317},"        kv_namespaces: [\n",[300,1641,1642],{"class":302,"line":378},[300,1643,1644],{"class":317},"          {\n",[300,1646,1647,1650,1653],{"class":302,"line":449},[300,1648,1649],{"class":317},"            binding: ",[300,1651,1652],{"class":327},"\"MY_KV\"",[300,1654,331],{"class":317},[300,1656,1657,1660],{"class":302,"line":454},[300,1658,1659],{"class":317},"            id: ",[300,1661,1587],{"class":327},[300,1663,1665],{"class":302,"line":1664},11,[300,1666,1667],{"class":317},"          }\n",[300,1669,1671],{"class":302,"line":1670},12,[300,1672,1673],{"class":317},"        ]\n",[300,1675,1677],{"class":302,"line":1676},13,[300,1678,446],{"class":317},[300,1680,1682],{"class":302,"line":1681},14,[300,1683,375],{"class":317},[300,1685,1687],{"class":302,"line":1686},15,[300,1688,1004],{"class":317},[252,1690,1691],{},[236,1692,1693],{},"\nOnly bindings in the default environment are recognized.",[236,1695,1696,1697,896,1699,1702],{},"you will be able to access the ",[244,1698,1549],{},[244,1700,1701],{},"MY_KV"," from the request event just as illustrated above.",[1704,1705,1706],"style",{},"html pre.shiki code .so5gQ, html code.shiki .so5gQ{--shiki-light:#D73A49;--shiki-default:#F97583;--shiki-dark:#F97583}html pre.shiki code .shcOC, html code.shiki .shcOC{--shiki-light:#6F42C1;--shiki-default:#B392F0;--shiki-dark:#B392F0}html pre.shiki code .slsVL, html code.shiki .slsVL{--shiki-light:#24292E;--shiki-default:#E1E4E8;--shiki-dark:#E1E4E8}html pre.shiki code .sfrk1, html code.shiki .sfrk1{--shiki-light:#032F62;--shiki-default:#9ECBFF;--shiki-dark:#9ECBFF}html pre.shiki code .suiK_, html code.shiki .suiK_{--shiki-light:#005CC5;--shiki-default:#79B8FF;--shiki-dark:#79B8FF}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sCsY4, html code.shiki .sCsY4{--shiki-light:#6A737D;--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .sQHwn, html code.shiki .sQHwn{--shiki-light:#E36209;--shiki-default:#FFAB70;--shiki-dark:#FFAB70}",{"title":296,"searchDepth":321,"depth":321,"links":1708},[1709,1714,1718,1719,1720,1727,1728],{"id":233,"depth":321,"text":234,"children":1710},[1711,1712,1713],{"id":502,"depth":334,"text":503},{"id":523,"depth":334,"text":524},{"id":542,"depth":334,"text":543},{"id":603,"depth":321,"text":604,"children":1715},[1716,1717],{"id":767,"depth":334,"text":503},{"id":780,"depth":334,"text":524},{"id":793,"depth":321,"text":794},{"id":837,"depth":321,"text":838},{"id":865,"depth":321,"text":866,"children":1721},[1722,1723,1724,1725],{"id":1007,"depth":334,"text":1008},{"id":1058,"depth":334,"text":1059},{"id":1104,"depth":334,"text":1105},{"id":1119,"depth":334,"text":1726},"Specify Variables using wrangler.toml/wrangler.json",{"id":1209,"depth":321,"text":1210},{"id":1369,"depth":321,"text":1370},"Deploy Nitro apps to Cloudflare.","md",{},{},{"title":144,"description":1729},"GM0j-F0rPtjZo7sncmC2cdG4NNHv2tviwOhqD4rw0is",[1736,1738],{"title":140,"path":141,"stem":142,"description":1737,"children":-1},"Deploy Nitro apps to Cleavr.",{"title":148,"path":149,"stem":150,"description":1739,"children":-1},"Deploy Nitro apps to Deno Deploy.",1775117856421]