[{"data":1,"prerenderedAt":872},["ShallowReactive",2],{"navigation":3,"-docs-storage":217,"-docs-storage-surround":868},[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":68,"body":219,"description":862,"extension":863,"meta":864,"navigation":865,"path":69,"seo":866,"stem":70,"__hash__":867},"content/1.docs/8.storage.md",{"type":220,"value":221,"toc":857,"icon":71},"minimark",[222,229,240,245,261,545,548,551,558,561,640,647,658,662,669,843,853],[223,224,225],"warning",{},[226,227,228],"p",{},"Nitro v3 Alpha docs are a work in progress — expect updates, rough edges, and occasional inaccuracies.",[226,230,231,232,239],{},"Nitro has built-in integration with ",[233,234,238],"a",{"href":235,"rel":236},"https://unstorage.unjs.io",[237],"nofollow","unstorage"," to provide a runtime agnostic persistent layer.",[241,242,244],"h2",{"id":243},"usage","Usage",[226,246,247,248,252,253,256,257,260],{},"To use the storage layer, you can use the ",[249,250,251],"code",{},"useStorage()"," and call ",[249,254,255],{},"get(key)"," to retrieve an item and ",[249,258,259],{},"set(key, value)"," to set an item.",[262,263,267],"pre",{"className":264,"code":265,"language":266,"meta":5,"style":5},"language-ts shiki shiki-themes github-light github-dark github-dark","import { useStorage } from \"nitro/storage\";\n\n// Default storage is in memory\nawait useStorage().set(\"test:foo\", { hello: \"world\" })\nawait useStorage().get(\"test:foo\")\n\n// You can use data storage to write data to default .data/kv directory\nconst dataStorage = useStorage(\"data\")\nawait dataStorage.set(\"test\", \"works\")\nawait dataStorage.get(\"data:test\") // Value persists\n\n// You can also specify the base in useStorage(base)\nawait useStorage(\"test\").set(\"foo\", { hello: \"world\" })\n\n// You can use generics to define types\nawait useStorage\u003C{ hello: string }>(\"test\").get(\"foo\")\nawait useStorage(\"test\").get\u003C{ hello: string }>(\"foo\")\n","ts",[249,268,269,292,299,306,337,356,361,367,389,412,432,437,443,470,475,481,516],{"__ignoreMap":5},[270,271,274,278,282,285,289],"span",{"class":272,"line":273},"line",1,[270,275,277],{"class":276},"so5gQ","import",[270,279,281],{"class":280},"slsVL"," { useStorage } ",[270,283,284],{"class":276},"from",[270,286,288],{"class":287},"sfrk1"," \"nitro/storage\"",[270,290,291],{"class":280},";\n",[270,293,295],{"class":272,"line":294},2,[270,296,298],{"emptyLinePlaceholder":297},true,"\n",[270,300,302],{"class":272,"line":301},3,[270,303,305],{"class":304},"sCsY4","// Default storage is in memory\n",[270,307,309,312,316,319,322,325,328,331,334],{"class":272,"line":308},4,[270,310,311],{"class":276},"await",[270,313,315],{"class":314},"shcOC"," useStorage",[270,317,318],{"class":280},"().",[270,320,321],{"class":314},"set",[270,323,324],{"class":280},"(",[270,326,327],{"class":287},"\"test:foo\"",[270,329,330],{"class":280},", { hello: ",[270,332,333],{"class":287},"\"world\"",[270,335,336],{"class":280}," })\n",[270,338,340,342,344,346,349,351,353],{"class":272,"line":339},5,[270,341,311],{"class":276},[270,343,315],{"class":314},[270,345,318],{"class":280},[270,347,348],{"class":314},"get",[270,350,324],{"class":280},[270,352,327],{"class":287},[270,354,355],{"class":280},")\n",[270,357,359],{"class":272,"line":358},6,[270,360,298],{"emptyLinePlaceholder":297},[270,362,364],{"class":272,"line":363},7,[270,365,366],{"class":304},"// You can use data storage to write data to default .data/kv directory\n",[270,368,370,373,377,380,382,384,387],{"class":272,"line":369},8,[270,371,372],{"class":276},"const",[270,374,376],{"class":375},"suiK_"," dataStorage",[270,378,379],{"class":276}," =",[270,381,315],{"class":314},[270,383,324],{"class":280},[270,385,386],{"class":287},"\"data\"",[270,388,355],{"class":280},[270,390,392,394,397,399,401,404,407,410],{"class":272,"line":391},9,[270,393,311],{"class":276},[270,395,396],{"class":280}," dataStorage.",[270,398,321],{"class":314},[270,400,324],{"class":280},[270,402,403],{"class":287},"\"test\"",[270,405,406],{"class":280},", ",[270,408,409],{"class":287},"\"works\"",[270,411,355],{"class":280},[270,413,415,417,419,421,423,426,429],{"class":272,"line":414},10,[270,416,311],{"class":276},[270,418,396],{"class":280},[270,420,348],{"class":314},[270,422,324],{"class":280},[270,424,425],{"class":287},"\"data:test\"",[270,427,428],{"class":280},") ",[270,430,431],{"class":304},"// Value persists\n",[270,433,435],{"class":272,"line":434},11,[270,436,298],{"emptyLinePlaceholder":297},[270,438,440],{"class":272,"line":439},12,[270,441,442],{"class":304},"// You can also specify the base in useStorage(base)\n",[270,444,446,448,450,452,454,457,459,461,464,466,468],{"class":272,"line":445},13,[270,447,311],{"class":276},[270,449,315],{"class":314},[270,451,324],{"class":280},[270,453,403],{"class":287},[270,455,456],{"class":280},").",[270,458,321],{"class":314},[270,460,324],{"class":280},[270,462,463],{"class":287},"\"foo\"",[270,465,330],{"class":280},[270,467,333],{"class":287},[270,469,336],{"class":280},[270,471,473],{"class":272,"line":472},14,[270,474,298],{"emptyLinePlaceholder":297},[270,476,478],{"class":272,"line":477},15,[270,479,480],{"class":304},"// You can use generics to define types\n",[270,482,484,486,488,491,495,498,501,504,506,508,510,512,514],{"class":272,"line":483},16,[270,485,311],{"class":276},[270,487,315],{"class":314},[270,489,490],{"class":280},"\u003C{ ",[270,492,494],{"class":493},"sQHwn","hello",[270,496,497],{"class":276},":",[270,499,500],{"class":375}," string",[270,502,503],{"class":280}," }>(",[270,505,403],{"class":287},[270,507,456],{"class":280},[270,509,348],{"class":314},[270,511,324],{"class":280},[270,513,463],{"class":287},[270,515,355],{"class":280},[270,517,519,521,523,525,527,529,531,533,535,537,539,541,543],{"class":272,"line":518},17,[270,520,311],{"class":276},[270,522,315],{"class":314},[270,524,324],{"class":280},[270,526,403],{"class":287},[270,528,456],{"class":280},[270,530,348],{"class":314},[270,532,490],{"class":280},[270,534,494],{"class":493},[270,536,497],{"class":276},[270,538,500],{"class":375},[270,540,503],{"class":280},[270,542,463],{"class":287},[270,544,355],{"class":280},[546,547],"read-more",{"to":235},[241,549,33],{"id":550},"configuration",[226,552,553,554,557],{},"You can mount one or multiple custom storage drivers using the ",[249,555,556],{},"storage"," option.",[226,559,560],{},"The key is the mount point name, and the value is the driver name and configuration.",[262,562,565],{"className":264,"code":563,"filename":564,"language":266,"meta":5,"style":5},"import { defineNitroConfig } from \"nitro/config\";\n\nexport default defineNitroConfig({\n  storage: {\n    redis: {\n      driver: \"redis\",\n      /* redis connector options */\n    }\n  }\n})\n","nitro.config.ts",[249,566,567,581,585,599,604,609,620,625,630,635],{"__ignoreMap":5},[270,568,569,571,574,576,579],{"class":272,"line":273},[270,570,277],{"class":276},[270,572,573],{"class":280}," { defineNitroConfig } ",[270,575,284],{"class":276},[270,577,578],{"class":287}," \"nitro/config\"",[270,580,291],{"class":280},[270,582,583],{"class":272,"line":294},[270,584,298],{"emptyLinePlaceholder":297},[270,586,587,590,593,596],{"class":272,"line":301},[270,588,589],{"class":276},"export",[270,591,592],{"class":276}," default",[270,594,595],{"class":314}," defineNitroConfig",[270,597,598],{"class":280},"({\n",[270,600,601],{"class":272,"line":308},[270,602,603],{"class":280},"  storage: {\n",[270,605,606],{"class":272,"line":339},[270,607,608],{"class":280},"    redis: {\n",[270,610,611,614,617],{"class":272,"line":358},[270,612,613],{"class":280},"      driver: ",[270,615,616],{"class":287},"\"redis\"",[270,618,619],{"class":280},",\n",[270,621,622],{"class":272,"line":363},[270,623,624],{"class":304},"      /* redis connector options */\n",[270,626,627],{"class":272,"line":369},[270,628,629],{"class":280},"    }\n",[270,631,632],{"class":272,"line":391},[270,633,634],{"class":280},"  }\n",[270,636,637],{"class":272,"line":414},[270,638,639],{"class":280},"})\n",[226,641,642,643,646],{},"Then, you can use the redis storage using the ",[249,644,645],{},"useStorage(\"redis\")"," function.",[546,648,650],{"to":649},"https://unstorage.unjs.io/",[226,651,652,653,657],{},"You can find the driver list on ",[233,654,656],{"href":649,"rel":655},[237],"unstorage documentation"," with their configuration.",[241,659,661],{"id":660},"runtime-configuration","Runtime configuration",[226,663,664,665,668],{},"In scenarios where the mount point configuration is not known until runtime, Nitro can dynamically add mount points during startup using ",[233,666,667],{"href":49},"plugins",".",[262,670,673],{"className":264,"code":671,"filename":672,"language":266,"meta":5,"style":5},"import { useStorage } from \"nitro/storage\";\nimport { definePlugin } from \"nitro\";\nimport redisDriver from \"unstorage/drivers/redis\";\n\nexport default definePlugin(() => {\n  const storage = useStorage()\n\n  // Dynamically pass in credentials from runtime configuration, or other sources\n  const driver = redisDriver({\n    base: \"redis\",\n    host: process.env.REDIS_HOST,\n    port: process.env.REDIS_PORT,\n    /* other redis connector options */\n  })\n\n  // Mount driver\n  storage.mount(\"redis\", driver)\n})\n","plugins/storage.ts",[249,674,675,687,701,715,719,737,752,756,761,775,784,794,804,809,814,818,823,838],{"__ignoreMap":5},[270,676,677,679,681,683,685],{"class":272,"line":273},[270,678,277],{"class":276},[270,680,281],{"class":280},[270,682,284],{"class":276},[270,684,288],{"class":287},[270,686,291],{"class":280},[270,688,689,691,694,696,699],{"class":272,"line":294},[270,690,277],{"class":276},[270,692,693],{"class":280}," { definePlugin } ",[270,695,284],{"class":276},[270,697,698],{"class":287}," \"nitro\"",[270,700,291],{"class":280},[270,702,703,705,708,710,713],{"class":272,"line":301},[270,704,277],{"class":276},[270,706,707],{"class":280}," redisDriver ",[270,709,284],{"class":276},[270,711,712],{"class":287}," \"unstorage/drivers/redis\"",[270,714,291],{"class":280},[270,716,717],{"class":272,"line":308},[270,718,298],{"emptyLinePlaceholder":297},[270,720,721,723,725,728,731,734],{"class":272,"line":339},[270,722,589],{"class":276},[270,724,592],{"class":276},[270,726,727],{"class":314}," definePlugin",[270,729,730],{"class":280},"(() ",[270,732,733],{"class":276},"=>",[270,735,736],{"class":280}," {\n",[270,738,739,742,745,747,749],{"class":272,"line":358},[270,740,741],{"class":276},"  const",[270,743,744],{"class":375}," storage",[270,746,379],{"class":276},[270,748,315],{"class":314},[270,750,751],{"class":280},"()\n",[270,753,754],{"class":272,"line":363},[270,755,298],{"emptyLinePlaceholder":297},[270,757,758],{"class":272,"line":369},[270,759,760],{"class":304},"  // Dynamically pass in credentials from runtime configuration, or other sources\n",[270,762,763,765,768,770,773],{"class":272,"line":391},[270,764,741],{"class":276},[270,766,767],{"class":375}," driver",[270,769,379],{"class":276},[270,771,772],{"class":314}," redisDriver",[270,774,598],{"class":280},[270,776,777,780,782],{"class":272,"line":414},[270,778,779],{"class":280},"    base: ",[270,781,616],{"class":287},[270,783,619],{"class":280},[270,785,786,789,792],{"class":272,"line":434},[270,787,788],{"class":280},"    host: process.env.",[270,790,791],{"class":375},"REDIS_HOST",[270,793,619],{"class":280},[270,795,796,799,802],{"class":272,"line":439},[270,797,798],{"class":280},"    port: process.env.",[270,800,801],{"class":375},"REDIS_PORT",[270,803,619],{"class":280},[270,805,806],{"class":272,"line":445},[270,807,808],{"class":304},"    /* other redis connector options */\n",[270,810,811],{"class":272,"line":472},[270,812,813],{"class":280},"  })\n",[270,815,816],{"class":272,"line":477},[270,817,298],{"emptyLinePlaceholder":297},[270,819,820],{"class":272,"line":483},[270,821,822],{"class":304},"  // Mount driver\n",[270,824,825,828,831,833,835],{"class":272,"line":518},[270,826,827],{"class":280},"  storage.",[270,829,830],{"class":314},"mount",[270,832,324],{"class":280},[270,834,616],{"class":287},[270,836,837],{"class":280},", driver)\n",[270,839,841],{"class":272,"line":840},18,[270,842,639],{"class":280},[223,844,845],{},[226,846,847,848,668],{},"This is a temporary workaround, with a better solution coming in the future! Keep a lookout on the GitHub issue ",[233,849,852],{"href":850,"rel":851},"https://github.com/nitrojs/nitro/issues/1161#issuecomment-1511444675",[237],"here",[854,855,856],"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 .sCsY4, html code.shiki .sCsY4{--shiki-light:#6A737D;--shiki-default:#6A737D;--shiki-dark:#6A737D}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 pre.shiki code .sQHwn, html code.shiki .sQHwn{--shiki-light:#E36209;--shiki-default:#FFAB70;--shiki-dark:#FFAB70}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);}",{"title":5,"searchDepth":294,"depth":294,"links":858},[859,860,861],{"id":243,"depth":294,"text":244},{"id":550,"depth":294,"text":33},{"id":660,"depth":294,"text":661},"Nitro provides a built-in storage layer that can abstract filesystem or database or any other data source.","md",{"icon":71},{"icon":71},{"title":68,"description":862},"sVZTXrRh3gxOPAYGtQed3ThD2w6LMdGsJHdf6N_se6U",[869,871],{"title":63,"path":64,"stem":65,"description":870,"icon":66,"children":-1},"Nitro provides a caching system built on top of the storage layer.",{"title":73,"path":74,"stem":75,"description":5,"icon":76,"children":-1},1770282543486]