---
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 the **Capacitor Vault** plugin — store secrets behind biometrics or a device passcode.](/blog/announcing-the-capacitor-vault-plugin/) 

* [  SDKs ](/docs/sdks/)
* [  Formbricks ](/docs/sdks/capacitor/formbricks/)
* [  Geocoder ](/docs/sdks/capacitor/geocoder/)
* [  Google Sign-In ](/docs/sdks/capacitor/google-sign-in/)
* [  Grafana Faro ](/docs/sdks/capacitor/grafana-faro/)
* [  libSQL ](/docs/sdks/capacitor/libsql/)
* [  Live Update ](/docs/sdks/capacitor/live-update/)
* [  Managed Configurations ](/docs/sdks/capacitor/managed-configurations/)
* [  Media Session ](/docs/sdks/capacitor/media-session/)
* [  ML Kit ](/docs/sdks/capacitor/mlkit/)
* [  Navigation Bar ](/docs/sdks/capacitor/navigation-bar/)
* [  NFC ](/docs/sdks/capacitor/nfc/)
* [  OAuth ](/docs/sdks/capacitor/oauth/)
* [  Pedometer ](/docs/sdks/capacitor/pedometer/)
* [  Photo Editor ](/docs/sdks/capacitor/photo-editor/)
* [  PostHog ](/docs/sdks/capacitor/posthog/)
* [  Printer ](/docs/sdks/capacitor/printer/)
* [  Purchases ](/docs/sdks/capacitor/purchases/)
* [  RealtimeKit ](/docs/sdks/capacitor/realtimekit/)
* [  Screen Orientation ](/docs/sdks/capacitor/screen-orientation/)
* [  Screenshot ](/docs/sdks/capacitor/screenshot/)
* [  Secure Preferences ](/docs/sdks/capacitor/secure-preferences/)
* [  Speech Recognition ](/docs/sdks/capacitor/speech-recognition/)
* [  Speech Synthesis ](/docs/sdks/capacitor/speech-synthesis/)
* [  Share Target ](/docs/sdks/capacitor/share-target/)
* [  Square Mobile Payments ](/docs/sdks/capacitor/square-mobile-payments/)
* [  SQLite ](/docs/sdks/capacitor/sqlite/)
* [  Superwall ](/docs/sdks/capacitor/superwall/)
* [  Torch ](/docs/sdks/capacitor/torch/)
* [  Vault ](/docs/sdks/capacitor/vault/)
* [  Wifi ](/docs/sdks/capacitor/wifi/)
* [  Zip ](/docs/sdks/capacitor/zip/)
* [  Cordova ](/docs/sdks/cordova/)
* [  Cloud ](/docs/cloud/)
* [  Integrations ](/docs/cloud/live-updates/integrations/)
* Concepts
* Reference
* [  Troubleshooting ](/docs/cloud/live-updates/troubleshooting/)
* [  FAQ ](/docs/cloud/live-updates/faq/)
* [  Native Builds ](/docs/cloud/native-builds/)
* [  Set Up Environments ](/docs/cloud/native-builds/environments/)
* [  Overwrite Native Configurations ](/docs/cloud/native-builds/native-configurations/)
* [  Auto-Increment Build Numbers ](/docs/cloud/native-builds/auto-incrementing-build-numbers/)
* [  Configure the Web Build Script ](/docs/cloud/native-builds/web-build-script/)
* [  Build from a Monorepo ](/docs/cloud/native-builds/monorepo/)
* [  Use pnpm or Yarn ](/docs/cloud/native-builds/package-managers/)
* [  Install Private npm Packages ](/docs/cloud/native-builds/npm-private-registry/)
* [  Override the Java Version ](/docs/cloud/native-builds/override-java-version/)
* [  Custom iOS Provisioning Profiles ](/docs/cloud/native-builds/custom-ios-provisioning-profiles/)
* [  Build without Git ](/docs/cloud/native-builds/build-without-git/)
* [  Access Git Behind a Firewall ](/docs/cloud/native-builds/firewall-access/)
* [  Integrations ](/docs/cloud/native-builds/integrations/)
* Reference
* [  Troubleshooting ](/docs/cloud/native-builds/troubleshooting/)
* [  FAQ ](/docs/cloud/native-builds/faq/)
* [  App Store Publishing ](/docs/cloud/app-store-publishing/)
* [  Submit a Build ](/docs/cloud/app-store-publishing/submit-a-build/)
* [  Submit Automatically After a Build ](/docs/cloud/app-store-publishing/submit-automatically/)
* [  Troubleshooting ](/docs/cloud/app-store-publishing/troubleshooting/)
* [  FAQ ](/docs/cloud/app-store-publishing/faq/)
* [  Automations ](/docs/cloud/automations/)
* [  Reference ](/docs/cloud/automations/reference/)
* [  Troubleshooting ](/docs/cloud/automations/troubleshooting/)
* [  FAQ ](/docs/cloud/automations/faq/)
* [  Assist ](/docs/cloud/assist/)
* [  CLI ](/docs/cloud/cli/)
* APIs and SDKs
* [  Webhooks ](/docs/cloud/webhooks/)
* [  Integrations ](/docs/cloud/integrations/)
* Account
* [  Organization ](/docs/cloud/organizations/)
* [  Two-Factor Enforcement ](/docs/cloud/organizations/two-factor-authentication/)
* [  Audit Logs ](/docs/cloud/organizations/audit-logs/)
* [  Billing ](/docs/cloud/organizations/billing/)
* [  License Keys ](/docs/cloud/license-keys/)
* [  AI ](/docs/ai/)
* [  Insiders ](/docs/insiders/)
* [  Billing & Plans ](/docs/insiders/billing-and-plans/)
* [  FAQ ](/docs/insiders/faq/)
* [  License ](https://capawesome.io/legal/eula/)
* [  Support ](/docs/support/)
* [  Contributing ](/docs/contributing/)
* Contributing code
* [  Code of Conduct ](/docs/contributing/code-of-conduct/)
* [  Questions ](https://docs.github.com/en/discussions/collaborating-with-your-community-using-discussions/participating-in-a-discussion#creating-a-discussion)
* [  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 plugin](/docs/sdks/capacitor/secure-preferences/). 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/sdks/capacitor/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/sdks/capacitor/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/sdks/capacitor/secure-preferences/#api) section of the documentation.

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

You can set a value using the [set](/docs/sdks/capacitor/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/sdks/capacitor/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/sdks/capacitor/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/sdks/capacitor/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/sdks/capacitor/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 plugin](/docs/sdks/capacitor/secure-preferences/). Be sure to check out the [API Reference](/docs/sdks/capacitor/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.

June 8, 2026 

 Back to top 