[API reference](https://evolu.dev/docs/api-reference) › [@evolu/common](https://evolu.dev/docs/api-reference/common) › [local‑first/Storage](https://evolu.dev/docs/api-reference/common/local-first/Storage) › StorageConfig

Defined in: [packages/common/src/local-first/Storage.ts:49](https://github.com/evoluhq/evolu/blob/49ea8ca499566aba270f8cb601e7f49aa62320f8/packages/common/src/local-first/Storage.ts#L49)

## Extended by

- [`RelayConfig`](https://evolu.dev/docs/api-reference/common/local-first/Relay/interfaces/RelayConfig)

## Properties

<a id="isownerwithinquota"></a>

### isOwnerWithinQuota

```ts
readonly isOwnerWithinQuota: (ownerId: string & Brand<"Id"> & Brand<"OwnerId">, requiredBytes: number & Brand<"NonNaN"> & Brand<"Finite"> & Brand<"Int"> & Brand<"NonNegative"> & Brand<"Positive">) => Awaitable<boolean>;
```

Defined in: [packages/common/src/local-first/Storage.ts:98](https://github.com/evoluhq/evolu/blob/49ea8ca499566aba270f8cb601e7f49aa62320f8/packages/common/src/local-first/Storage.ts#L98)

Callback called before an attempt to write, to check if an [OwnerId](https://evolu.dev/docs/api-reference/common/local-first/Owner/variables/OwnerId)
has sufficient quota for the write.

The callback receives the [OwnerId](https://evolu.dev/docs/api-reference/common/local-first/Owner/variables/OwnerId) and the total bytes that would be
stored after the write (current stored bytes plus incoming bytes), and
returns a [Awaitable](https://evolu.dev/docs/api-reference/common/Types/type-aliases/Awaitable) boolean: `true` to allow the write, or `false`
to deny it due to quota limits.

The callback can be synchronous (for SQLite or in-memory checks) or
asynchronous (for calling remote APIs).

The callback returns a boolean rather than an error because error handling
and logging are the responsibility of the callback implementation.

Relay deployments configure this callback. Client applications can observe
a denied relay write as a `ProtocolQuotaError` by subscribing once to the
shared `EvoluErrorDep.evoluError` store returned by `createEvoluDeps`.

### Example

```ts
import {
  createAppOwner,
  createOwnerSecret,
  createRandomBytes,
  PositiveInt,
} from "@evolu/common";

// Create once, persist the mnemonic securely, and restore it on later runs.
const appOwner = createAppOwner(
  createOwnerSecret({ randomBytes: createRandomBytes() }),
);
const maxBytes = PositiveInt.orThrow(1024);
const relayStorageConfig: StorageConfig = {
  isOwnerWithinQuota: (ownerId, requiredBytes) =>
    ownerId === appOwner.id && requiredBytes <= maxBytes,
};

expect(
  await relayStorageConfig.isOwnerWithinQuota(
    appOwner.id,
    PositiveInt.orThrow(2048),
  ),
).toBe(false);
```