---
description: Securely store key/value pairs such as passwords, tokens or other sensitive information in your Capacitor app.
title: Announcing the Secure Preferences Plugin for Capacitor - Capawesome
image: https://capawesome.io/docs/assets/images/social/blog/announcing-the-capacitor-secure-preferences-plugin.png
---

[ Skip to content](#announcing-the-capacitor-secure-preferences-plugin) 

[ 🎉 Introducing **Capawesome Platform** — one platform for Live Updates, Native Builds, App Store Publishing, and Insider SDKs.](https://capawesome.io) 

* [  Formbricks ](/docs/plugins/formbricks/)
* [  Geocoder ](/docs/plugins/geocoder/)
* [  Google Sign-In ](/docs/plugins/google-sign-in/)
* [  libSQL ](/docs/plugins/libsql/)
* [  Live Update ](/docs/plugins/live-update/)
* [  Managed Configurations ](/docs/plugins/managed-configurations/)
* [  Media Session ](/docs/plugins/media-session/)
* [  ML Kit ](/docs/plugins/mlkit/)
* [  NFC ](/docs/plugins/nfc/)
* [  OAuth ](/docs/plugins/oauth/)
* [  Pedometer ](/docs/plugins/pedometer/)
* [  Photo Editor ](/docs/plugins/photo-editor/)
* [  PostHog ](/docs/plugins/posthog/)
* [  Printer ](/docs/plugins/printer/)
* [  Purchases ](/docs/plugins/purchases/)
* [  RealtimeKit ](/docs/plugins/realtimekit/)
* [  Screen Orientation ](/docs/plugins/screen-orientation/)
* [  Screenshot ](/docs/plugins/screenshot/)
* [  Secure Preferences ](/docs/plugins/secure-preferences/)
* [  Speech Recognition ](/docs/plugins/speech-recognition/)
* [  Speech Synthesis ](/docs/plugins/speech-synthesis/)
* [  Share Target ](/docs/plugins/share-target/)
* [  Square Mobile Payments ](/docs/plugins/square-mobile-payments/)
* [  SQLite ](/docs/plugins/sqlite/)
* [  Superwall ](/docs/plugins/superwall/)
* [  Torch ](/docs/plugins/torch/)
* [  Wifi ](/docs/plugins/wifi/)
* [  Zip ](/docs/plugins/zip/)
* [  Cloud ](/docs/cloud/)
* [  Live Updates ](/docs/cloud/live-updates/)
* Advanced
* Integrations
* [  Native Builds ](/docs/cloud/native-builds/)
* [  Configuration ](/docs/cloud/native-builds/configuration/)
* [  Environments ](/docs/cloud/native-builds/environments/)
* Guides
* [  Sample Projects ](/docs/cloud/native-builds/sample-projects/)
* [  Troubleshooting ](/docs/cloud/native-builds/troubleshooting/)
* [  Automations ](/docs/cloud/automations/)
* Account
* Organizations
* [  Organization and User Management ](/docs/cloud/organizations/memberships/)
* [  Single Sign-On (SSO) ](/docs/cloud/organizations/sso/)
* [  Teams ](/docs/cloud/organizations/teams/)
* [  Two-Factor Authentication ](/docs/cloud/organizations/two-factor-authentication/)
* [  Integrations ](/docs/cloud/integrations/)
* [  License Keys ](/docs/cloud/license-keys/)
* [  Webhooks ](/docs/cloud/webhooks/)
* [  Pricing ](https://capawesome.io/pricing/)
* [  FAQ ](/docs/cloud/faq/)
* [  Support ](/docs/cloud/support/)
* [  Contributing ](/docs/contributing/)
* [  LLMs ](/docs/llms/)
* [  Insiders ](/docs/insiders/)
* [  License ](https://capawesome.io/legal/eula/)
* [  Support ](/docs/insiders/support/)
* [  FAQ ](/docs/insiders/faq/)
* [  Blog ](/blog/)
* Categories

* [  Conclusion ](#conclusion)

* Related links

# Announcing the Capacitor Secure Preferences Plugin[¶](#announcing-the-capacitor-secure-preferences-plugin "Permanent link")

Today we are excited to announce our brand new [Capacitor Secure Preferences](/docs/plugins/secure-preferences/) plugin. This plugin is a drop-in replacement for the official [Capacitor Preferences](https://capacitorjs.com/docs/apis/preferences) plugin and allows you to securely store key/value pairs such as passwords, tokens or other sensitive information. The plugin provides cross-platform support for Android, iOS and Web and is now available to all Capawesome [Insiders](/docs/insiders/).

Let's take a quick look at the [API](/docs/plugins/secure-preferences/#api) and how to use the plugin in your Capacitor app.

## Installation[¶](#installation "Permanent link")

To install the Capacitor Secure Preferences plugin, please refer to the [Installation](/docs/plugins/secure-preferences/#installation) section in the plugin documentation.

## Usage[¶](#usage "Permanent link")

Let's take a look at the basic usage of the plugin. You can find the complete API reference in the [API](/docs/plugins/secure-preferences/#api) section of the documentation.

### Set a value[¶](#set-a-value "Permanent link")

You can set a value using the [set](/docs/plugins/secure-preferences/#set) method:

`[](#%5F%5Fcodelineno-0-1)import { SecurePreferences } from '@capawesome-team/capacitor-secure-preferences';
[](#%5F%5Fcodelineno-0-2)
[](#%5F%5Fcodelineno-0-3)const set = async () => {
[](#%5F%5Fcodelineno-0-4)  await SecurePreferences.set({
[](#%5F%5Fcodelineno-0-5)    key: 'password',
[](#%5F%5Fcodelineno-0-6)    value: '123456',
[](#%5F%5Fcodelineno-0-7)  });
[](#%5F%5Fcodelineno-0-8)};
`

The stored value can be any string. To store other types or more complex objects, you can use [JSON.stringify()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global%5FObjects/
JSON/stringify) to convert them to a string before storing them and [JSON.parse()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global%5FObjects/JSON/parse) to convert them back to their original form after retrieving them.

No encryption on Web 

On **Android** and **iOS**, the value will be encrypted and stored securely on the device. On **Web**, the value will be stored unencrypted in `localStorage` since the web platform does not provide a secure storage solution. This is for development purposes only and should not be used in production.

### Get a value[¶](#get-a-value "Permanent link")

You can get a value using the [get](/docs/plugins/secure-preferences/#get) method:

`[](#%5F%5Fcodelineno-1-1)import { SecurePreferences } from '@capawesome-team/capacitor-secure-preferences';
[](#%5F%5Fcodelineno-1-2)
[](#%5F%5Fcodelineno-1-3)const get = async () => {
[](#%5F%5Fcodelineno-1-4)  const { value } = await SecurePreferences.get({ key: 'password' });
[](#%5F%5Fcodelineno-1-5)  console.log(value); // 123456
[](#%5F%5Fcodelineno-1-6)};
`

This will decrypt the value and return it as a string.

### Remove a value[¶](#remove-a-value "Permanent link")

To remove a value, you can use the [remove](/docs/plugins/secure-preferences/#remove) method:

`[](#%5F%5Fcodelineno-2-1)import { SecurePreferences } from '@capawesome-team/capacitor-secure-preferences';
[](#%5F%5Fcodelineno-2-2)
[](#%5F%5Fcodelineno-2-3)const remove = async () => {
[](#%5F%5Fcodelineno-2-4)  await SecurePreferences.remove({ key: 'password' });
[](#%5F%5Fcodelineno-2-5)};
`

### Clear all values[¶](#clear-all-values "Permanent link")

If you want to clear all values, simply call the [clear](/docs/plugins/secure-preferences/#clear) method:

`[](#%5F%5Fcodelineno-3-1)import { SecurePreferences } from '@capawesome-team/capacitor-secure-preferences';
[](#%5F%5Fcodelineno-3-2)
[](#%5F%5Fcodelineno-3-3)const clear = async () => {
[](#%5F%5Fcodelineno-3-4)  await SecurePreferences.clear();
[](#%5F%5Fcodelineno-3-5)};
`

### Get all keys[¶](#get-all-keys "Permanent link")

And finally, if you want to get all stored keys, you can use the [keys](/docs/plugins/secure-preferences/#keys) method:

`[](#%5F%5Fcodelineno-4-1)import { SecurePreferences } from '@capawesome-team/capacitor-secure-preferences';
[](#%5F%5Fcodelineno-4-2)
[](#%5F%5Fcodelineno-4-3)const getAllKeys = async () => {
[](#%5F%5Fcodelineno-4-4)  const { keys } = await SecurePreferences.keys();
[](#%5F%5Fcodelineno-4-5)  console.log(keys); // ['password']
[](#%5F%5Fcodelineno-4-6)};
`

## Conclusion[¶](#conclusion "Permanent link")

We hope you are as excited as we are about the new [Capacitor Secure Preferences](/docs/plugins/secure-preferences/) plugin. Be sure to check out the [API Reference](/docs/plugins/secure-preferences/#api) to see what else you can do with this plugin. If you are missing any features, just [create a feature request](https://github.com/capawesome-team/capacitor-plugins/issues/new/choose) in the [GitHub repository](https://github.com/capawesome-team/capacitor-plugins). Make sure you follow us on [X](https://x.com/capawesomeio) so you don't miss any future updates.

March 18, 2026 

 Back to top 