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