
# Storage

> Configure KV storage, cache, and database connections.

::note
All examples on this page assume the following import in `nitro.config.ts`:

```ts
import { defineConfig } from "nitro";
```
::

### `kv`

- Default: `{}`{lang=ts}

KV storage configuration.

```ts
export default defineConfig({
  kv: {
    redis: {
      driver: "redis",
      url: "redis://localhost:6379",
    },
  },
});
```

Use the `$development` key to override mounts during development:

```ts
export default defineConfig({
  $development: {
    kv: {
      redis: {
        driver: "fs",
        base: "./data/redis", // use filesystem in development
      },
    },
  },
});
```

`$development` only applies to the development server. Use `$prerender` to override mounts while prerendering. A mount with a different `driver` replaces the whole mount, and one with the same `driver` has its options deep merged.

::note
Previously named `storage`, which still works as a deprecated alias. The deprecated `devStorage` option is replaced by `kv` inside `$development` (and `$prerender`).
::

:read-more{to="/docs/storage"}

### `cache`

- Default: `{}`{lang=ts}

Cache storage and global default options for [cached functions, handlers](/docs/cache) and `cache` route rules.

```ts
export default defineConfig({
  cache: {
    driver: "fs", // "memory" (default) | "fs" | "kv"
    fs: { dir: ".data/cache" },
    defaults: { maxAge: 60, swr: true },
  },
});
```

- `driver`: `memory` (in-process LRU), `fs` (filesystem, Node.js compatible runtimes only) or `kv` (the [`kv`](#kv) storage layer). Defaults to `kv` when a `cache` KV mount point is configured, and `memory` otherwise.
- `memory`: `maxSize` and `maxBytes` limits of the `memory` driver.
- `fs`: `dir` of the `fs` driver (defaults to `.data/cache`).
- `defaults`: global default options for every cache (`maxAge`, `swr`, `staleMaxAge`, `maxResolveTime`, `base`, and handler-only `varies`, `allowQuery`, `allowCookies`, `allowAuthorization`, `sendCacheControl`, `cacheStatusHeader`, `maxBodySize`).

:read-more{to="/docs/cache#cache-storage"}

### `database`

Database connection configurations. Requires `experimental.database: true`.

```ts
export default defineConfig({
  database: {
    default: {
      connector: "sqlite",
      options: { name: "db" },
    },
  },
});
```

:read-more{to="/docs/database"}

### `devDatabase`

Database connection configuration overrides for development mode.

```ts
export default defineConfig({
  devDatabase: {
    default: {
      connector: "sqlite",
      options: { name: "db-dev" }, // separate dev database
    },
  },
});
```
