React Native macOS Menubar demo from App.Js Conf 2023
Note: This was the minimal amount of code I needed for my demo, so there's a lot that could be better. Such as:
- Rewrite this in Swift
- Remove the main window / dock icon
- Remove the iOS / Android targets
- Make this work with Fabric as well
Steps to recreate this demo for yourself (and also if this repo doesn't built)
- Initialize a standard React Native template
npx react-native init menubar-example --template react-native@^0.71
cd menubar-example- Run the macos init command
npx react-native-macos-init
- Add the necessary modification to create a menubar app (marked in the :
- Add an
NSStatusItemproperty toAppDelegate.h - Initialize it and add an image / click handler to it's button in
applicationDidFinishLaunchingofAppDelegate.m - Create the click handler (I called it showPopover) to create and show an NSPopover with the ViewController that creates our RCTRootView in
AppDelegate.m - Override
loadViewinViewController.m(because Appkit can be annoying..)
- Add an
Menubar app tutorials:
- https://www.polpiella.dev/a-menu-bar-only-macos-app-using-appkit/
- https://sarunw.com/posts/how-to-make-macos-menu-bar-app/
- https://www.kodeco.com/450-menus-and-popovers-in-menu-bar-apps-for-macos
The calendar library I used (Thanks Wix!)