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