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

<!doctype html> 

[Skip to content ](#capacitor-secure-preferences-encrypted-storage) 

[🖥️ Introducing the **Capacitor Electron Platform** — build desktop apps for macOS, Windows, and Linux. Free & open source. ](/blog/announcing-the-capacitor-electron-platform/) 

* [ 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/)
* [ Gyroscope ](/docs/sdks/capacitor/gyroscope/)
* [ Haptics ](/docs/sdks/capacitor/haptics/)
* [ Home Indicator ](/docs/sdks/capacitor/home-indicator/)
* [ In-App Browser ](/docs/sdks/capacitor/in-app-browser/)
* [ Install Referrer ](/docs/sdks/capacitor/install-referrer/)
* [ Intercom ](/docs/sdks/capacitor/intercom/)
* [ Intune ](/docs/sdks/capacitor/intune/)
* [ Keep Awake ](/docs/sdks/capacitor/keep-awake/)
* [ libSQL ](/docs/sdks/capacitor/libsql/)
* [ Light Sensor ](/docs/sdks/capacitor/light-sensor/)
* [ Live Update ](/docs/sdks/capacitor/live-update/)
* [ Localization ](/docs/sdks/capacitor/localization/)
* [ Mail Composer ](/docs/sdks/capacitor/mail-composer/)
* [ Managed Configurations ](/docs/sdks/capacitor/managed-configurations/)
* [ Maps Launcher ](/docs/sdks/capacitor/maps-launcher/)
* [ Media Session ](/docs/sdks/capacitor/media-session/)
* [ ML Kit ](/docs/sdks/capacitor/mlkit/)
* [ Navigation Bar ](/docs/sdks/capacitor/navigation-bar/)
* [ Network ](/docs/sdks/capacitor/network/)
* [ NFC ](/docs/sdks/capacitor/nfc/)
* [ Node.js ](/docs/sdks/capacitor/nodejs/)
* [ OAuth ](/docs/sdks/capacitor/oauth/)
* [ Passkeys ](/docs/sdks/capacitor/passkeys/)
* [ Password Autofill ](/docs/sdks/capacitor/password-autofill/)
* [ PDF Generator ](/docs/sdks/capacitor/pdf-generator/)
* [ PDF Viewer ](/docs/sdks/capacitor/pdf-viewer/)
* [ Pedometer ](/docs/sdks/capacitor/pedometer/)
* [ Permissions ](/docs/sdks/capacitor/permissions/)
* [ Phone Dialer ](/docs/sdks/capacitor/phone-dialer/)
* [ Photo Editor ](/docs/sdks/capacitor/photo-editor/)
* [ Photo Manipulator ](/docs/sdks/capacitor/photo-manipulator/)
* [ PixLive ](/docs/sdks/capacitor/pixlive/)
* [ PostHog ](/docs/sdks/capacitor/posthog/)
* [ Printer ](/docs/sdks/capacitor/printer/)
* [ Privacy Screen ](/docs/sdks/capacitor/privacy-screen/)
* [ Proximity Sensor ](/docs/sdks/capacitor/proximity-sensor/)
* [ Purchases ](/docs/sdks/capacitor/purchases/)
* [ RealtimeKit ](/docs/sdks/capacitor/realtimekit/)
* [ Root Detection ](/docs/sdks/capacitor/root-detection/)
* [ Screen Brightness ](/docs/sdks/capacitor/screen-brightness/)
* [ Screen Orientation ](/docs/sdks/capacitor/screen-orientation/)
* [ Screen Reader ](/docs/sdks/capacitor/screen-reader/)
* [ Screenshot ](/docs/sdks/capacitor/screenshot/)
* [ Secure Preferences ](/docs/sdks/capacitor/secure-preferences/)
* [ Settings Launcher ](/docs/sdks/capacitor/settings-launcher/)
* [ Shake ](/docs/sdks/capacitor/shake/)
* [ Silent Mode ](/docs/sdks/capacitor/silent-mode/)
* [ SIM ](/docs/sdks/capacitor/sim/)
* [ SMS Composer ](/docs/sdks/capacitor/sms-composer/)
* [ 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/)
* [ System WebView ](/docs/sdks/capacitor/system-webview/)
* [ Tauri ](/docs/sdks/capacitor/tauri/)
* [ Text Interaction ](/docs/sdks/capacitor/text-interaction/)
* [ Text Zoom ](/docs/sdks/capacitor/text-zoom/)
* [ Thermal State ](/docs/sdks/capacitor/thermal-state/)
* [ Toast ](/docs/sdks/capacitor/toast/)
* [ Torch ](/docs/sdks/capacitor/torch/)
* [ Vault ](/docs/sdks/capacitor/vault/)
* [ Volume ](/docs/sdks/capacitor/volume/)
* [ Wallet ](/docs/sdks/capacitor/wallet/)
* [ Wifi ](/docs/sdks/capacitor/wifi/)
* [ YouTube Player ](/docs/sdks/capacitor/youtube-player/)
* [ 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, Yarn, or bun ](/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

* [ FAQ ](#faq)
* [ Related Posts ](#related-posts)
* [ Conclusion ](#conclusion)

* Related links

# Capacitor Secure Preferences: Encrypted Storage[¶](#capacitor-secure-preferences-encrypted-storage "Permanent link")

Need to store passwords, tokens, or other sensitive values in a Capacitor app without rolling your own encryption? The [Capacitor Secure Preferences plugin](/docs/sdks/capacitor/secure-preferences/) is a drop-in replacement for the official [Capacitor Preferences](https://capacitorjs.com/docs/apis/preferences) plugin that stores key/value pairs securely. It provides cross-platform support for Android, iOS, and Web and is 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)};
`

## FAQ[¶](#faq "Permanent link")

### Which platforms does the Capacitor Secure Preferences plugin support?[¶](#which-platforms-does-the-capacitor-secure-preferences-plugin-support "Permanent link")

The plugin supports Android, iOS, and the Web. On Android and iOS values are encrypted and stored securely; on the Web they fall back to unencrypted `localStorage` (see below).

### Is the stored data encrypted on every platform?[¶](#is-the-stored-data-encrypted-on-every-platform "Permanent link")

No. On **Android** and **iOS** values are encrypted and stored securely on the device. On the **Web** there is no secure storage API, so values are kept unencrypted in `localStorage` — intended for development only, not production.

### Is it a drop-in replacement for @capacitor/preferences?[¶](#is-it-a-drop-in-replacement-for-capacitorpreferences "Permanent link")

Yes. It mirrors the official [Capacitor Preferences](https://capacitorjs.com/docs/apis/preferences) API — `set`, `get`, `remove`, `clear`, and `keys` — so you can swap it in with minimal changes.

### Can I store objects instead of plain strings?[¶](#can-i-store-objects-instead-of-plain-strings "Permanent link")

Values are stored as strings. Use `JSON.stringify()` before storing an object and `JSON.parse()` after reading it back.

## Related Posts[¶](#related-posts "Permanent link")

* [Alternative to the Ionic Identity Vault plugin](/blog/alternative-to-ionic-identity-vault-plugin/)
* [Alternative to the Ionic Secure Storage plugin](/blog/alternative-to-ionic-secure-storage-plugin/)
* [Exploring the Capacitor Secure Preferences API](/blog/exploring-the-capacitor-secure-preferences-api/)
* [Capacitor Biometrics plugin: Face & fingerprint authentication](/blog/announcing-the-capacitor-biometrics-plugin/)
* [Capacitor Vault plugin: store secrets securely](/blog/announcing-the-capacitor-vault-plugin/)

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

The [Capacitor Secure Preferences plugin](/docs/sdks/capacitor/secure-preferences/) gives you encrypted key/value storage on Android and iOS behind the familiar Preferences API, so securing tokens and other sensitive values is mostly a matter of swapping the import. Check the [API Reference](/docs/sdks/capacitor/secure-preferences/#api) for the full method list.

**Missing a feature?** [Create a feature request](https://github.com/capawesome-team/capacitor-plugins/issues/new/choose) in our [GitHub repository](https://github.com/capawesome-team/capacitor-plugins).

Join the Capawesome [Discord](https://discord.gg/VCXxSVjefW) server for questions and subscribe to the Capawesome [newsletter](https://capawesome.io/newsletter/) to stay updated.

July 16, 2026 

Back to top

```json
{
      "@context": "https://schema.org",
      "@type": "BlogPosting",
      "headline": "Capacitor Secure Preferences: Encrypted Storage",
      "description": "Securely store key/value pairs such as passwords, tokens or other sensitive information in your Capacitor app.",
      "image": "https://capawesome.io/assets/banners/cloud-build-and-deploy-capacitor-apps.png",
      "datePublished": "2025-05-01T00:00:00+00:00",
      "dateModified": "2026-07-10T00:00:00+00:00",
      "author": [
        {
          "@type": "Person",
          "name": "Robin Genz",
          "url": "https://github.com/robingenz"
        }
      ],
      "publisher": {
        "@type": "Organization",
        "name": "Capawesome",
        "url": "https://capawesome.io",
        "logo": {
          "@type": "ImageObject",
          "url": "https://capawesome.io/assets/images/logo.svg"
        }
      },
      "articleSection": "Announcements",
      "keywords": ["Announcements", "Capacitor", "SDKs"],
      "isPartOf": {
        "@type": "Blog",
        "@id": "https://capawesome.io/blog/#blog"
      },
      "mainEntityOfPage": "https://capawesome.io/blog/announcing-the-capacitor-secure-preferences-plugin/",
      "url": "https://capawesome.io/blog/announcing-the-capacitor-secure-preferences-plugin/"
    }
{
      "@context": "https://schema.org",
      "@type": "BreadcrumbList",
      "itemListElement": [
        {
          "@type": "ListItem",
          "position": 1,
          "name": "Home",
          "item": "https://capawesome.io/"
        },
        {
          "@type": "ListItem",
          "position": 2,
          "name": "Blog",
          "item": "https://capawesome.io/blog/"
        },
        {
          "@type": "ListItem",
          "position": 3,
          "name": "Capacitor Secure Preferences: Encrypted Storage",
          "item": "https://capawesome.io/blog/announcing-the-capacitor-secure-preferences-plugin/"
        }
      ]
    }
{"@context": "https://schema.org", "@type": "FAQPage", "mainEntity": [{"@type": "Question", "name": "Which platforms does the Capacitor Secure Preferences plugin support?", "acceptedAnswer": {"@type": "Answer", "text": "The plugin supports Android, iOS, and the Web. On Android and iOS values are encrypted and stored securely; on the Web they fall back to unencrypted localStorage (see below)."}}, {"@type": "Question", "name": "Is the stored data encrypted on every platform?", "acceptedAnswer": {"@type": "Answer", "text": "No. On Android and iOS values are encrypted and stored securely on the device. On the Web there is no secure storage API, so values are kept unencrypted in localStorage — intended for development only, not production."}}, {"@type": "Question", "name": "Is it a drop-in replacement for @capacitor/preferences?", "acceptedAnswer": {"@type": "Answer", "text": "Yes. It mirrors the official Capacitor Preferences API — set, get, remove, clear, and keys — so you can swap it in with minimal changes."}}, {"@type": "Question", "name": "Can I store objects instead of plain strings?", "acceptedAnswer": {"@type": "Answer", "text": "Values are stored as strings. Use JSON.stringify() before storing an object and JSON.parse() after reading it back."}}], "url": "https://capawesome.io/blog/announcing-the-capacitor-secure-preferences-plugin/"}
```
