---
name: "setStorageSync"
mode: "kit"
versionRequirements:
  - { name: "BaseKit", version: "2.0.1" }
platform:
  - "iOS"
  - "Android"
---

## setStorageSync

> [VERSION] BaseKit >= 2.0.1

> [PLATFORM] iOS, Android

### Description

Store data in local storage under the specified key. Overwrites any existing content for that key. Data remains available unless explicitly deleted by the user or cleared by the system due to storage constraints. Maximum size per key is 1MB; total storage limit is 10MB.

### Parameters

`Params`

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `storageDataBean` | `StorageDataBean` | No | - | Parameter object |

### Referenced Types

##### `interface` StorageDataBean

| Property | Type | Since | Description |
| --- | --- | --- | --- |
| `key` | `string` | `2.0.1` | Specified key in local storage |
| `data` | `string` | `2.0.1` | Value for the key |


### Examples

```tsx
// Write data to local storage for the specified key (overwrites existing content)
ty.setStorage({
  key: "demoKey",
  data: "demoValue",
  success: () => console.log("Written"),
  fail: error => console.error(error),
});
```
