npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

swizi

v6.8.2

Published

The Swizi sdk provides a way to access native methods such as retrieve the user, call generic actions or even getting a bar code inside your web plugin.

Readme

Swizi JS SDK

npm version downloads

This package provides a JavaScript interface to interact with native Swizi features on mobile devices (iOS/Android). It exposes a unified API for calling native capabilities such as clipboard, navigation, storage, geolocation, and more.

📦 Installation

npm install swizi
# Or with yarn
yarn add swizi

🏁 Initialization

To use this package, simply import it once at the beginning of your app:

import("swizi");

This will attach the swizi object to the global window object:

window.swizi.copyToClipboard("Hello", false);

Note: you don't need to assign the result of the import. Just importing it will make swizi globally available.

🔧 Basic Usage

await swizi.copyToClipboard("Hello World", true);

const platform = await swizi.getPlatform();
console.log(`Running on ${platform}`);

📘 API Documentation

Table of Contents

📋 Clipboard

copyToClipboard(text: string, sensitive: boolean): Promise<void>

Copy text to the clipboard. If sensitive is true, native code may treat the data as sensitive (e.g. avoid previews).

await swizi.copyToClipboard("secret", true);

🌐 Wifi & Network

connectToWifi(ssid, identity, pwd, wifiSecurity, eapType, authType, captivePortal): Promise<object|null>

Connect to a secure or open Wifi network. Returns parsed JSON or null.

const result = await swizi.connectToWifi(
  "MySSID",
  "identity",
  "password",
  1,
  "PEAP",
  "MSCHAPv2",
  false,
);
console.log(result);

getWifiInfos(): Promise<object|null>

Get current Wifi network info (structure depends on platform).

const info = await swizi.getWifiInfos();

📦 Storage

Namespaced Storage

const storage = swizi.createStorage("plugin_");
await storage.setItem("foo", "bar");
const value = await storage.getItem("foo");
await storage.removeItem("foo");
await storage.clear();
const allKeys = await storage.keys();

Global Key/Value

await swizi.setItemForKey("hello", "greeting");
const value = await swizi.getItemForKey("greeting");

🧭 Navigation

navigate(deeplink: string): Promise<void>

Navigate to a deep link.

await swizi.navigate("swz://views/home");

goBack(): Promise<void>

Go back in the navigation stack.

await swizi.goBack();

interceptBackNavigation(intercept = true): Promise<void>

Intercept native back navigation and route it to JS.

await swizi.interceptBackNavigation();

performGenericAction(actionID: string, params?: object): Promise<void>

Trigger a generic action in the app.

await swizi.performGenericAction("openPlanning", { foo: "bar" });

openAppSettings(): Promise<void>

Open the app settings on the device.

await swizi.openAppSettings();

💬 UI & Interaction

displayPopup(title: string, content: string): Promise<void>

Show a popup dialog.

await swizi.displayPopup("Alert", "Something went wrong");

displayMenu(title: string, actions: Array): Promise<void>

Show a menu or bottom sheet.

await swizi.displayMenu("Options", [{ label: "Delete", color: "danger", event: "delete_item" }]);

setViewTitle(title: string): Promise<void>

Change the title of the current view.

await swizi.setViewTitle("My new title");

setViewActions(actions: Array): Promise<void>

Set the action buttons on the current view.

await swizi.setViewActions([
  {
    icon: "business",
    color: "primary_base",
    event: "select_site",
    badge: true,
  },
]);

readQRCode(title?: string, fullscreen?: boolean, multipleTimes?: boolean, action?: object): Promise<void>

Open a QR code scanner. Listen for results via events (see Events section).

await swizi.readQRCode("Scan code", false, false, { label: "Manual entry", event: "manual" });

share(content: string): Promise<void>

Open the native share sheet.

await swizi.share("Check this out!");

downloadFile(url: string, fileName: string): Promise<void>

Download a file natively.

await swizi.downloadFile("https://example.com/file.pdf", "file.pdf");

getColor(colorName: string): Promise<{r:number,g:number,b:number,a:number}|null>

Get a named color as RGBA.

const color = await swizi.getColor("COLOR_BUTTON_BACK");

getPrint(canvas?: string): Promise<string>

Send content to a Zebra printer.

const result = await swizi.getPrint(base64Image);

🌍 Device & App Info

isPluginBridgeReady(): boolean

Returns true if a native bridge is available.

getPlatform(): Promise<"ios"|"android">

Returns platform string.

getPlatformVersion(): Promise<object|null>

Returns OS version object.

getVersion(): Promise<{version:string,buildNumber:string}|null>

Returns app version/build.

getManifest(): Promise<object|null>

Returns plugin manifest and parsed configuration.

getLang(): Promise<{lang:string}|null>

Returns current language.


📍 Location & Tracking

getLocation(forceRefresh?: boolean): Promise<{result:string,lat?:number,lon?:number}|null>

Get device location. Returns { result: "success", lat, lon } or { result: "location_unauthorized" }.

const location = await swizi.getLocation(true);

trackUserLocation(): Promise<object|null>

Start continuous location tracking.

const status = await swizi.trackUserLocation();

stopTrackUserLocation(): Promise<void>

Stop location tracking.

await swizi.stopTrackUserLocation();

getUserLocation(): Promise<void>

Request a one-shot user location event (listen via onEvent).


👤 User & Auth

getUser(): Promise<object|null>

Returns the connected user object.

getToken(): Promise<string>

Returns current user JWT.

getUserPhoto(userId?: number): Promise<void>

Request user photo (event-based response).


📑 Manifest

See Device & App Info (getManifest).


📊 Analytics

sendStat(key: string, segmentation?: object): Promise<void>

Send an analytics/statistics event.

await swizi.sendStat("search", { query: "hello" });

🧩 Events & Logging

onEvent(listener: function): void / removeEvent(listener: function): void

Subscribe/unsubscribe to native-originated events dispatched as swiziEvent on document.

const handler = (ev) => {
  console.log("Swizi event", ev.detail);
};
swizi.onEvent(handler);
swizi.removeEvent(handler);

Common emitters: readQRCode, getUserPhoto, getUserLocation, trackUserLocation.

log(type: "log"|"warn"|"error", message: string): void

Console logging helper.

swizi.log("warn", "Something happened");

Deprecated

setTitle() → use setViewTitle() instead.


Note: Many functions return parsed JSON objects. Event-based APIs emit swiziEvent with payloads; inspect ev.detail for data.