# balena-settings-storage

> Balena settings storage utilities

Latest version **9.0.0** (published 2026-06-10) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install balena-settings-storage
pnpm add balena-settings-storage
yarn add balena-settings-storage
bun add balena-settings-storage
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 9.0.0 |
| Published | 2026-06-10 |
| First published | 2018-10-15 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=18.0.0 |
| Dependencies | 3 |
| Unpacked size | 79.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 4 |
| Author | Balena Ltd. |
| Maintainers | balena.io |
| Keywords | balena, data, storage, settings |

## Links

- npm: https://www.npmjs.com/package/balena-settings-storage
- Repository: https://github.com/balena-io-modules/balena-settings-storage
- Issues: https://github.com/balena-io-modules/balena-settings-storage/issues
- npm.io page: https://npm.io/package/balena-settings-storage

## Dependencies (3)

- [tslib](https://npm.io/package/tslib.md) ^2.0.0
- [@types/node](https://npm.io/package/@types/node.md) ^18.0.0
- [balena-errors](https://npm.io/package/balena-errors.md) ^5.0.0

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 9.0.0 (latest) — 2026-06-10
- 9.0.0-build-errors-v5-3ee409d39daf6172c447a4ca13969d42c39b368c-1 (build-errors-v5) — 2026-06-10
- 8.2.0-build-export-error-types-88a0de48cd1c7d24e4dee443e8c2f756b1083b82-1 (build-export-error-types) — 2026-03-24
- 8.1.1-build-add-npm-oidc-permissions-dcdd0453912e0593b9d6831cbd9d4e887c3b28eb-1 (build-add-npm-oidc-permissions) — 2026-03-12
- 8.1.0-build-data-directory-false-c6c29b01d76bbcaf8b9917ec2437cba30169ef95-1 (build-data-directory-false) — 2023-07-28
- 8.0.2-build-virtual-store-own-property-fix-285e9cf751dff296392c0bc2fd2de9e445efd79a-1 (build-virtual-store-own-property-fix) — 2023-07-28
- 8.1.0-build-data-directory-false-106b2ce73664a26a0ab3e163949b161186bcf1cc-1 (build-data-directory-false-106b2ce73664a26a0ab3e163949b161186bcf1cc) — 2023-07-27
- 8.1.0-build-data-directory-false-1b8f7a795219cee4a14cddd5e0167ded1e3de243-1 (build-data-directory-false-1b8f7a795219cee4a14cddd5e0167ded1e3de243) — 2023-07-26
- 8.0.1-build-fix-local-storage-check-190fe6ba20cb71703cc9de4376b3ba5f1618f09a-1 (build-fix-local-storage-check-190fe6ba20cb71703cc9de4376b3ba5f1618f09a) — 2023-07-26
- 8.0.0-build-browser-00400db327771795a8b14fe89c0bf0c6deb7259a-1 (build-browser-00400db327771795a8b14fe89c0bf0c6deb7259a) — 2023-07-24
- 8.0.0-build-browser-619b0f2cd003b4a35aa08b90b86c03ea0b6e8ca7-1 (build-browser-619b0f2cd003b4a35aa08b90b86c03ea0b6e8ca7) — 2023-07-24
- 8.0.0-build-browser-6a1390414ba3b228c79c28cbc172887a76039d40-1 (build-browser-6a1390414ba3b228c79c28cbc172887a76039d40) — 2023-07-24
- 8.0.0-build-browser-cd151cd730442cb2c83ff667b869f30fe314d651-1 (build-browser-cd151cd730442cb2c83ff667b869f30fe314d651) — 2023-07-24
- 7.0.3-build-flowzone-appvoyer-2bdc416bc58f5f9f244baeccb20a8bb2f1d3ebf8-1 (build-flowzone-appvoyer-2bdc416bc58f5f9f244baeccb20a8bb2f1d3ebf8) — 2023-01-19
- 7.0.3-build-flowzone-appvoyer-8971feccdd769237080f9dd69a15735c19f6a7a1-1 (build-flowzone-appvoyer-8971feccdd769237080f9dd69a15735c19f6a7a1) — 2023-01-19
- … 41 more at https://npm.io/package/balena-settings-storage/versions

## README

balena-settings-storage
----------------------

[![npm version](https://badge.fury.io/js/balena-settings-storage.svg)](http://badge.fury.io/js/balena-settings-storage)
[![dependencies](https://david-dm.org/balena-io-modules/balena-settings-storage.png)](https://david-dm.org/balena-io-modules/balena-settings-storage.png)
[![Build Status](https://travis-ci.org/balena-io-modules/balena-settings-storage.svg?branch=master)](https://travis-ci.org/balena-io-modules/balena-settings-storage)
[![Build status](https://ci.appveyor.com/api/projects/status/w9kqe2ok1rbkj42y?svg=true)](https://ci.appveyor.com/project/balena-io-modules/balena-settings-storage)

Join our online chat at [![Gitter chat](https://badges.gitter.im/balena-io/chat.png)](https://gitter.im/balena-io/chat)

Balena settings storage utilities.

Role
----

The intention of this module is to provide low level access to how balena persists settings in both the filesystem and the browser.

**THIS MODULE IS LOW LEVEL AND IS NOT MEANT TO BE USED BY END USERS DIRECTLY**.

Unless you know what you're doing, use the [balena SDK](https://github.com/balena-io/balena-sdk) instead.

Installation
------------

Install `balena-settings-storage` by running:

```sh
$ npm install --save balena-settings-storage
```

Documentation
-------------


* [storage](#module_storage)
    * [.getStorage(options)](#module_storage.getStorage) ⇒ <code>storage</code>
        * [~set(name, value)](#module_storage.getStorage..set) ⇒ <code>Promise</code>
        * [~get(name)](#module_storage.getStorage..get) ⇒ <code>Promise.&lt;\*&gt;</code>
        * [~has(name)](#module_storage.getStorage..has) ⇒ <code>Promise.&lt;Boolean&gt;</code>
        * [~remove(name)](#module_storage.getStorage..remove) ⇒ <code>Promise</code>
        * [~clear()](#module_storage.getStorage..clear) ⇒ <code>Promise</code>

<a name="module_storage.getStorage"></a>

### storage.getStorage(options) ⇒ <code>storage</code>
**Kind**: static method of [<code>storage</code>](#module_storage)  
**Summary**: Get an instance of storage module  
**Access**: public  

| Param | Type | Description |
| --- | --- | --- |
| options | <code>Object</code> | options |
| [options.dataDirectory] | <code>String</code> \| <code>False</code> | the directory to use for storage in Node.js or false to create an isolated in memory instance. Values other than false are ignored in the browser. |

**Example**  
```js
// with es6 imports
import { getStorage } from 'balena-settings-storage';
// or with node require
const { getStorage } = require('balena-settings-storage');

const storage = getStorage({
	dataDirectory: '/opt/cache/balena'
});
```

* [.getStorage(options)](#module_storage.getStorage) ⇒ <code>storage</code>
    * [~set(name, value)](#module_storage.getStorage..set) ⇒ <code>Promise</code>
    * [~get(name)](#module_storage.getStorage..get) ⇒ <code>Promise.&lt;\*&gt;</code>
    * [~has(name)](#module_storage.getStorage..has) ⇒ <code>Promise.&lt;Boolean&gt;</code>
    * [~remove(name)](#module_storage.getStorage..remove) ⇒ <code>Promise</code>
    * [~clear()](#module_storage.getStorage..clear) ⇒ <code>Promise</code>

<a name="module_storage.getStorage..set"></a>

#### getStorage~set(name, value) ⇒ <code>Promise</code>
**Kind**: inner method of [<code>getStorage</code>](#module_storage.getStorage)  
**Summary**: Set a value  
**Access**: public  

| Param | Type | Description |
| --- | --- | --- |
| name | <code>String</code> | name |
| value | <code>\*</code> | value |

**Example**  
```js
storage.set('token', '1234')
```
<a name="module_storage.getStorage..get"></a>

#### getStorage~get(name) ⇒ <code>Promise.&lt;\*&gt;</code>
**Kind**: inner method of [<code>getStorage</code>](#module_storage.getStorage)  
**Summary**: Get a value  
**Returns**: <code>Promise.&lt;\*&gt;</code> - value or undefined  
**Access**: public  

| Param | Type | Description |
| --- | --- | --- |
| name | <code>String</code> | name |

**Example**  
```js
storage.get('token').then((token) => {
	console.log(token)
});
```
<a name="module_storage.getStorage..has"></a>

#### getStorage~has(name) ⇒ <code>Promise.&lt;Boolean&gt;</code>
**Kind**: inner method of [<code>getStorage</code>](#module_storage.getStorage)  
**Summary**: Check if the value exists  
**Returns**: <code>Promise.&lt;Boolean&gt;</code> - has value  
**Access**: public  

| Param | Type | Description |
| --- | --- | --- |
| name | <code>String</code> | name |

**Example**  
```js
storage.has('token').then((hasToken) => {
	if (hasToken) {
		console.log('Yes')
	} else {
		console.log('No')
});
```
<a name="module_storage.getStorage..remove"></a>

#### getStorage~remove(name) ⇒ <code>Promise</code>
**Kind**: inner method of [<code>getStorage</code>](#module_storage.getStorage)  
**Summary**: Remove a value  
**Access**: public  

| Param | Type | Description |
| --- | --- | --- |
| name | <code>String</code> | name |

**Example**  
```js
storage.remove('token')
```
<a name="module_storage.getStorage..clear"></a>

#### getStorage~clear() ⇒ <code>Promise</code>
**Kind**: inner method of [<code>getStorage</code>](#module_storage.getStorage)  
**Summary**: Remove all values  
**Access**: public  
**Example**  
```js
storage.clear()
```

Support
-------

If you're having any problem, please [raise an issue](https://github.com/balena-io-modules/balena-settings-storage/issues/new) on GitHub and the balena team will be happy to help.

Tests
-----

Run the test suite by doing:

```sh
$ npm test
```

Contribute
----------

- Issue Tracker: [github.com/balena-io-modules/balena-settings-storage/issues](https://github.com/balena-io-modules/balena-settings-storage/issues)
- Source Code: [github.com/balena-io-modules/balena-settings-storage](https://github.com/balena-io-modules/balena-settings-storage)

Before submitting a PR, please make sure that you include tests, and that [coffeelint](http://www.coffeelint.org/) runs without any warning:

```sh
$ npm run lint
```

License
-------

The project is licensed under the Apache 2.0 license.

---
_Source: https://npm.io/package/balena-settings-storage · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
