> ## Documentation Index
> Fetch the complete documentation index at: https://www.dynamic.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Storage

> Use regular and secure Storage from DynamicCore in your JavaScript SDK extension.

The `Storage` service on `DynamicCore` provides type-safe, schema-backed persistence. Use `storageTier: "default"` for regular storage and `storageTier: "secure"` for secure storage on supported platforms.

## Define storage keys

```typescript theme={"system"}
import { getCore, createStorageKeySchema } from "@dynamic-labs-sdk/client/core";
import * as z from "zod/mini";

const client = getDefaultClient();

const regularSchema = createStorageKeySchema({
  key: "my-extension-config",
  schema: z.string(),
  config: { storageTier: "default" },
});

const secureSchema = createStorageKeySchema({
  key: "my-extension-secret",
  schema: z.string(),
  config: { storageTier: "secure" },
});
```

## Read, write, and remove

```typescript theme={"system"}
const value = await getCore(client).storage.getItem(regularSchema);
await getCore(client).storage.setItem(regularSchema, "hello");
await getCore(client).storage.removeItem(secureSchema);
```

## When to use secure storage

Secure storage delegates to platform-specific stores such as iOS Keychain, Android `EncryptedSharedPreferences` / Keychain (via `react-native-keychain`), or other secure adapters. Use it for secrets such as API keys, tokens, or private key material.

Prefer `storageTier: "default"` for non-sensitive values. Default storage uses `localStorage` in browsers and `AsyncStorage` in React Native. It is faster, does not require platform entitlements, and is always available. Default storage is also easier to inspect during development.

Secure storage has tradeoffs:

* It is usually slower because it calls platform secure APIs.
* It may require OS permissions, entitlements, or user authentication, depending on the platform and adapter.
* It is not universally available; for example, the browser `localStorage` adapter does not provide a secure tier. Use it only where a secure adapter is configured for your platform.
* Values are opaque to the OS secure store, so debugging and migration can be harder.

Reserve `secure` for values that must be protected from other apps or processes. Use `default` for configuration, flags, and other non-sensitive extension state.
