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

xdg-portal

v1.3.0

Published

A wrapper around dbus to ease the use of XDG Desktop Portals

Downloads

1,335

Readme

xdg-portal

A wrapper around dbus to ease the use of XDG Desktop Portals.

The naming of methods (including parameters), properties and signals is the exact same as in dbus.
As of now (August 2026) all portals are supported.

Installation

xdg-portal is available on npm:

npm install --save xdg-portal

Examples

Check if a portal is available

import * as portal from "xdg-portal";

const client = await portal.client();
// Version is a property available on all portals.
// Reading it will never throw, but instead return 0 if the portal cannot be reached
const version = await client.desktop.GlobalShortcuts.version;
if(version > 0) {
    // do something with the portal
}
client.close();

Show a notification (send and forget)

import * as portal from "xdg-portal";

const client = await portal.client();
// await, so the notification is sent before the client is closed
await client.desktop.Notification.showNotification({
  title: "Hello World",
  body: "This is a notification from my app.",
  icon: "dialog-information"
});
client.close();

Ask the user to share their account information (request and wait for a response)

import * as portal from "xdg-portal";

const client = await portal.client();
const userInfo = await client.desktop.Account.getUserInfo("");
if(userInfo.response === 0) // According to the XDG docs: 0 = success, 1 = cancelled, 2 = other error
    console.log("User info:", userInfo.results);
else
    console.error("The user denied access to their account information.");
client.close();

Listen for low memory warnings (subscribe to a signal)

import * as portal from "xdg-portal";

const client = await portal.client();
client.desktop.MemoryMonitor.LowMemoryWarning.addListener((level) => {
    console.log("Low memory warning:", level);
});
await new Promise(resolve => setTimeout(resolve, 60000)); // listen for 1 minute
client.close();

Check if a camera is present (read a property)

import * as portal from "xdg-portal";

const client = await portal.client();
const haveCamera = await client.desktop.Camera.IsCameraPresent;
console.log("Is camera present:", haveCamera);
client.close();

Get the current location (use a session)

import * as portal from "xdg-portal";

const client = await portal.client();
const session = await client.desktop.Location.CreateSession();
client.desktop.Location.LocationUpdated.once((data) => {
    console.log("Location:", data);
});
await client.desktop.Location.Start(session, "");
await new Promise(resolve => setTimeout(resolve, 5000)); // wait for 5 seconds to receive a location update
await session.Close();
client.close();

Connect to a custom dbus bus

import * as portal from "xdg-portal";

const options: portal.DBusConnectionOptions = {
    busAddress: "unix:path=/tmp/my-custom-bus"
};

const client = await portal.client(options);
// Use the client as usual
client.close();