Storage
The storage APIs can be used to store data in Raycast's local encrypted database.
All commands in an extension have shared access to the stored data. Extensions can not access the storage of other extensions.
Values can be managed through functions such as LocalStorage.getItem
, LocalStorage.setItem
, or LocalStorage.removeItem
. A typical use case is storing user-related data, for example entered todos.
The API is not meant to store large amounts of data. For this, use Node's built-in APIs to write files, e.g. to the extension's support directory.
API Reference
LocalStorage.getItem
Retrieve the stored value for the given key.
Signature
Example
Parameters
Name | Description | Type |
---|---|---|
key* | The key you want to retrieve the value of. |
|
Return
A Promise that resolves with the stored value for the given key. If the key does not exist, undefined
is returned.
LocalStorage.setItem
Stores a value for the given key.
Signature
Example
Parameters
Name | Description | Type |
---|---|---|
key* | The key you want to create or update the value of. |
|
value* | The value you want to create or update for the given key. |
Return
A Promise that resolves when the value is stored.
LocalStorage.removeItem
Removes the stored value for the given key.
Signature
Example
Parameters
Name | Description | Type |
---|---|---|
key* | The key you want to remove the value of. |
|
Return
A Promise that resolves when the value is removed.
LocalStorage.allItems
Retrieve all stored values in the local storage of an extension.
Signature
Example
Return
A Promise that resolves with an object containing all Values.
LocalStorage.clear
Removes all stored values of an extension.
Signature
Example
Return
A Promise that resolves when all values are removed.
Types
LocalStorage.Values
Values of local storage items.
For type-safe values, you can define your own interface. Use the keys of the local storage items as the property names.
Properties
Name | Type | Description |
---|---|---|
[key: string] |
| The local storage value of a given key. |
LocalStorage.Value
Supported storage value types.
Example
Last updated