[{"data":1,"prerenderedAt":858},["ShallowReactive",2],{"navigation":3,"-docs-storage":217,"-docs-storage-surround":854},[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":848,"extension":849,"meta":850,"navigation":851,"path":69,"seo":852,"stem":70,"__hash__":853},"content/1.docs/8.storage.md",{"type":220,"value":221,"toc":843,"icon":71},"minimark",[222,229,240,245,261,545,548,551,558,561,640,647,658,662,669,829,839],[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 { defineNitroPlugin, useStorage } from \"nitro/storage\";\nimport redisDriver from \"unstorage/drivers/redis\";\n\nexport default defineNitroPlugin(() => {\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,688,702,706,724,739,743,748,762,771,781,791,796,801,805,810,825],{"__ignoreMap":5},[270,676,677,679,682,684,686],{"class":272,"line":273},[270,678,277],{"class":276},[270,680,681],{"class":280}," { defineNitroPlugin, useStorage } ",[270,683,284],{"class":276},[270,685,288],{"class":287},[270,687,291],{"class":280},[270,689,690,692,695,697,700],{"class":272,"line":294},[270,691,277],{"class":276},[270,693,694],{"class":280}," redisDriver ",[270,696,284],{"class":276},[270,698,699],{"class":287}," \"unstorage/drivers/redis\"",[270,701,291],{"class":280},[270,703,704],{"class":272,"line":301},[270,705,298],{"emptyLinePlaceholder":297},[270,707,708,710,712,715,718,721],{"class":272,"line":308},[270,709,589],{"class":276},[270,711,592],{"class":276},[270,713,714],{"class":314}," defineNitroPlugin",[270,716,717],{"class":280},"(() ",[270,719,720],{"class":276},"=>",[270,722,723],{"class":280}," {\n",[270,725,726,729,732,734,736],{"class":272,"line":339},[270,727,728],{"class":276},"  const",[270,730,731],{"class":375}," storage",[270,733,379],{"class":276},[270,735,315],{"class":314},[270,737,738],{"class":280},"()\n",[270,740,741],{"class":272,"line":358},[270,742,298],{"emptyLinePlaceholder":297},[270,744,745],{"class":272,"line":363},[270,746,747],{"class":304},"  // Dynamically pass in credentials from runtime configuration, or other sources\n",[270,749,750,752,755,757,760],{"class":272,"line":369},[270,751,728],{"class":276},[270,753,754],{"class":375}," driver",[270,756,379],{"class":276},[270,758,759],{"class":314}," redisDriver",[270,761,598],{"class":280},[270,763,764,767,769],{"class":272,"line":391},[270,765,766],{"class":280},"    base: ",[270,768,616],{"class":287},[270,770,619],{"class":280},[270,772,773,776,779],{"class":272,"line":414},[270,774,775],{"class":280},"    host: process.env.",[270,777,778],{"class":375},"REDIS_HOST",[270,780,619],{"class":280},[270,782,783,786,789],{"class":272,"line":434},[270,784,785],{"class":280},"    port: process.env.",[270,787,788],{"class":375},"REDIS_PORT",[270,790,619],{"class":280},[270,792,793],{"class":272,"line":439},[270,794,795],{"class":304},"    /* other redis connector options */\n",[270,797,798],{"class":272,"line":445},[270,799,800],{"class":280},"  })\n",[270,802,803],{"class":272,"line":472},[270,804,298],{"emptyLinePlaceholder":297},[270,806,807],{"class":272,"line":477},[270,808,809],{"class":304},"  // Mount driver\n",[270,811,812,815,818,820,822],{"class":272,"line":483},[270,813,814],{"class":280},"  storage.",[270,816,817],{"class":314},"mount",[270,819,324],{"class":280},[270,821,616],{"class":287},[270,823,824],{"class":280},", driver)\n",[270,826,827],{"class":272,"line":518},[270,828,639],{"class":280},[223,830,831],{},[226,832,833,834,668],{},"This is a temporary workaround, with a better solution coming in the future! Keep a lookout on the GitHub issue ",[233,835,838],{"href":836,"rel":837},"https://github.com/nitrojs/nitro/issues/1161#issuecomment-1511444675",[237],"here",[840,841,842],"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":844},[845,846,847],{"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":848},"N8PqNxP9Wd7Yk2zfk7fMMTwVjPmzs4EwktOQl7BLrPU",[855,857],{"title":63,"path":64,"stem":65,"description":856,"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},1764005906107]