---
description: Capacitor Secure Preferences plugin to store sensitive data like passwords and tokens in native secure storage. An Ionic Secure Storage alternative.
title: Capacitor Secure Preferences Plugin - Capawesome
image: https://capawesome.io/docs/assets/images/social/sdks/capacitor/secure-preferences.png
---

<!doctype html> 

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

[🖥️ 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 [ Secure Preferences ](/docs/sdks/capacitor/secure-preferences/)
* [ Web ](#web)
* [ Configuration ](#configuration)
* [ Usage ](#usage)
* [ API ](#api)
* [ FAQ ](#faq)
* [ Related Plugins ](#related-plugins)
* [ Next steps ](#next-steps)
* [ Newsletter ](#newsletter)
* [ Changelog ](#changelog)
* [ Breaking Changes ](#breaking-changes)
* [ License ](#license)
* [ 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

* [ Web ](#web)
* [ Configuration ](#configuration)
* [ Usage ](#usage)
* [ API ](#api)
* [ FAQ ](#faq)
* [ Related Plugins ](#related-plugins)
* [ Next steps ](#next-steps)
* [ Newsletter ](#newsletter)
* [ Changelog ](#changelog)
* [ Breaking Changes ](#breaking-changes)
* [ License ](#license)

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

Capacitor plugin to securely store key/value pairs such as passwords, tokens or other sensitive information.

[ ![Deliver Live Updates to your Capacitor app with Capawesome Cloud](https://capawesome.io/assets/banners/cloud-build-and-deploy-capacitor-apps.png?t=1) ](https://capawesome.io/) 

## Features[¶](#features "Permanent link")

The Capacitor Secure Preferences plugin is one of the most complete secure storage solutions for Capacitor apps. Here are some of the key features:

* 🖥️ **Cross-platform**: Native secure storage on Android and iOS, with a `localStorage`\-backed web implementation for development.
* 🔒 **Secure**: Store sensitive information such as passwords securely using the [Android Keystore](https://developer.android.com/privacy-and-security/keystore) and [iOS Keychain](https://developer.apple.com/documentation/security/keychain-services).
* 🔍 **Detailed Error Messages**: Get actionable error messages with specific failure reasons and error codes on iOS, making debugging keychain issues straightforward.
* 🤝 **Compatibility**: Compatible with the [Biometrics](https://capawesome.io/docs/sdks/capacitor/biometrics/), [SQLite](https://capawesome.io/docs/sdks/capacitor/sqlite/), and [Vault](https://capawesome.io/docs/sdks/capacitor/vault/) plugins.
* 📦 **CocoaPods & SPM**: Supports CocoaPods and Swift Package Manager for iOS.
* 🔁 **Up-to-date**: Always supports the latest Capacitor version.
* ⭐️ **Support**: Priority support from the Capawesome Team.
* ✨ **Handcrafted**: Built from the ground up with care and expertise, not forked or AI-generated.

Missing a feature? Just [open an issue](https://github.com/capawesome-team/capacitor-plugins/issues) and we'll take a look!

## Use Cases[¶](#use-cases "Permanent link")

The Secure Preferences plugin is typically used whenever an app needs to keep small pieces of sensitive data on the device, for example:

* **Authentication tokens**: Store OAuth refresh tokens or session tokens that the app reads in the background.
* **API keys**: Keep server-issued API keys encrypted at rest instead of in plain text.
* **Credentials**: Securely store passwords using the Android Keystore and iOS Keychain.
* **Sensitive settings**: Persist preference flags that contain personal information.

## Compatibility[¶](#compatibility "Permanent link")

| Plugin Version | Capacitor Version | Status         |
| -------------- | ----------------- | -------------- |
| 0.3.x          | \>=8.x.x          | Active support |
| 0.2.x          | \>=8.x.x          | Deprecated     |

## Guides[¶](#guides "Permanent link")

* [Alternative to the Ionic Secure Storage plugin](https://capawesome.io/blog/alternative-to-ionic-secure-storage-plugin/)
* [Announcing the Capacitor Secure Preferences Plugin](https://capawesome.io/blog/announcing-the-capacitor-secure-preferences-plugin/)
* [Exploring the Capacitor Secure Preferences API](https://capawesome.io/blog/exploring-the-capacitor-secure-preferences-api/)
* [How to Securely Store Credentials with Capacitor](https://capawesome.io/blog/how-to-securely-store-credentials-with-capacitor/)

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

This plugin is only available to [Capawesome Insiders](https://capawesome.io/insiders/). First, make sure you have the Capawesome npm registry set up. You can do this by running the following commands:

`[](#%5F%5Fcodelineno-0-1)npm config set @capawesome-team:registry https://npm.registry.capawesome.io
[](#%5F%5Fcodelineno-0-2)npm config set //npm.registry.capawesome.io/:_authToken <YOUR_LICENSE_KEY>
`

**Attention**: Replace `<YOUR_LICENSE_KEY>` with the license key you received from Polar. If you don't have a license key yet, you can get one by becoming a [Capawesome Insider](https://capawesome.io/insiders/).

Next, you can use our **AI-Assisted Setup** to install the plugin. Add the [Capawesome Skills](https://github.com/capawesome-team/skills) to your AI tool using the following command:

`[](#%5F%5Fcodelineno-1-1)npx skills add capawesome-team/skills --skill capacitor-plugins
`

Then use the following prompt:

`` [](#%5F%5Fcodelineno-2-1)Use the `capacitor-plugins` skill from `capawesome-team/skills` to install the `@capawesome-team/capacitor-secure-preferences` plugin in my project.
 ``

If you prefer **Manual Setup**, install the plugin by running the following commands and follow the platform-specific instructions below:

`[](#%5F%5Fcodelineno-3-1)npm install @capawesome-team/capacitor-secure-preferences
[](#%5F%5Fcodelineno-3-2)npx cap sync
`

### Android[¶](#android "Permanent link")

#### Proguard[¶](#proguard "Permanent link")

If you are using Proguard, you need to add the following rules to your `proguard-rules.pro` file:

`[](#%5F%5Fcodelineno-4-1)-keep class io.capawesome.capacitorjs.plugins.** { *; }
`

### Web[¶](#web "Permanent link")

**Attention**: The web implementation uses `localStorage` to make cross-platform development easier. It is intended for development and testing purposes only and should NOT be used in production.

## Configuration[¶](#configuration "Permanent link")

No configuration required for this plugin.

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

The following examples show how to store a value, retrieve a value, list all stored keys, remove a value, and clear all stored values.

### Store a value[¶](#store-a-value "Permanent link")

Store a value securely under a key. On Android and iOS, the value is encrypted at rest. On the web, the value is stored unencrypted in `localStorage` for development purposes only:

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

### Retrieve a value[¶](#retrieve-a-value "Permanent link")

Get the value associated with a key:

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

### List all stored keys[¶](#list-all-stored-keys "Permanent link")

Get a list of all keys that currently have a stored value:

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

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

Remove a single value given its key:

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

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

Remove all stored keys and values at once:

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

## API[¶](#api "Permanent link")

* [clear()](#clear)
* [get(...)](#get)
* [keys()](#keys)
* [remove(...)](#remove)
* [set(...)](#set)
* [Interfaces](#interfaces)

### clear()[¶](#clear "Permanent link")

`[](#%5F%5Fcodelineno-10-1)clear() => Promise<void>
`

Clear all stored keys and values.

**Since:** 0.1.0

---

### get(...)[¶](#get "Permanent link")

`[](#%5F%5Fcodelineno-11-1)get(options: GetOptions) => Promise<GetResult>
`

Get the value associated with a key.

| Param       | Type                      |
| ----------- | ------------------------- |
| **options** | [GetOptions](#getoptions) |

**Returns:** `Promise<[GetResult](#getresult)>`

**Since:** 0.1.0

---

### keys()[¶](#keys "Permanent link")

`[](#%5F%5Fcodelineno-12-1)keys() => Promise<KeysResult>
`

Get a list of all stored keys.

**Returns:** `Promise<[KeysResult](#keysresult)>`

**Since:** 0.1.0

---

### remove(...)[¶](#remove "Permanent link")

`[](#%5F%5Fcodelineno-13-1)remove(options: RemoveOptions) => Promise<void>
`

Remove a value given its key.

| Param       | Type                            |
| ----------- | ------------------------------- |
| **options** | [RemoveOptions](#removeoptions) |

**Since:** 0.1.0

---

### set(...)[¶](#set "Permanent link")

`[](#%5F%5Fcodelineno-14-1)set(options: SetOptions) => Promise<void>
`

Set a value given its key.

On **Web**, the value is stored unencrypted in `localStorage`. This is for development purposes only and should NOT be used in production.

| Param       | Type                      |
| ----------- | ------------------------- |
| **options** | [SetOptions](#setoptions) |

**Since:** 0.1.0

---

### Interfaces[¶](#interfaces "Permanent link")

#### GetResult[¶](#getresult "Permanent link")

| Prop      | Type           | Description          | Since |
| --------- | -------------- | -------------------- | ----- |
| **value** | string \| null | The retrieved value. | 0.1.0 |

#### GetOptions[¶](#getoptions "Permanent link")

| Prop    | Type   | Description                               | Since |
| ------- | ------ | ----------------------------------------- | ----- |
| **key** | string | The key associated with the stored value. | 0.1.0 |

#### KeysResult[¶](#keysresult "Permanent link")

| Prop     | Type       | Description                | Since |
| -------- | ---------- | -------------------------- | ----- |
| **keys** | string\[\] | The available stored keys. | 0.1.0 |

#### RemoveOptions[¶](#removeoptions "Permanent link")

| Prop    | Type   | Description        | Since |
| ------- | ------ | ------------------ | ----- |
| **key** | string | The key to remove. | 0.1.0 |

#### SetOptions[¶](#setoptions "Permanent link")

| Prop      | Type   | Description                               | Since |
| --------- | ------ | ----------------------------------------- | ----- |
| **key**   | string | The key associated with the stored value. | 0.1.0 |
| **value** | string | The value to store.                       | 0.1.0 |

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

### Where is the data stored?[¶](#where-is-the-data-stored "Permanent link")

On Android, the encryption key is stored in the [Android Keystore](https://developer.android.com/privacy-and-security/keystore) and the encrypted values are stored in a `SharedPreferences` file (`CAPAWESOME_SECURE_PREFERENCES.xml`). On iOS, the encrypted values are stored as [Keychain](https://developer.apple.com/documentation/security/keychain-services) items.

On Android, the encryption key in the Keystore is never backed up. The encrypted values in `SharedPreferences` are part of [Android Auto Backup](https://developer.android.com/identity/data/autobackup) by default, but the backed-up ciphertext is unusable on another device without the Keystore key; to exclude the preferences file (`CAPAWESOME_SECURE_PREFERENCES.xml`) from backup, see the [Android documentation](https://developer.android.com/identity/data/autobackup#IncludingFiles). On iOS, the Keychain items are not synced to iCloud, but they may be included in encrypted local device backups and restored on a new device.

### When should I use Secure Preferences instead of Vault or SQLite?[¶](#when-should-i-use-secure-preferences-instead-of-vault-or-sqlite "Permanent link")

All three plugins protect data on the device, but they target different problems:

* **Secure Preferences** (this plugin) is a transparent key/value store. Values are encrypted at rest using the Android Keystore and iOS Keychain, but the app can read them at any time without prompting the user. Reach for it when you need to keep small bits of sensitive data around that the app itself accesses in the background — typical examples are OAuth refresh tokens, server-issued API keys, or preference flags that contain personal information.
* **[Vault](https://capawesome.io/docs/sdks/capacitor/vault/)** is a key/value store with an active lock state and biometric or device-passcode gating. The user has to unlock it before any read or write, and it locks again on demand or after a configurable background timeout. Reach for it when access to the data should require an explicit user action — a password manager's entries, an authenticator app's TOTP secrets, or the credentials sitting behind an "app lock" screen.
* **[SQLite](https://capawesome.io/docs/sdks/capacitor/sqlite/)** is a full relational database with optional SQLCipher encryption. Use it when the shape of your data calls for queries, joins, indexes, or large record sets — for example, an offline-first app that syncs structured records, or anything you would otherwise model with a server-side database.

A quick decision tree:

* Need encrypted key/value storage the app can read freely in the background? → **Secure Preferences**.
* Need encrypted key/value storage the user must actively unlock with biometrics or a passcode? → **Vault**.
* Need queries, relations, or large datasets? → **SQLite**.

The three plugins are designed to coexist. A real-world app might use Secure Preferences for app-managed tokens, SQLite for synced records, and Vault for the master password that protects everything else.

### Is this plugin an alternative to Ionic Secure Storage?[¶](#is-this-plugin-an-alternative-to-ionic-secure-storage "Permanent link")

Yes, for key/value data. This plugin was built as an actively maintained alternative to [Ionic Secure Storage](https://ionic.io/products/secure-storage), which sunsets on December 31, 2027\. Like Ionic Secure Storage's key/value API, it stores sensitive data encrypted at rest, backed by the Android Keystore and iOS Keychain. If you use Ionic Secure Storage's encrypted SQLite database, take a look at the [SQLite](https://capawesome.io/docs/sdks/capacitor/sqlite/) plugin instead, which provides SQLCipher-based encryption.

### How do I migrate from Ionic Secure Storage?[¶](#how-do-i-migrate-from-ionic-secure-storage "Permanent link")

For an AI-assisted migration of your code, add the [Capawesome Skills](https://github.com/capawesome-team/skills) to your AI tool and instruct it to use the `ionic-enterprise-sdk-migration` skill to migrate your project from Ionic Secure Storage to `@capawesome-team/capacitor-secure-preferences`. Alternatively, if you want to perform the migration manually, you can follow the instructions in this blog post: [Alternative to the Ionic Secure Storage plugin](https://capawesome.io/blog/alternative-to-ionic-secure-storage-plugin/).

### Can I use the plugin on the web?[¶](#can-i-use-the-plugin-on-the-web "Permanent link")

Yes, but only for development and testing purposes. The web implementation stores values unencrypted in `localStorage` to make cross-platform development easier and should NOT be used in production. The secure, encrypted storage backed by the Android Keystore and iOS Keychain is only available on Android and iOS.

### Can I use this plugin with Ionic, React, Vue or Angular?[¶](#can-i-use-this-plugin-with-ionic-react-vue-or-angular "Permanent link")

Yes, the plugin is framework-agnostic. It works in any Capacitor app regardless of the web framework, including Ionic with Angular, React, or Vue, as well as plain JavaScript projects.

## Related Plugins[¶](#related-plugins "Permanent link")

* [Biometrics](https://capawesome.io/docs/sdks/capacitor/biometrics/): Request biometric authentication, such as face or fingerprint recognition.
* [Root Detection](https://capawesome.io/docs/sdks/capacitor/root-detection/): Detect rooted and jailbroken devices before trusting locally stored secrets.
* [SQLite](https://capawesome.io/docs/sdks/capacitor/sqlite/): Access SQLite databases with support for encryption, transactions, and schema migrations.
* [Vault](https://capawesome.io/docs/sdks/capacitor/vault/): Securely store key/value pairs in lockable, biometric-protected vaults.

## Next steps[¶](#next-steps "Permanent link")

Here are a few resources to help you continue:

* Read [Alternative to the Ionic Secure Storage plugin](https://capawesome.io/blog/alternative-to-ionic-secure-storage-plugin/) if you are migrating from Ionic Secure Storage.
* Need biometric-protected, lockable storage? Check out the [Capacitor Vault plugin](https://capawesome.io/docs/sdks/capacitor/vault/).
* Need encrypted relational storage? Check out the [Capacitor SQLite plugin](https://capawesome.io/docs/sdks/capacitor/sqlite/).

## Newsletter[¶](#newsletter "Permanent link")

Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our [Capawesome Newsletter](https://capawesome.io/newsletter/).

## Changelog[¶](#changelog "Permanent link")

See [CHANGELOG.md](https://github.com/capawesome-team/capacitor-plugins/blob/main/packages/secure-preferences/CHANGELOG.md).

## Breaking Changes[¶](#breaking-changes "Permanent link")

See [BREAKING.md](https://github.com/capawesome-team/capacitor-plugins/blob/main/packages/secure-preferences/BREAKING.md).

## License[¶](#license "Permanent link")

See [LICENSE](https://github.com/capawesome-team/capacitor-plugins/blob/main/packages/secure-preferences/LICENSE).

July 8, 2026 

Back to top

```json
{"@context": "https://schema.org", "@graph": [{"@type": "TechArticle", "@id": "https://capawesome.io/docs/sdks/capacitor/secure-preferences/#article", "headline": "Capacitor Secure Preferences Plugin", "name": "Capacitor Secure Preferences Plugin", "description": "Capacitor Secure Preferences plugin to store sensitive data like passwords and tokens in native secure storage. An Ionic Secure Storage alternative.", "inLanguage": "en", "url": "https://capawesome.io/docs/sdks/capacitor/secure-preferences/", "mainEntityOfPage": "https://capawesome.io/docs/sdks/capacitor/secure-preferences/", "author": {"@type": "Organization", "name": "Capawesome", "url": "https://capawesome.io", "logo": {"@type": "ImageObject", "url": "https://capawesome.io/assets/images/logo.svg"}}, "publisher": {"@type": "Organization", "name": "Capawesome", "url": "https://capawesome.io", "logo": {"@type": "ImageObject", "url": "https://capawesome.io/assets/images/logo.svg"}}, "about": {"@id": "https://capawesome.io/docs/sdks/capacitor/secure-preferences/#software"}}, {"@type": "SoftwareSourceCode", "@id": "https://capawesome.io/docs/sdks/capacitor/secure-preferences/#software", "name": "Capacitor Secure Preferences Plugin", "description": "Capacitor Secure Preferences plugin to store sensitive data like passwords and tokens in native secure storage. An Ionic Secure Storage alternative.", "url": "https://capawesome.io/docs/sdks/capacitor/secure-preferences/", "programmingLanguage": "TypeScript", "runtimePlatform": "Capacitor", "codeRepository": "https://github.com/capawesome-team", "author": {"@type": "Organization", "name": "Capawesome", "url": "https://capawesome.io", "logo": {"@type": "ImageObject", "url": "https://capawesome.io/assets/images/logo.svg"}}, "publisher": {"@type": "Organization", "name": "Capawesome", "url": "https://capawesome.io", "logo": {"@type": "ImageObject", "url": "https://capawesome.io/assets/images/logo.svg"}}}]}
{"@context": "https://schema.org", "@type": "FAQPage", "mainEntity": [{"@type": "Question", "name": "Where is the data stored?", "acceptedAnswer": {"@type": "Answer", "text": "On Android, the encryption key is stored in the Android Keystore and the encrypted values are stored in a SharedPreferences file ( CAPAWESOME_SECURE_PREFERENCES.xml). On iOS, the encrypted values are stored as Keychain items. On Android, the encryption key in the Keystore is never backed up. The encrypted values in SharedPreferences are part of Android Auto Backup by default, but the backed-up ciphertext is unusable on another device without the Keystore key; to exclude the preferences file ( CAPAWESOME_SECURE_PREFERENCES.xml) from backup, see the Android documentation. On iOS, the Keychain items are not synced to iCloud, but they may be included in encrypted local device backups and restored on a new device."}}, {"@type": "Question", "name": "When should I use Secure Preferences instead of Vault or SQLite?", "acceptedAnswer": {"@type": "Answer", "text": "All three plugins protect data on the device, but they target different problems: Secure Preferences (this plugin) is a transparent key/value store. Values are encrypted at rest using the Android Keystore and iOS Keychain, but the app can read them at any time without prompting the user. Reach for it when you need to keep small bits of sensitive data around that the app itself accesses in the background — typical examples are OAuth refresh tokens, server-issued API keys, or preference flags that contain personal information. Vault is a key/value store with an active lock state and biometric or device-passcode gating. The user has to unlock it before any read or write, and it locks again on demand or after a configurable background timeout. Reach for it when access to the data should require an explicit user action — a password manager's entries, an authenticator app's TOTP secrets, or the credentials sitting behind an \"app lock\" screen. SQLite is a full relational database with optional SQLCipher encryption. Use it when the shape of your data calls for queries, joins, indexes, or large record sets — for example, an offline-first app that syncs structured records, or anything you would otherwise model with a server-side database. A quick decision tree: Need encrypted key/value storage the app can read freely in the background? → Secure Preferences. Need encrypted key/value storage the user must actively unlock with biometrics or a passcode? → Vault. Need queries, relations, or large datasets? → SQLite. The three plugins are designed to coexist. A real-world app might use Secure Preferences for app-managed tokens, SQLite for synced records, and Vault for the master password that protects everything else."}}, {"@type": "Question", "name": "Is this plugin an alternative to Ionic Secure Storage?", "acceptedAnswer": {"@type": "Answer", "text": "Yes, for key/value data. This plugin was built as an actively maintained alternative to Ionic Secure Storage, which sunsets on December 31, 2027. Like Ionic Secure Storage's key/value API, it stores sensitive data encrypted at rest, backed by the Android Keystore and iOS Keychain. If you use Ionic Secure Storage's encrypted SQLite database, take a look at the SQLite plugin instead, which provides SQLCipher-based encryption."}}, {"@type": "Question", "name": "How do I migrate from Ionic Secure Storage?", "acceptedAnswer": {"@type": "Answer", "text": "For an AI-assisted migration of your code, add the Capawesome Skills to your AI tool and instruct it to use the ionic-enterprise-sdk-migration skill to migrate your project from Ionic Secure Storage to @capawesome-team/capacitor-secure-preferences. Alternatively, if you want to perform the migration manually, you can follow the instructions in this blog post: Alternative to the Ionic Secure Storage plugin."}}, {"@type": "Question", "name": "Can I use the plugin on the web?", "acceptedAnswer": {"@type": "Answer", "text": "Yes, but only for development and testing purposes. The web implementation stores values unencrypted in localStorage to make cross-platform development easier and should NOT be used in production. The secure, encrypted storage backed by the Android Keystore and iOS Keychain is only available on Android and iOS."}}, {"@type": "Question", "name": "Can I use this plugin with Ionic, React, Vue or Angular?", "acceptedAnswer": {"@type": "Answer", "text": "Yes, the plugin is framework-agnostic. It works in any Capacitor app regardless of the web framework, including Ionic with Angular, React, or Vue, as well as plain JavaScript projects."}}], "url": "https://capawesome.io/docs/sdks/capacitor/secure-preferences/"}
```
