# @storyshelf/storage-local

> Store StoryShelf screenshots, diffs, and Storybook archives on a local filesystem.

Source: https://storyshelf.js.org/packages/storage-local/

`@storyshelf/storage-local` is the default blob storage adapter for a single-node deployment. It stores screenshots, diff overlays, and uploaded Storybook archives below one data directory.

## Install

```sh
npm i @storyshelf/storage-local
```

[![JSR](https://jsr.io/badges/@storyshelf/storage-local)](https://jsr.io/@storyshelf/storage-local) [![JSR Score](https://jsr.io/badges/@storyshelf/storage-local/score)](https://jsr.io/@storyshelf/storage-local)

- [npm package](https://www.npmjs.com/package/@storyshelf/storage-local) — install tarballs and version history.
- [JSR package](https://jsr.io/@storyshelf/storage-local) — TypeScript-first registry page.
- [Public API reference](https://storyshelf.js.org/reference/storage-local/) — generated docs for every export; start here to learn the API. (The same reference is on [JSR](https://jsr.io/@storyshelf/storage-local/doc).)
- [Source on GitHub](https://github.com/GuptaSiddhant/storyshelf/tree/main/packages/storage-local) — package directory on `main`.

## Configure

```ts
import { createLocalStorage } from "@storyshelf/storage-local";
import { createShelfApp } from "@storyshelf/app";
import { createSqliteDatabase } from "@storyshelf/db-sqlite";

const storage = createLocalStorage("./data");
const database = createSqliteDatabase("./data/shelf.db");

const app = createShelfApp({ database, storage });
```

### `createLocalStorage(dataDir: string): StorageAdapter`

Stores all blobs under the resolved `dataDir` (creating directories as needed). Paths are confined to the data directory — any path escaping it throws an error.

The returned adapter implements every method of the `StorageAdapter` interface (`read`, `write`, `delete`, `exists`, `list(prefix)`).

## When to use it

Use local storage with [SQLite](../db-sqlite/) for a simple single-node deployment. For cloud or multi-node deployments where instances need shared objects, switch to [S3 storage](../storage-s3/) without changing the core router.
