
Security News
Scaling Socket from Zero to 10,000+ Organizations
Socket CEO Feross Aboukhadijeh shares lessons from scaling a developer security startup to 10,000+ organizations in this founder interview.
@capacitor-trancee/nearby
Advanced tools
Uses Nearby Connections peer-to-peer networking API that allows apps to easily discover, connect to, and exchange data with nearby devices in real-time, regardless of network connectivity
Uses Bluetooth LE to scan and advertise for nearby devices
npm install @capacitor-trancee/nearby
npx cap sync
BLUETOOTH CORE SPECIFICATION Version 5.1 | Vol 3, Part A
4.22 LE CREDIT BASED CONNECTION REQUEST (CODE 0x14)

<uses-permission
android:name="android.permission.BLUETOOTH"
android:maxSdkVersion="30" />
<!-- https://developer.android.com/develop/connectivity/bluetooth/bt-permissions#discover-local-devices -->
<uses-permission
android:name="android.permission.BLUETOOTH_ADMIN"
android:maxSdkVersion="30" />
<uses-permission
android:name="android.permission.BLUETOOTH_ADVERTISE"
android:minSdkVersion="31" />
<uses-permission
android:name="android.permission.BLUETOOTH_CONNECT"
android:minSdkVersion="31" />
<uses-permission
android:name="android.permission.BLUETOOTH_SCAN"
android:minSdkVersion="31"
android:usesPermissionFlags="neverForLocation"
tools:targetApi="s" />
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"
android:maxSdkVersion="28" />
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"
android:maxSdkVersion="31"
android:minSdkVersion="29"
tools:ignore="CoarseFineLocation" />
<!-- https://developer.android.com/develop/connectivity/bluetooth/bt-permissions#features -->
<uses-feature
android:name="android.hardware.bluetooth"
android:required="false" />
<uses-feature
android:name="android.hardware.bluetooth_le"
android:required="true" />
These configuration values are available:
| Prop | Type | Description | Since |
|---|---|---|---|
endpointName | string | A human readable name for this endpoint, to appear on the remote device. | 4.1.0 |
endpointInfo | string | Identifing information about this endpoint, to appear on the remote device. Note: maximum length is 14 bytes. | 4.1.0 |
serviceID | ServiceID | An identifier to advertise your app to other endpoints. The serviceID value must uniquely identify your app. As a best practice, use the package name of your app (for example, com.example.myapp). | 4.1.0 |
In capacitor.config.json:
{
"plugins": {
"Nearby": {
"endpointName": "My App",
"endpointInfo": "TXkgQXBw",
"serviceID": "com.example.myapp"
}
}
}
In capacitor.config.ts:
/// <reference types="@capacitor-trancee/nearby" />
import { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = {
plugins: {
Nearby: {
endpointName: "My App",
endpointInfo: "TXkgQXBw",
serviceID: "com.example.myapp",
},
},
};
export default config;
initialize(...)reset()startAdvertising(...)stopAdvertising()startDiscovering()stopDiscovering()connect(...)disconnect(...)sendPayload(...)status()checkPermissions()requestPermissions(...)addListener('onPermissionChanged', ...)addListener('onBluetoothStateChanged', ...)addListener('onEndpointFound', ...)addListener('onEndpointLost', ...)addListener('onEndpointConnected', ...)addListener('onEndpointDisconnected', ...)addListener('onPayloadReceived', ...)initialize(options?: InitializeOptions | undefined) => Promise<InitializeResult>
Initializes Nearby for advertising and discovering of endpoints.
| Param | Type |
|---|---|
options | InitializeOptions |
Returns: Promise<InitializeResult>
Since: 4.1.0
reset() => Promise<void>
Stops and resets advertising and discovering of endpoints.
Since: 4.1.0
startAdvertising(options?: StartAdvertisingOptions | undefined) => Promise<void>
Starts advertising the local endpoint.
| Param | Type |
|---|---|
options | StartAdvertisingOptions |
Since: 4.1.0
stopAdvertising() => Promise<void>
Stops advertising the local endpoint.
Since: 4.1.0
startDiscovering() => Promise<void>
Starts discovering remote endpoints.
Since: 4.1.0
stopDiscovering() => Promise<void>
Stops discovering remote endpoints.
Since: 4.1.0
connect(options: ConnectOptions) => Promise<void>
| Param | Type |
|---|---|
options | ConnectOptions |
disconnect(options: DisconnectOptions) => Promise<void>
Disconnects from a remote endpoint.
Payloads can no longer be sent to or received from the endpoint after this method is called.
| Param | Type |
|---|---|
options | DisconnectOptions |
Since: 4.1.0
sendPayload(options: SendPayloadOptions) => Promise<void>
Sends a Payload to a remote endpoint.
| Param | Type |
|---|---|
options | SendPayloadOptions |
Since: 4.1.0
status() => Promise<StatusResult>
Returns advertising and discovering status, and discovered endpoints.
Returns: Promise<StatusResult>
Since: 4.1.0
checkPermissions() => Promise<PermissionStatus>
Check for the appropriate permissions to use Nearby.
Returns: Promise<PermissionStatus>
Since: 4.1.0
requestPermissions(permissions?: NearbyPermissions | undefined) => Promise<PermissionStatus>
Request the appropriate permissions to use Nearby.
| Param | Type |
|---|---|
permissions | NearbyPermissions |
Returns: Promise<PermissionStatus>
Since: 4.1.0
addListener(eventName: 'onPermissionChanged', listenerFunc: (granted: boolean) => void) => Promise<PluginListenerHandle>
Called when permission is granted or revoked for this app to use Nearby.
| Param | Type |
|---|---|
eventName | 'onPermissionChanged' |
listenerFunc | (granted: boolean) => void |
Returns: Promise<PluginListenerHandle>
Since: 4.1.0
addListener(eventName: 'onBluetoothStateChanged', listenerFunc: (state: BluetoothState) => void) => Promise<PluginListenerHandle>
Called when state of Bluetooth has changed.
| Param | Type |
|---|---|
eventName | 'onBluetoothStateChanged' |
listenerFunc | (state: BluetoothState) => void |
Returns: Promise<PluginListenerHandle>
Since: 4.1.0
addListener(eventName: 'onEndpointFound', listenerFunc: EndpointFoundCallback) => Promise<PluginListenerHandle>
Called when a remote endpoint is discovered.
| Param | Type |
|---|---|
eventName | 'onEndpointFound' |
listenerFunc | EndpointFoundCallback |
Returns: Promise<PluginListenerHandle>
Since: 4.1.0
addListener(eventName: 'onEndpointLost', listenerFunc: EndpointLostCallback) => Promise<PluginListenerHandle>
Called when a remote endpoint is no longer discoverable.
| Param | Type |
|---|---|
eventName | 'onEndpointLost' |
listenerFunc | EndpointLostCallback |
Returns: Promise<PluginListenerHandle>
Since: 4.1.0
addListener(eventName: 'onEndpointConnected', listenerFunc: EndpointConnectedCallback) => Promise<PluginListenerHandle>
Called when a remote endpoint is connected.
| Param | Type |
|---|---|
eventName | 'onEndpointConnected' |
listenerFunc | EndpointConnectedCallback |
Returns: Promise<PluginListenerHandle>
Since: 4.1.0
addListener(eventName: 'onEndpointDisconnected', listenerFunc: EndpointDisconnectedCallback) => Promise<PluginListenerHandle>
Called when a remote endpoint is disconnected or has become unreachable.
| Param | Type |
|---|---|
eventName | 'onEndpointDisconnected' |
listenerFunc | EndpointDisconnectedCallback |
Returns: Promise<PluginListenerHandle>
Since: 4.1.0
addListener(eventName: 'onPayloadReceived', listenerFunc: PayloadReceivedCallback) => Promise<PluginListenerHandle>
Called when a Payload is received from a remote endpoint.
| Param | Type |
|---|---|
eventName | 'onPayloadReceived' |
listenerFunc | PayloadReceivedCallback |
Returns: Promise<PluginListenerHandle>
Since: 4.1.0
| Prop | Type | Description | Since |
|---|---|---|---|
endpointID | EndpointID | A unique identifier for this endpoint. | 4.1.0 |
| Prop | Type | Description | Since |
|---|---|---|---|
endpointName | string | A human readable name for this endpoint, to appear on the remote device. | 4.1.0 |
endpointInfo | string | Identifing information about this endpoint, to appear on the remote device. Note: maximum length is 14 bytes. | 4.1.0 |
serviceID | ServiceID | An identifier to advertise your app to other endpoints. The serviceID value must uniquely identify your app. As a best practice, use the package name of your app (for example, com.example.myapp). | 4.1.0 |
| Prop | Type | Description | Since |
|---|---|---|---|
endpointInfo | string | Identifing information about this endpoint. Note: maximum length is 14 bytes. | 4.1.0 |
| Prop | Type | Description | Since |
|---|---|---|---|
endpointID | EndpointID | The identifier for the remote endpoint to connect to. | 4.1.0 |
| Prop | Type | Description | Since |
|---|---|---|---|
endpointID | EndpointID | The identifier for the remote endpoint to disconnect from. | 4.1.0 |
| Prop | Type | Description | Since |
|---|---|---|---|
endpointID | EndpointID | The identifier for the remote endpoint to which the payload should be sent. | 4.1.0 |
endpointIDs | string[] | The identifiers for the remote endpoints to which the payload should be sent. | 4.1.0 |
payload | string | The Payload to be sent. | 4.1.0 |
| Prop | Type |
|---|---|
isAdvertising | boolean |
isDiscovering | boolean |
| Prop | Type | Description | Since |
|---|---|---|---|
bluetooth | PermissionState | BLUETOOTH_ADVERTISE Required to be able to advertise to nearby Bluetooth devices. BLUETOOTH_CONNECT Required to be able to connect to paired Bluetooth devices. BLUETOOTH_SCAN Required to be able to discover and pair nearby Bluetooth devices. BLUETOOTH Allows applications to connect to paired bluetooth devices. BLUETOOTH_ADMIN Allows applications to discover and pair bluetooth devices. | 4.1.0 |
location | PermissionState | ACCESS_FINE_LOCATION Allows an app to access precise location. ACCESS_COARSE_LOCATION Allows an app to access approximate location. | 4.1.0 |
| Prop | Type |
|---|---|
permissions | NearbyPermissionType[] |
| Prop | Type |
|---|---|
remove | () => Promise<void> |
| Prop | Type | Description | Since |
|---|---|---|---|
endpointID | EndpointID | The ID of the remote endpoint that was discovered. | 4.1.0 |
endpointName | string | A human readable name for this endpoint. | 4.1.0 |
endpointInfo | string | Identifing information about this endpoint. Note: maximum length is 14 bytes. | 4.1.0 |
A Payload sent between devices.
| Prop | Type | Description | Since |
|---|---|---|---|
payload | string | Payload data. | 4.1.0 |
Used to represent an endpoint.
string
Used to represent a service identifier.
string
'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'
'bluetooth' | 'location'
Called when a remote endpoint is discovered.
(_: Endpoint): void
Called when a remote endpoint is no longer discoverable.
(_: Endpoint): void
Called when a remote endpoint is connected.
(_: Endpoint): void
Called when a remote endpoint is disconnected or has become unreachable.
(_: Endpoint): void
Called when a payload is received from a remote endpoint. Depending on the type of the payload, all of the data may or may not have been received at the time of this call.
| Members | Value | Description | Since |
|---|---|---|---|
UNKNOWN | 'unknown' | The manager’s state is unknown. | 1.0.0 |
RESETTING | 'resetting' | A state that indicates the connection with the system service was momentarily lost. | 1.0.0 |
UNSUPPORTED | 'unsupported' | A state that indicates this device doesn’t support the Bluetooth low energy central or client role. | 1.0.0 |
UNAUTHORIZED | 'unauthorized' | A state that indicates the application isn’t authorized to use the Bluetooth low energy role. | 1.0.0 |
POWERED_OFF | 'poweredOff' | A state that indicates Bluetooth is currently powered off. | 1.0.0 |
POWERED_ON | 'poweredOn' | A state that indicates Bluetooth is currently powered on and available to use. | 1.0.0 |
FAQs
Uses Nearby Connections peer-to-peer networking API that allows apps to easily discover, connect to, and exchange data with nearby devices in real-time, regardless of network connectivity
We found that @capacitor-trancee/nearby demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh shares lessons from scaling a developer security startup to 10,000+ organizations in this founder interview.

Research
Socket Threat Research maps a rare inside look at OtterCookie’s npm-Vercel-GitHub chain, adding 197 malicious packages and evidence of North Korean operators.

Research
Socket researchers identified a malicious Chrome extension that manipulates Raydium swaps to inject an undisclosed SOL transfer, quietly routing fees to an attacker wallet.