# @capacitor/synapse

> ### Example

Latest version **1.0.4** (published 2025-07-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install @capacitor/synapse
pnpm add @capacitor/synapse
yarn add @capacitor/synapse
bun add @capacitor/synapse
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2025-07-11 |
| First published | 2024-11-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | itschaced, ionicjs, jcesarmobile, vmfo, jpender, dtarnawsky, mark-ionic, alexgerardojacinto, os-pedrobilro, harvdoggy, jpender-os, ndr, kepatoto, rui.mendes, markemer |

## Links

- npm: https://www.npmjs.com/package/@capacitor/synapse
- npm.io page: https://npm.io/package/@capacitor/synapse

## Recent versions

- 1.0.4 (latest) — 2025-07-11
- 1.0.2-dev.1 (dev) — 2025-02-14
- 1.0.3 — 2025-06-16
- 1.0.2 — 2025-02-19
- 1.0.1 — 2024-11-21
- 1.0.0 — 2024-11-21

## README

# Synapse

### Example

You have plugins that exist for both Capacitor and Cordova. They share the same API for the most part; as in they both expose a `ping` method that takes a string and returns that string with the word "_pong" appeneded to it. You can use synapse to create a single call in ODC that will use which ever plugin is available to the built app. Adding this to your plugins does not alter their ability to be used in the normal fashion they would be directly in a Capacitor or Cordova app.

#### Capacitor Usage of MyPlugin
```javascript
import { MyPlugin } from 'capacitor-my-plugin';
...
async function buttonClick() {
  try {
    const resp = await MyPlugin.ping({text: "Hello World"});
    console.log(resp); // "Hello World_pong"
  } catch (error) {
    console.error(error);
  }
}
```

#### Cordova Usage of MyPlugin
```javascript
function buttonClick() {
  window.cordova.plugins.MyPlugin.ping(
    {text: "Hello World"},
    function(response) {
      console.log(response); // "Hello World_pong"
    },
    function(error) {
      console.error(error);
    }
  )
}
```

#### Synapse Usage of MyPlugin

```javascript
function buttonClick() {
  window.CapacitorUtils.Synapse.MyPlugin.ping(
    {text: "Hello World"},
    function(response) {
      console.log(response); // "Hello World_pong"
    },
    function(error) {
      console.error(error);
    }
  )
}
```

While similar to the way you call cordova plugins, the synapse call will use the appropriate plugin for the platform it is running on. If the app is built with Capacitor, it will use the Capacitor plugin. If the app is built with Cordova, it will use the Cordova plugin.

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