# Save to Local Storage

With the Save to Local Storage action, you can save values in the browser's local storage. \
This is useful when you want to share the same value between multiple pages, like user token or user preferences. The saved value is available as `{{localStorage.<key>}}` in all actions and components.

To configure the action, you need to specify your variable's name as this name will be used to access the value in the local storage. Then, you need to pass the data you want to save in the *New value* field.

<figure><img src="https://837703843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUX6zPRMFFK0yrTghj7cY%2Fuploads%2F73sypHL5fZSrhwyWPoWM%2FCleanShot%202025-05-21%20at%2013.59.23%402x-min.png?alt=media&#x26;token=e3f2c390-bf2c-48b9-9f5b-3ec89af1fb93" alt=""><figcaption></figcaption></figure>

## Examples

### Saving the result of the previous step

```javascript
{{data.token}}
```

You can always adjust the data before saving it.

### Adding additional values

```javascript
const values = {{ui.form.value}};

return {
  ...values,
  created_at: new Date(),
}Jav
```

{% hint style="warning" %}
The `created_at` column must exist in the table schema, otherwise it won't be sent.
{% endhint %}

### Changing values

```javascript
const values = {{ui.form.value}};
return {
  ...values,
  name: values.name.toUpperCase(),
}
```

### Deleting unwanted values

```javascript
const values = {{ui.form.value}};
delete values.age;
return values;
```

alternatively:

```javascript
const values = {{ui.form.value}};
const { created_at, ...rest } = values;
return rest;
```

### Joining array values

```javascript
const values = {{ui.form.value}};
return {
  ...values,
  tags: values.tags.join(','),
}
```

### Using default values

```javascript
const values = {{ui.form.value}};
return {
  ...values,
  // if the value is not set, use the default value
  created_at: values.created_at || new Date(),
}
```

***

More information on `localStorage` you can find here :point\_down:

{% content-ref url="../../concepts/localstorage" %}
[localstorage](https://docs.uibakery.io/concepts/localstorage)
{% endcontent-ref %}
