nsh README

The project's README from github.com/longbridge/nsh. As one markdown file: README.md.

Native Shell (NSH)

Build once, native everywhere. Native Shell is a native UI framework for iOS, Android, macOS, Windows, Linux and the web, built in Rust. It unifies components, state, logic and API, with app-owned visual design and platform rendering: native views on iOS, Android, macOS, Windows and Linux, HTML on the web, GPUI in GPUI apps, character Cells in a terminal, with the platform's own text, input and interaction (a menu is a popup on the desktop and a sheet on a phone). Write the app in TSX and extend it with Rust components, modules and classes through nshm crates, or write the whole app in Rust.

image

Package it as a standalone app on every platform, or embed it in an existing one. On the same engine, apps load TSX modules at run time — plugins, features, UI generated by AI — delivered as signed packages and run in a sandbox the host configures.

Documentation, guides and live demos: nsh.dev. Follow @native_shell on X for updates.

Goals

Native views and interaction, with an app-owned design: NSH shares components, state and APIs across platforms, while the app controls colors, typography, spacing, shapes and motion. nsh/base provides the behavior and accessible structure of common controls such as Button, Checkbox and Switch; apps and community libraries give them a look. Platform modules expose capabilities specific to their platforms, such as the mobile system tab bar.

Read Goals and design principles for the component boundaries and how these goals guide Rust apps, TSX modules and AI-generated UI.

Features

Platforms

Platform Drawn with Embed with Requires
iOS UIKit, CoreText NshAppView (Swift, NativeShell.xcframework) iOS 15+
Android Android views, StaticLayout NshView (Java / Kotlin, nsh.aar) Android 8 (API 26)+
macOS AppKit, Core Animation, CoreText AppView (Rust, nsh-platform-macos) macOS 14+
Windows Win32, Direct2D, DirectWrite AppView (Rust, nsh-platform-windows) Windows 10 1809+
Linux GTK 4, Pango AppView (Rust, nsh-platform-linux) GTK 4.14+
GPUI (macOS, Windows, Linux) GPUI (GPUI Fast) AppView (Rust, a GPUI view, nsh-platform-gpui) macOS, Windows; Linux with Vulkan
Terminal ratatui, the terminal's Cell grid AppView (Rust, an area of a ratatui frame, nsh-platform-tui) Terminals on macOS, Windows, Linux
Web HTML, CSS createPlayer (JavaScript) or an iframe Modern browsers

Each desktop runs and packages apps with its own backend (AppKit, Win32, GTK 4). The GPUI backend draws with GPUI on all three desktops and embeds NSH in GPUI and GPUI Kit apps; nsh run --target gpui shows an app as they do. The web platform (nsh run --target web, nsh package --target web) publishes apps as static sites and runs the website's live demos. The terminal backend (nsh run --target tui) draws apps on a terminal's character grid in its own colors, with the keyboard and the mouse.

Quick start

Install the nsh command (other ways):

macOS / Linux
curl -fsSL https://nsh.dev/install.sh | sh

The nightly build of the latest main, rebuilt every night that it changes:

curl -fsSL https://nsh.dev/install.sh | sh -s -- --nightly
Homebrew
brew install longbridge/tap/nsh
MacPorts
sudo port install native-shell
Windows (PowerShell)
irm https://nsh.dev/install.ps1 | iex

The nightly build:

$env:NSH_VERSION = 'nightly'; irm https://nsh.dev/install.ps1 | iex
From source (macOS / Linux)

Build and install the latest main from source (Git, Rust and the platform build dependencies required):

curl -fsSL https://nsh.dev/install.sh | sh -s -- --source

Re-run to update. The checkout stays in ~/.nsh/source for runtime builds.

Choose how to write your app:

TSX TSX extended with Rust Rust
Create nsh init my-app --template ts nsh init my-app --template mixed nsh init my-app --template rust
Write TSX components, Tailwind classes and signals TSX screens, importing components, modules and classes from the app's nshm crate in ext/ Rust components, typed styles and signals
Iterate Hot updates that preserve state TSX hot; Rust changes restart Rebuild and restart on Rust changes
Toolchain nsh nsh and Rust nsh and Rust

nsh init starts a TSX app by default. When the app needs Rust (a parser, a storage engine, a native view, heavy computation), add an nshm crate in ext/ or a published one, and TSX imports it with types generated from the Rust signatures; see nshm. A whole app in Rust ships with no JavaScript VM; see Building with Rust. Rust builds work with the standard Cargo or huacnlee/cargo.

Run the app on your chosen platform:

iOS
nsh run my-app --target ios        # iOS simulator; requires Xcode
Android
nsh run my-app --target android    # emulator or device; requires the Android SDK
macOS
nsh run my-app --target macos      # AppKit window
Windows
nsh run my-app --target windows    # Win32 window
Linux
nsh run my-app --target linux      # GTK 4 window
GPUI (macOS, Windows, Linux)
nsh run my-app --target gpui       # as GPUI apps that embed it show it
Terminal
nsh run my-app --target tui        # in the current terminal
Web
nsh run my-app --target web        # open in the browser

The TSX template includes App.tsx, nsh.json and tsconfig.json, with generated TypeScript declarations in .nsh/types for your editor. The mixed template adds an nshm crate in ext/<name>-native. The Rust template includes a Cargo project with its root component in src/lib.rs. Logs and errors show in the terminal. What each platform needs: Installation.

Examples

Example What it shows
examples/gallery A tour of what NSH supports: lists, navigation, forms, controls, gestures, animation, images, styles, text, web view and video, fetch
examples/counter The smallest app
examples/tasks A small app with a store, pages, a list, a system alert and tests, laid out as the Coding Guides say
examples/rust-exports A TSX app using a component, a module and a class of its own Rust crate
examples/hopper A dark, tabbed dashboard built only from primitives: interactive canvas charts, sliders, menus, animation
examples/desktop A desktop app with a title bar and menus of its own (nsh/desktop)
examples/embed-ios, examples/embed-android NSH inside existing native apps, with a native component the app registers
examples/tasks-rs The same tasks app written only in Rust
examples/gallery-rs The gallery written in Rust: an app with no TSX and no QuickJS
examples/bench Rust components against the same components in TSX
cargo run

Skills for AI coding agents

Install the NSH skills for your coding agent (Claude Code, Codex, Cursor, Gemini CLI and others), so it follows NSH's model in TSX, TSX extended with Rust, or Rust:

npx skills add longbridge/nsh
Skill What it gives the agent
nsh Building apps in TSX, TSX extended with Rust nshm crates, or Rust: the Coding Guides, a page per mode, tooling, and a tested app in TSX and in Rust
nsh-design-guides The Design Guides, for any screen, interaction or interface copy

Acknowledgements

NSH builds on the ideas of these projects:

License

Licensed under the Apache License, Version 2.0.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be licensed under Apache-2.0, without any additional terms or conditions.

nsh (longbridge/nsh)

Searching Database…

3.1K ·GitHub
What is this?NSH is a Rust engine for building cross-platform apps where screens are written in TSX (or Rust), and each platform renders them with its own native UI: UIKit on iOS, Android views on Android, AppKit on macOS, Win32/Direct2D on Windows, GTK 4 on Linux, GPUI on desktops, or HTML on the web.
Is this a framework I build my whole app with, or something I just embed?It works both ways: you can build a standalone app entirely with NSH, or embed NSH inside an existing native app alongside things like maps and web views.
How do I get started with it?Install the 'nsh' CLI via Homebrew on macOS/Linux or the PowerShell installer on Windows, then run 'nsh init my-app --template ts' (or '--template rust' / '--template mixed'), and 'nsh run --target ' to launch it.
What OS versions does each platform need?iOS 15+, Android 9 (API 28)+, macOS 14+, Windows 10 1809+, and GTK 4.14+ on Linux; the GPUI backend additionally needs Vulkan on Linux.
If TSX screens can be delivered at runtime, is that a security risk?Dynamically delivered TSX modules must be signed packages and they run inside a sandbox whose capabilities the host app configures, so hosts control what loaded screens are allowed to do.
Do I write my app in Rust or in TSX?Either, or both: Rust gives typed components and signals with rebuild-on-change, TSX gives Tailwind-styled components with hot updates that preserve state, and a 'mixed' template lets TSX screens import your Rust components.
What does the GPUI backend give me over plain native views?The GPUI backend renders the same app with GPUI on all three desktop OSes instead of each system's native toolkit, and it can embed directly inside other GPUI or GPUI Kit apps.
Can AI tools generate NSH screens?Yes — NSH generates TypeScript declarations and model-readable documentation specifically so AI-generated TSX and Tailwind screens can be produced and run natively on each platform.
What do the example apps cover?They range from a minimal 'counter' app to a full widget 'gallery', a Rust-only version of that gallery with no TSX/QuickJS, native-embedding demos for iOS and Android, and a benchmark comparing Rust components against the same components in TSX.
What are similar projects?react-native, ng-native, perry, expo, lynx, weex, PakePlus, native
Creator
longbridge
Size
84.2 MB
Stars
3.1K
Age
1mo
Commits · 90 Days