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 🙏

© 2026 – Pkg Stats / Ryan Hefner

electron-native-share

v0.1.0

Published

Universal native Share API for Electron apps — macOS NSSharingService, Windows WinRT DataTransferManager

Readme

electron-native-share

CI npm

Universal native Share API for Electron apps. Brings the OS share sheet to your desktop app — macOS NSSharingServicePicker, Windows DataTransferManager.

Install

npm install electron-native-share

Prebuilt binaries are included for macOS and Windows. No C++ compiler required for most users.

Usage

import { share, canShare } from 'electron-native-share';

// Check if native sharing is available on this platform
if (canShare()) {
  console.log('Native share sheet available');
}

// Share content (from Electron main process)
const result = await share({
  title: 'Check this out',
  text: 'Hello from my Electron app!',
  url: 'https://example.com',
});

console.log(result);
// { method: 'native' }

Sharing files

await share({
  title: 'My document',
  files: ['/absolute/path/to/document.pdf'],
});

With a specific BrowserWindow

Pass the Electron BrowserWindow instance as the second argument so the share sheet anchors to the correct window:

import { BrowserWindow } from 'electron';
import { share } from 'electron-native-share';

const win = new BrowserWindow({ width: 800, height: 600 });

await share({ text: 'Hello!' }, win);

API

canShare(): boolean

Returns true if native sharing is available on the current platform (macOS or Windows).

share(options, browserWindow?): Promise<ShareResult>

Opens the native share sheet with the given content.

Options:

| Property | Type | Description | | -------- | ---------- | ----------------------------------- | | title | string? | Share title | | text | string? | Text content to share | | url | string? | URL to share | | files | string[]?| Array of absolute file paths |

At least one of title, text, url, or files must be provided.

Returns: Promise<ShareResult>

interface ShareResult {
  method: 'native' | 'cancelled';
}

Throws an Error if native sharing is not available on the current platform. Use canShare() to check before calling.

getNativeWindowHandle(browserWindow): Buffer | undefined

Utility to extract the native window handle from an Electron BrowserWindow.

Platform Support

| Platform | Method | Status | | -------- | --------------------------------- | ------ | | macOS | NSSharingServicePicker | ✅ | | Windows | WinRT DataTransferManager | ✅ | | Linux | Not supported | — |

How it works

This library provides direct access to native OS share sheets. There are no silent fallbacks — if native sharing isn't available, share() throws so your app can decide how to handle it (show a message, copy to clipboard, etc.).

if (canShare()) {
  const result = await share({ text: 'Hello!' });
  // result.method is 'native' or 'cancelled'
} else {
  // Handle unsupported platform your way
  clipboard.writeText('Hello!');
  showToast('Copied to clipboard');
}

The install script uses node-gyp-build || exit 0, so native addon build failures are silently ignored. On unsupported platforms the addon simply won't load, and canShare() will return false.

Building from source

If prebuilt binaries aren't available for your platform:

npm run build        # Compile TypeScript + native addon
npm run build:ts     # TypeScript only
npm run build:native # Native addon only (requires C++ toolchain)

Requirements for building native addon

  • macOS: Xcode command line tools
  • Windows: Visual Studio with C++ Desktop workload + Windows 10 SDK

Example Electron App

A minimal example app is included in examples/electron-app/:

cd examples/electron-app
npm install
npm start

License

MIT