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