Convert Figma logo to code with AI

microsoft logoreact-native-macos

A framework for building native macOS apps with React.

3,761
146
3,761
126

Top Related Projects

A framework for building native applications using React

117,268

:electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS

91,910

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.

Make any web page a desktop application

9,046

A library for building cross-platform native desktop applications with Node.js and CSS 🚀. React NodeGui : https://react.nodegui.org and Vue NodeGui: https://vue.nodegui.org

8,066

:zap: Native, high-performance, cross-platform desktop apps - built with Reason!

Quick Overview

React Native for macOS is an extension of the React Native framework, allowing developers to build native macOS desktop applications using React and JavaScript. It provides a way to create cross-platform apps that can run on both mobile devices and macOS, sharing a significant portion of the codebase.

Pros

  • Enables cross-platform development for iOS, Android, and macOS using a single codebase
  • Leverages the power and flexibility of React Native for desktop application development
  • Provides access to native macOS APIs and components
  • Allows for code reuse between mobile and desktop versions of an app

Cons

  • Still in experimental stage, which may lead to stability issues and frequent changes
  • Limited community support compared to more established frameworks
  • May have performance limitations compared to fully native macOS applications
  • Requires knowledge of both React Native and macOS development concepts

Code Examples

  1. Creating a simple macOS window:
import React from 'react';
import { AppRegistry, View, Text } from 'react-native-macos';

const App = () => (
  <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
    <Text>Hello, macOS!</Text>
  </View>
);

AppRegistry.registerComponent('MyMacOSApp', () => App);
  1. Using macOS-specific components:
import React from 'react';
import { NSButton, NSTextField } from 'react-native-macos';

const MacOSForm = () => (
  <>
    <NSTextField placeholder="Enter your name" />
    <NSButton title="Submit" bezelStyle="rounded" />
  </>
);
  1. Accessing macOS APIs:
import { NativeModules } from 'react-native-macos';

const { MacOSNotification } = NativeModules;

MacOSNotification.showNotification('Hello', 'This is a macOS notification');

Getting Started

To start using React Native for macOS:

  1. Install React Native CLI:

    npm install -g react-native-cli
    
  2. Create a new React Native project:

    react-native init MyMacOSApp --template react-native-macos-template
    
  3. Navigate to the project directory and run:

    cd MyMacOSApp
    react-native run-macos
    

This will set up a new React Native project with macOS support and launch the app in the macOS simulator.

Competitor Comparisons

A framework for building native applications using React

Pros of React Native

  • Larger community and ecosystem, with more third-party libraries and resources
  • More comprehensive documentation and tutorials
  • Supports a wider range of platforms, including iOS, Android, and web

Cons of React Native

  • Less optimized for macOS-specific features and performance
  • May require additional configuration or workarounds for macOS development
  • Potentially slower updates for macOS-specific issues or improvements

Code Comparison

React Native (for iOS):

import { Platform, StyleSheet } from 'react-native';

const styles = StyleSheet.create({
  container: {
    ...Platform.select({
      ios: { paddingTop: 20 },
      android: { paddingTop: 0 },
    }),
  },
});

React Native macOS:

import { Platform, StyleSheet } from 'react-native';

const styles = StyleSheet.create({
  container: {
    ...Platform.select({
      macos: { paddingTop: 20 },
      ios: { paddingTop: 20 },
      android: { paddingTop: 0 },
    }),
  },
});

The main difference is the addition of the macos platform in the Platform.select method, allowing for macOS-specific styling and behavior.

117,268

:electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS

Pros of Electron

  • Cross-platform development for desktop apps (Windows, macOS, Linux)
  • Large ecosystem and community support
  • Easier learning curve for web developers

Cons of Electron

  • Higher resource consumption and larger app size
  • Performance limitations compared to native apps
  • Security concerns due to Chromium's attack surface

Code Comparison

Electron (main process):

const { app, BrowserWindow } = require('electron')

function createWindow () {
  const win = new BrowserWindow({ width: 800, height: 600 })
  win.loadFile('index.html')
}

app.whenReady().then(createWindow)

React Native macOS:

import { AppRegistry } from 'react-native';
import App from './App';

AppRegistry.registerComponent('MyApp', () => App);

React Native macOS focuses on creating native macOS applications using React Native, while Electron enables cross-platform desktop app development using web technologies. Electron has a broader reach and more extensive community support, but React Native macOS offers better performance and a more native look and feel for macOS applications. The code structure differs significantly, with Electron using a main process and renderer process approach, while React Native macOS follows a more React-like component structure.

