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.

Examples

Saving the result of the previous step

{{data.token}}

You can always adjust the data before saving it.

Adding additional values

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

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

Changing values

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

Deleting unwanted values

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

alternatively:

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

Joining array values

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

Using default values

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 πŸ‘‡

Local storage

Last updated

Was this helpful?