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

react-native-nswindow

v0.0.4

Published

Multi-window support for react-native-macos using NSWindow

Downloads

599

Readme

react-native-nswindow

Multi-window support for React Native macOS. Create, modify, close, and observe native NSWindow instances from JavaScript.

Requirements

  • React Native macOS >= 0.81
  • macOS deployment target >= 14.0
  • New Architecture (TurboModules) enabled

Installation

npm install react-native-nswindow
cd macos && pod install

Usage

import NSWindowModule from 'react-native-nswindow';
import { AppRegistry } from 'react-native';

// Register a component to render in the new window
function MyWindow() {
  return <Text>Hello from a new window!</Text>;
}
AppRegistry.registerComponent('MyWindow', () => MyWindow);

// Create a window
const windowId = await NSWindowModule.addWindow({
  componentName: 'MyWindow',
  windowName: 'my-window',
  initialProps: {},
  title: 'My Window',
  width: 600,
  height: 400,
});

// Modify it
await NSWindowModule.modifyWindow(windowId, {
  title: 'Updated Title',
  backgroundColor: '#1e1e1e',
  vibrancy: 'sidebar',
});

// Listen for events
const sub = NSWindowModule.onWindowClose((id) => {
  console.log('Window closed:', id);
});
sub.remove(); // cleanup

API

Methods

| Method | Description | |--------|-------------| | addWindow(props: WindowProps) | Create a new window. Returns its ID. | | closeWindow(windowId) | Close a window. | | modifyWindow(windowId, props) | Modify window properties. | | listWindows() | List all tracked window IDs. | | getWindowState(windowId) | Get position, size, and state flags. | | focusWindow(windowId) | Make window key and bring to front. | | hideWindow(windowId) | Hide (order out) a window. | | showWindow(windowId) | Show (order front) a window. | | minimizeWindow(windowId) | Minimize to dock. | | deminimizeWindow(windowId) | Restore from dock. | | setFullScreen(windowId, bool) | Enter/exit full screen. | | bringToFront(windowId) | Order front. | | sendToBack(windowId) | Order back. | | getScreenInfo() | Get screen layout info (all screens, total bounds, main screen). |

Window Props

All properties are optional except componentName, windowName, and initialProps (on addWindow).

| Prop | Type | Default | Description | |------|------|---------|-------------| | x, y | number | 100 | Window origin | | width, height | number | 400×300 | Window size | | minWidth, minHeight | number | — | Minimum size constraints | | maxWidth, maxHeight | number | — | Maximum size constraints | | center | boolean | false | Center on screen | | title | string | windowName | Title bar text | | titleBarStyle | string | 'default' | 'default' | 'hidden' | 'hiddenInset' | 'transparent' | | vibrancy | string | 'none' | 'none' | 'sidebar' | 'menu' | 'popover' | 'fullScreenUI' | 'underWindowBackground' | 'hudWindow' | | backgroundColor | string | — | Any React Native color string (e.g. '#ff0000', 'rgba(0,0,0,0.5)', 'red') | | transparent | boolean | false | Set window non-opaque (required for translucent backgrounds) | | hasShadow | boolean | true | Window shadow | | resizable | boolean | true | Allow resize | | movable | boolean | true | Allow drag | | minimizable | boolean | true | Show minimize button | | closable | boolean | true | Show close button | | zoomable | boolean | true | Enable zoom button | | alwaysOnTop | boolean | false | Float above other windows | | level | string | 'normal' | 'normal' | 'floating' | 'modalPanel' | 'mainMenu' | 'statusBar' | 'screenSaver' | | show | boolean | true | Show immediately | | focusOnCreate | boolean | true | Make key on show | | autoSaveFrame | string | — | Persist frame position across launches | | stopShouldClose | boolean | false | Intercept close (window stays open) |

Events

| Event | Payload | Description | |-------|---------|-------------| | onWindowClose | windowId | Window was closed | | onWindowWillClose | windowId | Close was attempted (fires even if blocked) | | onWindowFocus | windowId | Became key window | | onWindowBlur | windowId | Resigned key window | | onWindowMove | { windowId, x, y } | Window moved | | onWindowResize | { windowId, width, height } | Window resized | | onWindowMinimize | windowId | Minimized to dock | | onWindowDeminimize | windowId | Restored from dock | | onWindowEnterFullScreen | windowId | Entered full screen | | onWindowExitFullScreen | windowId | Exited full screen | | onWindowOcclusionStateChange | { windowId, isVisible } | Window occlusion state changed (visible/occluded) | | onWindowBackingPropertiesChange | windowId | Backing properties changed (e.g. moved between Retina/non-Retina displays) | | onScreenInfoChange | — | Screen parameters changed (display added/removed/resized) |

Events use the New Architecture EventEmitter pattern. Each event method takes a callback and returns a subscription with a .remove() method:

import { useEffect } from 'react';
import NSWindowModule from 'react-native-nswindow';

useEffect(() => {
  const subs = [
    NSWindowModule.onWindowClose((windowId) => {
      console.log('closed:', windowId);
    }),
    NSWindowModule.onWindowMove(({ windowId, x, y }) => {
      console.log('moved:', windowId, x, y);
    }),
    NSWindowModule.onWindowResize(({ windowId, width, height }) => {
      console.log('resized:', windowId, width, height);
    }),
  ];
  return () => subs.forEach((s) => s.remove());
}, []);

How It Works

This is a C++ TurboModule (CxxTurboModule). An ObjC singleton (RNNSWindowHelper) manages the window dictionary, acts as NSWindowDelegate, and observes NSNotificationCenter for all window events. Window operations dispatch to the main thread; promises resolve via the JS invoker.

License

MIT