---
title: Keychain
description: Secure storage for credentials.
---

Secure storage for credentials.

The keychain is a secure storage for credentials, keys etc. Use the `set()` method to add values to the keychain. You can then later use the `get()` method to retrieve the value.

## Methods

<span id="contains" class="api-anchor"></span>

### contains(key)

Check if keychain contains a key.

```typescript
static contains(key: string): bool
```

Checks if the keychain contains the specified key.

#### Parameters

**`key` `string`**

Key to look up in the keychain.

#### Return value

**`bool`**

True if the key exists in the keychain, otherwise false.

<span id="get" class="api-anchor"></span>

### get(key)

Reads a value from the keychain.

```typescript
static get(key: string): string
```

Reads the value for the specified key. If the key doesn't exist the method will throw an error. Used the `contains` method to check if a key exists in the keychain.

#### Parameters

**`key` `string`**

Key to read value for.

#### Return value

**`string`**

Value assigned to the specified key.

<span id="remove" class="api-anchor"></span>

### remove(key)

Remove key from keychain.

```typescript
static remove(key: string)
```

#### Parameters

**`key` `string`**

Key to remove from the keychain.

<span id="set" class="api-anchor"></span>

### set(key, value)

Add value for a specified key to keychain.

```typescript
static set(key: string, value: string)
```

Adds the value to the keychain, assigning it to the specified key. If the key already exists in the keychain, the value is overwritten.

Values are securely stored in an encrypted database.

#### Parameters

**`key` `string`**

Key which the value should be assigned to.

**`value` `string`**

Value to assign to the specified key.