[{"data":1,"prerenderedAt":1816},["ShallowReactive",2],{"navigation":3,"-deploy-providers-cloudflare":217,"-deploy-providers-cloudflare-surround":1811},[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":1805,"extension":1806,"meta":1807,"navigation":1808,"path":138,"seo":1809,"stem":139,"__hash__":1810},"content/2.deploy/20.providers/cloudflare.md",{"type":220,"value":221,"toc":1782},"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,1028,1032,1042,1068,1084,1088,1111,1122,1132,1136,1147,1156,1164,1169,1173,1347,1351,1365,1379,1390,1393,1395,1402,1522,1526,1537,1542,1674,1681,1685,1688,1691,1700,1705,1708,1778],[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\";\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",[236,900,901,915,929,933,952,956,977,982,990,997,1005,1022],{"__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,919,922,924,927],{"class":290,"line":312},[288,918,295],{"class":294},[288,920,921],{"class":298}," { useRuntimeConfig } ",[288,923,302],{"class":294},[288,925,926],{"class":305}," \"nitro/runtime-config\"",[288,928,309],{"class":298},[288,930,931],{"class":290,"line":319},[288,932,316],{"emptyLinePlaceholder":315},[288,934,935,938,941,944,946,949],{"class":290,"line":335},[288,936,937],{"class":298},"console.",[288,939,940],{"class":328},"log",[288,942,943],{"class":298},"(process.env.",[288,945,890],{"class":370},[288,947,948],{"class":298},") ",[288,950,951],{"class":614},"// note that this is in the global scope! so it doesn't actually work and the variable is undefined!\n",[288,953,954],{"class":290,"line":347},[288,955,316],{"emptyLinePlaceholder":315},[288,957,958,960,962,965,968,970,972,975],{"class":290,"line":358},[288,959,322],{"class":294},[288,961,325],{"class":294},[288,963,964],{"class":328}," defineHandler",[288,966,967],{"class":298},"((",[288,969,589],{"class":588},[288,971,948],{"class":298},[288,973,974],{"class":294},"=>",[288,976,574],{"class":298},[288,978,979],{"class":290,"line":364},[288,980,981],{"class":614},"  // note that all the below are valid ways of accessing the above mentioned variables\n",[288,983,984,987],{"class":290,"line":376},[288,985,986],{"class":328},"  useRuntimeConfig",[288,988,989],{"class":298},"().helloThere\n",[288,991,992,994],{"class":290,"line":385},[288,993,986],{"class":328},[288,995,996],{"class":298},"().secret\n",[288,998,999,1002],{"class":290,"line":391},[288,1000,1001],{"class":298},"  process.env.",[288,1003,1004],{"class":370},"NITRO_HELLO_THERE\n",[288,1006,1008,1011,1013,1016,1019],{"class":290,"line":1007},11,[288,1009,1010],{"class":294},"  import",[288,1012,261],{"class":298},[288,1014,1015],{"class":370},"meta",[288,1017,1018],{"class":298},".env.",[288,1020,1021],{"class":370},"SECRET\n",[288,1023,1025],{"class":290,"line":1024},12,[288,1026,1027],{"class":298},"});\n",[438,1029,1031],{"id":1030},"specify-variables-in-development-mode","Specify Variables in Development Mode",[228,1033,1034,1035,868,1038,1041],{},"For development, you can use a ",[236,1036,1037],{},".env",[236,1039,1040],{},".env.local"," file to specify environment variables:",[280,1043,1047],{"className":1044,"code":1045,"language":1046,"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,1048,1049,1059],{"__ignoreMap":5},[288,1050,1051,1053,1056],{"class":290,"line":291},[288,1052,894],{"class":294},[288,1054,1055],{"class":298},"=",[288,1057,1058],{"class":305},"\"captain\"\n",[288,1060,1061,1063,1065],{"class":290,"line":312},[288,1062,890],{"class":294},[288,1064,1055],{"class":298},[288,1066,1067],{"class":305},"\"top-secret\"\n",[244,1069,1070],{},[228,1071,1072,1074,1075,891,1077,1079,1080,1083],{},[231,1073,848],{}," Make sure you add ",[236,1076,1037],{},[236,1078,1040],{}," to the ",[236,1081,1082],{},".gitignore"," file so that you don't commit it as it can contain sensitive information.",[438,1085,1087],{"id":1086},"specify-variables-for-local-previews","Specify Variables for local previews",[228,1089,1090,1091,868,1093,1095,1096,1099,1100,891,1105,1110],{},"After build, when you try out your project locally with ",[236,1092,458],{},[236,1094,815],{},", in order to have access to environment variables you will need to specify the in a ",[236,1097,1098],{},".dev.vars"," file in the root of your project (as presented in the ",[250,1101,1104],{"href":1102,"rel":1103},"https://developers.cloudflare.com/pages/functions/bindings/#interact-with-your-environment-variables-locally",[259],"Pages",[250,1106,1109],{"href":1107,"rel":1108},"https://developers.cloudflare.com/workers/configuration/environment-variables/#interact-with-environment-variables-locally",[259],"Workers"," documentation).",[228,1112,1113,1114,868,1116,1118,1119,1121],{},"If you are using a ",[236,1115,1037],{},[236,1117,1040],{}," file while developing, your ",[236,1120,1098],{}," should be identical to it.",[244,1123,1124],{},[228,1125,1126,1074,1128,1079,1130,1083],{},[231,1127,848],{},[236,1129,1098],{},[236,1131,1082],{},[438,1133,1135],{"id":1134},"specify-variables-for-production","Specify Variables for Production",[228,1137,1138,1139,1146],{},"For production, use the Cloudflare dashboard or the ",[250,1140,1143],{"href":1141,"rel":1142},"https://developers.cloudflare.com/workers/wrangler/commands/#secret",[259],[236,1144,1145],{},"wrangler secret"," command to set environment variables and secrets.",[438,1148,1150,1151,215,1154],{"id":1149},"specify-variables-using-wranglertomlwranglerjson","Specify Variables using ",[236,1152,1153],{},"wrangler.toml",[236,1155,404],{},[228,1157,1158,1159,215,1161,1163],{},"You can specify a custom ",[236,1160,1153],{},[236,1162,404],{}," file and define vars inside.",[630,1165,1166],{},[228,1167,1168],{},"Note that this isn't recommend for sensitive data like secrets.",[228,1170,1171],{},[231,1172,886],{},[1174,1175,1176,1239],"code-group",{},[280,1177,1179],{"className":1044,"code":1178,"filename":1153,"language":1046,"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,1180,1181,1186,1191,1200,1209,1213,1218,1223,1231],{"__ignoreMap":5},[288,1182,1183],{"class":290,"line":291},[288,1184,1185],{"class":614},"# Shared\n",[288,1187,1188],{"class":290,"line":312},[288,1189,1190],{"class":328},"[vars]\n",[288,1192,1193,1195,1197],{"class":290,"line":319},[288,1194,894],{"class":294},[288,1196,1055],{"class":298},[288,1198,1199],{"class":305},"\"general\"\n",[288,1201,1202,1204,1206],{"class":290,"line":335},[288,1203,890],{"class":294},[288,1205,1055],{"class":298},[288,1207,1208],{"class":305},"\"secret\"\n",[288,1210,1211],{"class":290,"line":347},[288,1212,316],{"emptyLinePlaceholder":315},[288,1214,1215],{"class":290,"line":358},[288,1216,1217],{"class":614},"# Override values for `--env production` usage\n",[288,1219,1220],{"class":290,"line":364},[288,1221,1222],{"class":328},"[env.production.vars]\n",[288,1224,1225,1227,1229],{"class":290,"line":376},[288,1226,894],{"class":294},[288,1228,1055],{"class":298},[288,1230,1058],{"class":305},[288,1232,1233,1235,1237],{"class":290,"line":385},[288,1234,890],{"class":294},[288,1236,1055],{"class":298},[288,1238,1067],{"class":305},[280,1240,1244],{"className":1241,"code":1242,"filename":404,"language":1243,"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,1245,1246,1251,1259,1272,1281,1286,1293,1300,1307,1319,1328,1333,1337,1342],{"__ignoreMap":5},[288,1247,1248],{"class":290,"line":291},[288,1249,1250],{"class":298},"{\n",[288,1252,1253,1256],{"class":290,"line":312},[288,1254,1255],{"class":370},"  \"vars\"",[288,1257,1258],{"class":298},": {\n",[288,1260,1261,1264,1267,1270],{"class":290,"line":319},[288,1262,1263],{"class":370},"    \"NITRO_HELLO_THERE\"",[288,1265,1266],{"class":298},": ",[288,1268,1269],{"class":305},"\"general\"",[288,1271,344],{"class":298},[288,1273,1274,1277,1279],{"class":290,"line":335},[288,1275,1276],{"class":370},"    \"SECRET\"",[288,1278,1266],{"class":298},[288,1280,1208],{"class":305},[288,1282,1283],{"class":290,"line":347},[288,1284,1285],{"class":298},"  },\n",[288,1287,1288,1291],{"class":290,"line":358},[288,1289,1290],{"class":370},"  \"env\"",[288,1292,1258],{"class":298},[288,1294,1295,1298],{"class":290,"line":364},[288,1296,1297],{"class":370},"    \"production\"",[288,1299,1258],{"class":298},[288,1301,1302,1305],{"class":290,"line":376},[288,1303,1304],{"class":370},"      \"vars\"",[288,1306,1258],{"class":298},[288,1308,1309,1312,1314,1317],{"class":290,"line":385},[288,1310,1311],{"class":370},"        \"NITRO_HELLO_THERE\"",[288,1313,1266],{"class":298},[288,1315,1316],{"class":305},"\"captain\"",[288,1318,344],{"class":298},[288,1320,1321,1324,1326],{"class":290,"line":391},[288,1322,1323],{"class":370},"        \"SECRET\"",[288,1325,1266],{"class":298},[288,1327,1067],{"class":305},[288,1329,1330],{"class":290,"line":1007},[288,1331,1332],{"class":298},"      }\n",[288,1334,1335],{"class":290,"line":1024},[288,1336,388],{"class":298},[288,1338,1340],{"class":290,"line":1339},13,[288,1341,620],{"class":298},[288,1343,1345],{"class":290,"line":1344},14,[288,1346,625],{"class":298},[223,1348,1350],{"id":1349},"direct-access-to-cloudflare-bindings","Direct access to Cloudflare bindings",[228,1352,1353,1354,1359,1360,802],{},"Bindings are what allows you to interact with resources from the Cloudflare platform, examples of such resources are key-value data storages (",[250,1355,1358],{"href":1356,"rel":1357},"https://developers.cloudflare.com/kv/",[259],"KVs",") and serverless SQL databases (",[250,1361,1364],{"href":1362,"rel":1363},"https://developers.cloudflare.com/d1/",[259],"D1s",[240,1366,1367],{},[228,1368,1369,1370,891,1374,1378],{},"For more details on Bindings and how to use them please refer to the Cloudflare ",[250,1371,1104],{"href":1372,"rel":1373},"https://developers.cloudflare.com/pages/functions/bindings/",[259],[250,1375,1109],{"href":1376,"rel":1377},"https://developers.cloudflare.com/workers/configuration/bindings/#bindings",[259]," documentation.",[1380,1381,1382],"tip",{},[228,1383,1384,1385,891,1387,1389],{},"\nNitro provides high level API to interact with primitives such as ",[250,1386,68],{"href":69},[250,1388,38],{"href":39}," and you are highly recommended to prefer using them instead of directly depending on low-level APIs for usage stability.",[240,1391],{"to":39,"title":1392},"Database Layer",[240,1394],{"to":69,"title":68},[228,1396,1397,1398,1401],{},"In runtime, you can access bindings from the request event, by accessing its ",[236,1399,1400],{},"context.cloudflare.env"," field, this is for example how you can access a D1 bindings:",[280,1403,1405],{"className":282,"code":1404,"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,1406,1407,1419,1423,1443,1462,1494,1518],{"__ignoreMap":5},[288,1408,1409,1411,1413,1415,1417],{"class":290,"line":291},[288,1410,295],{"class":294},[288,1412,907],{"class":298},[288,1414,302],{"class":294},[288,1416,912],{"class":305},[288,1418,309],{"class":298},[288,1420,1421],{"class":290,"line":312},[288,1422,316],{"emptyLinePlaceholder":315},[288,1424,1425,1428,1430,1433,1435,1437,1439,1441],{"class":290,"line":319},[288,1426,1427],{"class":328},"defineHandler",[288,1429,585],{"class":298},[288,1431,1432],{"class":294},"async",[288,1434,796],{"class":298},[288,1436,589],{"class":588},[288,1438,948],{"class":298},[288,1440,974],{"class":294},[288,1442,574],{"class":298},[288,1444,1445,1448,1451,1454,1457,1459],{"class":290,"line":335},[288,1446,1447],{"class":294},"  const",[288,1449,1450],{"class":298}," { ",[288,1452,1453],{"class":370},"cloudflare",[288,1455,1456],{"class":298}," } ",[288,1458,1055],{"class":294},[288,1460,1461],{"class":298}," event.context\n",[288,1463,1464,1466,1469,1472,1475,1478,1481,1483,1486,1488,1491],{"class":290,"line":347},[288,1465,1447],{"class":294},[288,1467,1468],{"class":370}," stmt",[288,1470,1471],{"class":294}," =",[288,1473,1474],{"class":294}," await",[288,1476,1477],{"class":298}," cloudflare.env.",[288,1479,1480],{"class":370},"MY_D1",[288,1482,261],{"class":298},[288,1484,1485],{"class":328},"prepare",[288,1487,585],{"class":298},[288,1489,1490],{"class":305},"'SELECT id FROM table'",[288,1492,1493],{"class":298},")\n",[288,1495,1496,1498,1500,1503,1505,1507,1509,1512,1515],{"class":290,"line":358},[288,1497,1447],{"class":294},[288,1499,1450],{"class":298},[288,1501,1502],{"class":370},"results",[288,1504,1456],{"class":298},[288,1506,1055],{"class":294},[288,1508,1474],{"class":294},[288,1510,1511],{"class":298}," stmt.",[288,1513,1514],{"class":328},"all",[288,1516,1517],{"class":298},"()\n",[288,1519,1520],{"class":290,"line":364},[288,1521,394],{"class":298},[438,1523,1525],{"id":1524},"access-to-the-bindings-in-local-dev","Access to the bindings in local dev",[228,1527,1528,1529,215,1532,215,1534,1536],{},"To access bindings in dev mode, we first define them. You can do this in a ",[236,1530,1531],{},"wrangler.jsonc",[236,1533,404],{},[236,1535,1153],{}," file",[228,1538,1539,1540,592],{},"For example, to define a variable and a KV namespace in ",[236,1541,1153],{},[1174,1543,1544,1596],{},[280,1545,1547],{"className":1044,"code":1546,"filename":1153,"language":1046,"meta":5,"style":5},"[vars]\nMY_VARIABLE=\"my-value\"\n\n[[kv_namespaces]]\nbinding = \"MY_KV\"\nid = \"xxx\"\n",[236,1548,1549,1553,1563,1567,1575,1586],{"__ignoreMap":5},[288,1550,1551],{"class":290,"line":291},[288,1552,1190],{"class":328},[288,1554,1555,1558,1560],{"class":290,"line":312},[288,1556,1557],{"class":294},"MY_VARIABLE",[288,1559,1055],{"class":298},[288,1561,1562],{"class":305},"\"my-value\"\n",[288,1564,1565],{"class":290,"line":319},[288,1566,316],{"emptyLinePlaceholder":315},[288,1568,1569,1572],{"class":290,"line":335},[288,1570,1571],{"class":328},"[[kv_namespaces]",[288,1573,1574],{"class":298},"]\n",[288,1576,1577,1580,1583],{"class":290,"line":347},[288,1578,1579],{"class":294},"binding",[288,1581,1582],{"class":298}," = ",[288,1584,1585],{"class":305},"\"MY_KV\"\n",[288,1587,1588,1591,1593],{"class":290,"line":358},[288,1589,1590],{"class":294},"id",[288,1592,1582],{"class":298},[288,1594,1595],{"class":305},"\"xxx\"\n",[280,1597,1599],{"className":1241,"code":1598,"filename":404,"language":1243,"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,1600,1601,1605,1611,1623,1627,1635,1640,1652,1661,1665,1670],{"__ignoreMap":5},[288,1602,1603],{"class":290,"line":291},[288,1604,1250],{"class":298},[288,1606,1607,1609],{"class":290,"line":312},[288,1608,1255],{"class":370},[288,1610,1258],{"class":298},[288,1612,1613,1616,1618,1621],{"class":290,"line":319},[288,1614,1615],{"class":370},"    \"MY_VARIABLE\"",[288,1617,1266],{"class":298},[288,1619,1620],{"class":305},"\"my-value\"",[288,1622,344],{"class":298},[288,1624,1625],{"class":290,"line":335},[288,1626,1285],{"class":298},[288,1628,1629,1632],{"class":290,"line":347},[288,1630,1631],{"class":370},"  \"kv_namespaces\"",[288,1633,1634],{"class":298},": [\n",[288,1636,1637],{"class":290,"line":358},[288,1638,1639],{"class":298},"    {\n",[288,1641,1642,1645,1647,1650],{"class":290,"line":364},[288,1643,1644],{"class":370},"      \"binding\"",[288,1646,1266],{"class":298},[288,1648,1649],{"class":305},"\"MY_KV\"",[288,1651,344],{"class":298},[288,1653,1654,1657,1659],{"class":290,"line":376},[288,1655,1656],{"class":370},"      \"id\"",[288,1658,1266],{"class":298},[288,1660,1595],{"class":305},[288,1662,1663],{"class":290,"line":385},[288,1664,388],{"class":298},[288,1666,1667],{"class":290,"line":391},[288,1668,1669],{"class":298},"  ]\n",[288,1671,1672],{"class":290,"line":1007},[288,1673,625],{"class":298},[228,1675,1676,1677,1680],{},"Next we install the required ",[236,1678,1679],{},"wrangler"," package (if not already installed):",[1682,1683],"pm-install",{"name":1684},"wrangler -D",[228,1686,1687],{},"From this moment, when running",[452,1689],{"script":1690},"dev",[228,1692,1693,1694,891,1696,1699],{},"you will be able to access the ",[236,1695,1557],{},[236,1697,1698],{},"MY_KV"," from the request event just as illustrated above.",[1701,1702,1704],"h4",{"id":1703},"wrangler-environments","Wrangler environments",[228,1706,1707],{},"If you have multiple Wrangler environments, you can specify which Wrangler environment to use during Cloudflare dev emulation:",[280,1709,1711],{"className":282,"code":1710,"filename":277,"language":284,"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",[236,1712,1713,1725,1729,1739,1749,1753,1758,1766,1770,1774],{"__ignoreMap":5},[288,1714,1715,1717,1719,1721,1723],{"class":290,"line":291},[288,1716,295],{"class":294},[288,1718,299],{"class":298},[288,1720,302],{"class":294},[288,1722,306],{"class":305},[288,1724,309],{"class":298},[288,1726,1727],{"class":290,"line":312},[288,1728,316],{"emptyLinePlaceholder":315},[288,1730,1731,1733,1735,1737],{"class":290,"line":319},[288,1732,322],{"class":294},[288,1734,325],{"class":294},[288,1736,329],{"class":328},[288,1738,332],{"class":298},[288,1740,1741,1744,1747],{"class":290,"line":335},[288,1742,1743],{"class":298},"  preset: ",[288,1745,1746],{"class":305},"'cloudflare-module'",[288,1748,344],{"class":298},[288,1750,1751],{"class":290,"line":347},[288,1752,667],{"class":298},[288,1754,1755],{"class":290,"line":358},[288,1756,1757],{"class":298},"    dev: {\n",[288,1759,1760,1763],{"class":290,"line":364},[288,1761,1762],{"class":298},"      environment: ",[288,1764,1765],{"class":305},"'preview'\n",[288,1767,1768],{"class":290,"line":376},[288,1769,388],{"class":298},[288,1771,1772],{"class":290,"line":385},[288,1773,620],{"class":298},[288,1775,1776],{"class":290,"line":391},[288,1777,394],{"class":298},[1779,1780,1781],"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":1783},[1784,1790,1794,1795,1802],{"id":225,"depth":312,"text":226,"children":1785},[1786,1787,1788,1789],{"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":1791},[1792,1793],{"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":1796},[1797,1798,1799,1800],{"id":1030,"depth":319,"text":1031},{"id":1086,"depth":319,"text":1087},{"id":1134,"depth":319,"text":1135},{"id":1149,"depth":319,"text":1801},"Specify Variables using wrangler.toml/wrangler.json",{"id":1349,"depth":312,"text":1350,"children":1803},[1804],{"id":1524,"depth":319,"text":1525},"Deploy Nitro apps to Cloudflare.","md",{},{},{"title":137,"description":1805},"kt8-LnDAIBsha0HV-Vb2X110KyVI8iO9zZH8wvP-hXA",[1812,1814],{"title":133,"path":134,"stem":135,"description":1813,"children":-1},"Deploy Nitro apps to Cleavr.",{"title":141,"path":142,"stem":143,"description":1815,"children":-1},"Deploy Nitro apps to Deno Deploy.",1770282546021]