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