91,910

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.

Pros of Tauri

  • Smaller app size and better performance due to native system components
  • Cross-platform support for Windows, macOS, and Linux
  • Flexibility to use any frontend framework (React, Vue, Svelte, etc.)

Cons of Tauri

  • Less mature ecosystem compared to React Native
  • Steeper learning curve for developers new to Rust
  • Limited mobile support (currently in alpha)

Code Comparison

React Native macOS:

import React from 'react';
import { View, Text } from 'react-native';

const App = () => (
  <View>
    <Text>Hello, macOS!</Text>
  </View>
);

Tauri:

#[tauri::command]
fn greet(name: &str) -> String {
    format!("Hello, {}! You've been greeted from Rust!", name)
}

fn main() {
    tauri::Builder::default()
        .invoke_handler(tauri::generate_handler![greet])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

React Native macOS focuses on extending React Native to macOS, providing a familiar development experience for React Native developers. Tauri, on the other hand, offers a more native approach using web technologies for the frontend and Rust for the backend, resulting in smaller, faster applications with broader desktop platform support.

Make any web page a desktop application

Pros of Nativefier

  • Simpler to use for non-developers, as it can create desktop apps from any website
  • Supports multiple platforms (Windows, macOS, Linux) out of the box
  • Faster development process for basic web-to-desktop app conversion

Cons of Nativefier

  • Limited customization options compared to React Native for macOS
  • Less native look and feel, as it's essentially a wrapped web app
  • Performance may not be as optimized as a truly native application

Code Comparison

React Native for macOS:

import { AppRegistry, StyleSheet, Text, View } from 'react-native';

const App = () => (
  <View style={styles.container}>
    <Text>Hello, macOS!</Text>
  </View>
);

Nativefier:

const nativefier = require('nativefier').default;

nativefier({
  name: 'My App',
  targetUrl: 'https://example.com',
  platform: 'mac',
  arch: 'x64',
  out: './output'
});

Summary

React Native for macOS offers more native integration and customization but requires more development expertise. Nativefier provides a quick solution for creating desktop apps from websites across multiple platforms but with less native functionality and performance optimization.

9,046

A library for building cross-platform native desktop applications with Node.js and CSS 🚀. React NodeGui : https://react.nodegui.org and Vue NodeGui: https://vue.nodegui.org

Pros of NodeGUI

  • Uses native Qt widgets, resulting in a more native look and feel
  • Potentially better performance due to direct use of C++ bindings
  • Supports cross-platform development for desktop applications (Windows, macOS, Linux)

Cons of NodeGUI

  • Smaller community and ecosystem compared to React Native
  • Steeper learning curve for developers not familiar with Qt
  • Limited mobile development capabilities

Code Comparison

NodeGUI:

const { QMainWindow, QWidget, QLabel, FlexLayout } = require("@nodegui/nodegui");

const win = new QMainWindow();
const centralWidget = new QWidget();
centralWidget.setObjectName("myroot");
const rootLayout = new FlexLayout();
centralWidget.setLayout(rootLayout);

const label = new QLabel();
label.setText("Hello World");
rootLayout.addWidget(label);

React Native macOS:

import React from 'react';
import { View, Text } from 'react-native';

const App = () => (
  <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
    <Text>Hello World</Text>
  </View>
);

export default App;

Both frameworks offer unique approaches to desktop application development. NodeGUI provides a more native experience with Qt widgets, while React Native macOS leverages the familiar React ecosystem for macOS development. The choice between them depends on specific project requirements, target platforms, and developer expertise.

8,066

:zap: Native, high-performance, cross-platform desktop apps - built with Reason!

Pros of Revery

  • Native performance with OCaml/Reason
  • Cross-platform support for desktop and web
  • Lightweight and fast startup times

Cons of Revery

  • Smaller community and ecosystem compared to React Native
  • Steeper learning curve for developers unfamiliar with OCaml/Reason
  • Limited mobile platform support

Code Comparison

React Native macOS:

import React from 'react';
import { View, Text } from 'react-native';

const App = () => (
  <View>
    <Text>Hello, macOS!</Text>
  </View>
);

Revery:

open Revery;
open Revery.UI;

let app = () =>
  <View>
    <Text text="Hello, Revery!" />
  </View>;

App.start(app);

Summary

React Native macOS leverages the familiar React ecosystem and JavaScript/TypeScript for building macOS applications, while Revery offers a native, cross-platform approach using OCaml/Reason. React Native macOS benefits from a larger community and extensive React Native ecosystem, making it easier for web developers to transition. Revery, on the other hand, provides better performance and a more lightweight solution, but with a steeper learning curve and smaller ecosystem. The choice between the two depends on the developer's familiarity with the languages, desired performance, and target platforms.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

React Native for macOS

Build native macOS apps with React.

React Native for macOS is released under the MIT license. Current npm package version. PRs welcome!

See the official React Native website for an introduction to React Native.

React Native is a framework developed by Facebook that enables you to build world-class application experiences on native platforms using a consistent developer experience based on JavaScript and React. The focus of React Native is on developer efficiency across all the platforms you care about - learn once, write anywhere.

  • Declarative. React makes it painless to create interactive UIs. Declarative views make your code more predictable and easier to debug.
  • Component-Based. Build encapsulated components that manage their state, then compose them to make complex UIs.
  • Developer Velocity. See local changes in seconds. Changes to JavaScript code can be live reloaded without rebuilding the native app.
  • Portability. Reuse code across iOS, Android, and other platforms.

React Native is developed and supported by many companies and individual core contributors. Find out more in our ecosystem overview.

This repository is a working fork of facebook/react-native that adds support for the official React Native for macOS implementation from Microsoft.

You can read more about the macOS implementation in our website - React Native for Windows + macOS. You can read about how we manage this fork in our docs folder.

Contents

📋 Requirements

React Native apps may target iOS 15.1 and Android 7.0 (API 24) or newer. You may use Windows, macOS, or Linux as your development operating system, though building and running iOS apps is limited to macOS. Tools like Expo can be used to work around this.

🎉 Building your first React Native app

Follow the Getting Started guide. The recommended way to install React Native depends on your project. Here you can find short guides for the most common scenarios:

Requirements

You can run React Native for macOS apps on Mac devices with versions Big Sur (11) or newer.

For a full and detailed list of the system requirements and how to set up your development platform, see our System Requirements documentation on our website.

Getting Started

See the Getting Started Guide on our React Native for Windows + macOS website to build your first React Native for macOS app.

Logging Issues

Search the existing issues and try to make sure your problem doesn’t already exist before opening a new issue. If your issue doesn't exist yet, try to make sure you provide as much information as possible to us so we can help you sooner. It’s helpful if you include information like:

  • The version of macOS, React Native, React Native macOS extension where you ran into the issue.
  • A stack trace and reduced repro case when possible.
  • Ensure the appropriate template is used when filing your issue(s).

Contributing

See Contributing guidelines for how to set up your fork of the repo and start a PR to contribute to React Native for macOS.

Good First Issue and help wanted are great starting points for PRs.

Documentation

The full documentation for React Native can be found on the documentation website. The React Native documentation discusses components, APIs, and topics that are specific to React Native. For further documentation on the React API that is shared between React Native and React DOM, refer to the React documentation.

The source for the React Native documentation and website is hosted on a separate repository, @facebook/react-native-website.

React Native for Windows + macOS has its own separate documentation site where Windows and macOS specific information, like API docs and blog updates live. We are still working on the documentation for macOS, contributions are welcome!

If you're looking for sample code, just browse the RNTester folder for examples

Git flow and syncing with upstream

For more details on how this fork handles keeping up with upstream, and how the general git flow works, check out this dedicated document.

License

The React Native for macOS extension, including modifications to the original Facebook source code, and all newly contributed code is provided under the MIT License. Portions of the React Native for macOS extension derived from React Native are copyright Facebook.

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

🚀 Upgrading

Upgrading to new versions of React Native may give you access to more APIs, views, developer tools, and other goodies. See the Upgrading Guide for instructions.

React Native releases are discussed in this discussion repo.

👏 How to Contribute

The main purpose of this repository is to continue evolving React Native core. We want to make contributing to this project as easy and transparent as possible, and we are grateful to the community for contributing bug fixes and improvements. Read below to learn how you can take part in improving React Native.

Code of Conduct

Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please read the full text so that you can understand what actions will and will not be tolerated.

Contributing Guide

Read our Contributing Guide to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes to React Native.

Open Source Roadmap

You can learn more about our vision for React Native in the Roadmap.

Good First Issues

We have a list of good first issues that contain bugs which have a relatively limited scope. This is a great place to get started, gain experience, and get familiar with our contribution process.

Discussions

Larger discussions and proposals are discussed in @react-native-community/discussions-and-proposals.

📄 License

React Native is MIT licensed, as found in the LICENSE file.

React Native documentation is Creative Commons licensed, as found in the LICENSE-docs file.

NPM DownloadsLast 30 Days