DEV Community

uuware
uuware

Posted on

Lupine.js Native: five platforms in depth

Lupine.js Native: One Codebase, Five Platforms (iOS, Android, macOS, Windows, and Web)

When I first introduced Lupine.js (The Lightweight Frontend & Efficient Backend Framework), it was built around one simple goal: full-stack web development with SSR, CSS-in-JS, and a ~7 KB frontend—without the bloat of modern meta-frameworks.

Since then, we completed a major architectural refactoring. Today, Lupine.js 1.x takes that same philosophy—small binaries, zero hidden magic, direct control—and extends it far beyond the browser.

With lupine.native, one TypeScript/TSX codebase now runs natively across 5 platforms:

  • iOS (UIKit)
  • Android (Android Views / Kotlin + JNI)
  • macOS (AppKit)
  • Windows (Single native Win32 window rendered with Direct2D & DirectWrite)
  • Web (Standard DOM + full-stack SSR via lupine.web and lupine.api)

No WebView. No Virtual DOM. No custom compiler. Just signals driving each platform's real controls, producing 4 to 6 MB native release builds with the JavaScript engine linked right inside.

macOS fullstack-note

Windows (responsive-starter) Web (doc-starter)
Windows Web
iOS (fullstack-note) iOS (cv-starter) Android (fullstack-note) Android Dark (responsive-starter)
iOS Home iOS CV Android Components Android Dark

Why a "Third Path" for Cross-Platform?

Most cross-platform frameworks fall into one of two camps:

  1. Web-in-a-shell (WebView / Electron / Tauri): Easy to share code with the web, but you ship a browser engine or rely on WebView quirks, deal with browser memory overhead, and miss out on truly native UI primitives.
  2. Virtual DOM + Async Native Bridge: You get native views, but your UI continuously diffs virtual trees in JavaScript and serializes batches of mutations across a bridge to the UI thread—causing subtle input lag or gesture desyncs under load.

lupine.native takes a third path:

  1. Fine-grained signals instead of a Virtual DOM: Component functions run once. Reactive expressions ({count} or {() => ...}) bind directly to the exact property of the native control or DOM node.
  2. Synchronous JS on the UI thread: JavaScript runs directly on the UI thread. When you tap a button or type a character, the event handler, all resulting signal updates, and a single Yoga flexbox layout pass happen synchronously in one step—inputs and gestures never lag a frame behind.
  3. No custom compiler: You write standard TSX, bundled by esbuild. Reactivity is explicit and transparent: pass a function (() => count() * 2 or {count}) where you want reactivity.

What It Looks Like in Code

Here is a complete cross-platform counter + input app that runs identically on iOS, Android, macOS, Windows, and the Web:

import { createSignal, Platform, Text, TextInput, View } from 'lupine.native.core';
import { Button } from 'lupine.native.components';
import { runApp } from 'lupine.native.core/native'; // on the web: 'lupine.native.core/web'

export const App = () => {
  const [name, setName] = createSignal('');
  return (
    <View style={{ flex: 1, padding: 24, gap: 12, justifyContent: 'center' }}>
      <Text style={{ fontSize: 24, fontWeight: '700' }}>
        {() => `Hello ${name() || Platform.OS}`}
      </Text>
      <TextInput value={name} onChangeText={setName} placeholder='Your name' />
      <Button
        title='Clear'
        kind='primary'
        disabled={() => !name()}
        onPress={() => setName('')}
      />
    </View>
  );
};

runApp(App);
Enter fullscreen mode Exit fullscreen mode

When name changes on keystrokes, App does not re-render. Only the text property of that single UILabel / TextView / NSTextField / DirectWrite text block / DOM node and the disabled state of the button are updated.


Under the Hood: The Refactored Architecture

To cover all five platforms cleanly without duplicating framework logic, we split the core of Lupine.js into layered packages:

app/src (TSX) ──esbuild──▶ app.js / app.hbc (+ assets)
  ├── lupine.native.components   themes, i18n, router, Screen, forms, overlays, lists, charts, games
  ├── lupine.native.plugins      AdMob, Alipay, Apple/Google Sign-In, RevenueCat, WeChat, PDF, ONNX
  └── lupine.native.core         primitives, platform APIs, Yoga layout, `lupine-native` CLI
        ├── shells/ios           Objective-C++ ──▶ UIKit (iOS 15.1+)
        ├── shells/android       Kotlin + JNI  ──▶ Android Views (API 24+)
        ├── shells/macos         Objective-C++ ──▶ AppKit (macOS 11+)
        ├── shells/windows       C++ Win32     ──▶ Direct2D & DirectWrite + OpenGL 3.3 (Windows 10+)
        └── shells/web           TypeScript    ──▶ DOM + SSR (`renderToString`)
  └── lupine.core                signals, region-based renderer, themes, i18n, icons (shared with lupine.web!)
Enter fullscreen mode Exit fullscreen mode

1. One Core Renderer (lupine.core) Shared by Web & Native

During the refactoring, we extracted the reactive engine (createSignal, createMemo, createEffect) and the region-based tree/list reconciler into lupine.core—zero dependencies, zero DOM assumptions.

Both lupine.web (for web sites) and lupine.native.core (for 5-platform apps) run on this exact same renderer. Every platform simply implements a tiny Host<N> interface (createNode, setProp, setEvent, insert, remove).

2. Two Embedded JavaScript Engines: Hermes (Default) & QuickJS-ng

Rather than shipping external .dll or .framework runtime blobs next to your app, lupine.native builds the JS engine from source once and statically links it into your binary:

  • Hermes (default): Source code is compiled ahead-of-time to Hermes bytecode (.hbc) during the build.
    • On iOS, Android, and macOS, C++ talks to Hermes directly via JSI (engine_jsi.cpp).
    • On Windows, Hermes built from source talks JSI as well, and the whole .exe is cross-compiled straight from macOS or Linux with llvm-mingw. With --hermes=prebuilt, the app uses Microsoft's prebuilt hermes.dll through its Node-API C ABI (engine_napi.cpp)—a plain C interface, so even that .exe can be cross-compiled from macOS or Linux!
  • QuickJS-ng (--engine=quickjs): Available on iOS, macOS, and Windows for binaries a quarter to a third smaller and shorter GC pauses.

3. Five Native Platform Shells

Each shell is lean, purpose-built, and maps Lupine primitives directly to system capabilities:

  • iOS (shells/ios) & macOS (shells/macos): Objective-C++ shells driving UIKit (UIView, UILabel, UIGestureRecognizer, CALayer animations) and AppKit (NSView, multi-window desktop menus & startProcess).
  • Android (shells/android): Kotlin views (Views.kt, Input.kt, GLView.kt, Camera.kt, etc.) paired with a thin C++ JNI layer (android_host.cpp).
  • Windows (shells/windows): A single native Win32 window that paints the entire Yoga view tree with Direct2D and DirectWrite—requiring zero external runtimes and producing a single standalone .exe. Focused text inputs, <Video>, and <WebView> use real Win32/WebView2 controls, <GL> uses OpenGL 3.3, and a built-in software rasterizer fallback lets you run and inspect the .exe directly on macOS/Linux via Wine (or LUPINE_RENDERER=software).
  • Web (shells/web): Standard DOM elements with CSS Flexbox layout. Even better, your native app can live inside a full-stack lupine.web + lupine.api site with full SSR:
    • renderToString awaits async components (fetchData()) on the server and outputs real HTML + CSS @media rules (media({ base: 'column', mobileAbove: 'row' })) before any JS loads.
    • Using PageRouter with { keep: true }, navigating between SSR marketing/content pages and the app preserves your app's exact scroll positions, open tabs, and input state!

4. Write Shared C++ Modules Once for All Native Platforms

Need heavy image processing, audio DSP, or an existing C/C++ library? Add a native/module.cpp and register functions with lupineRegisterModules. You get automatic async worker-queue execution (native.call('calc.sum', buffer)) or synchronous UI-thread calls (native.callSync) across iOS, Android, macOS, and Windows from one C++ file.


Beyond Buttons: Everything Included

lupine.native isn't limited to basic forms and text. Out of the box, the same TSX API covers:

  • Graphics & 3D: <Canvas> (2D), <Svg>, <Icon>, and <GL> (full WebGL 2—even three.js runs as-is on all 5 platforms).
  • Media & Hardware: Low-latency Web Audio (miniaudio backend on native, Web Audio on web), microphone recording, <Camera>, barcode scanning, <Video>, notifications, geolocation, biometrics (Face ID / Touch ID / Windows Hello), haptics, clipboard, sharing, printing, and WebSockets.
  • UI Library (lupine.native.components): Unified cross-platform Pages + responsive NavBar (bottom tabs on mobile, side rail on desktop/wide screens), OverlayHost (sheets, dialogs, toasts), forms, pickers, DataTable, Markdown, QRCode/Barcode, charts, 2D game helpers, live theming (col(), deriveTheme), and i18n (tr(), addTexts). The groups of components and how one of them runs on every platform: Signals, styles and components.
  • On-Demand Native Plugins (lupine.native.plugins): Declared in package.json under lupineNative.plugins so unused SDKs add zero bytes—supporting WeChat, Alipay, Sign in with Apple, Google Sign-In, RevenueCat (purchases), AdMob, PDF rendering, and on-device AI inference with ONNX Runtime (Core ML on Apple, NNAPI on Android, Web Worker on Web).

Real Numbers: Binary Size & Performance

All benchmarks below are reproducible from apps/native-bench (measured on a 2020 Intel Core i7 MacBook Pro, Windows 11 Parallels VM, iPhone XR, Huawei nova 7, and REDMI Note 15 Pro):

Release Binary Size (Small App)

Platform Hermes from source (default) Hermes prebuilt QuickJS-ng
iOS (simulator) 3.9 MB 9.0 MB 2.9 MB
Android arm64 (APK) 5.4 MB 6.5 MB —
macOS 4.9 MB 14.4 MB 3.3 MB
Windows x64 (.exe) 4.8 MB 9.6 MB (with hermes.dll) 3.7 MB

On the Web:

  • Minimal lupine.web page (signals, TSX, rendering): 7.1 KB compressed (16.6 KB raw)
  • Minimal lupine.native app as a web page: 14.2 KB compressed (36.1 KB raw), or 18.4 KB with a themed Button

Engine & Device UI Performance

  • GC Pause (longest step while 400,000 objects are live):
    • Windows: 7.1 ms (Hermes source) / 1.5 ms (QuickJS-ng)
    • macOS: 3.2 ms (Hermes source) / 0.4 ms (QuickJS-ng)
  • Framework UI Operations (1,000 rows of 3 views):
    • Change 100 of 1,000 rows: 15.6 ms (iPhone XR), 6.9 ms (REDMI Note 15 Pro), 5.1 ms (macOS), 2.2 ms (Windows), 0.7 ms (Web)
    • Frame rates hit the display cap (60 fps on iPhone XR / Huawei nova 7 / Web, 120 fps on REDMI Note 15 Pro) across scrolling lists, fades, motion, Canvas 2D, and OpenGL scenes.

Developer Experience: 5 Targets From One Mac (or Docker)

You don't need five machines on your desk to build and test five platforms:

npx create-lupine@latest my-app     # Pick from 5 full-stack/cross-platform templates
cd my-app
npm install
npx lupine-native doctor            # Checks missing tools (Xcode, Android SDK, CMake, Wine...)
Enter fullscreen mode Exit fullscreen mode

Run any target with one command:

npm run dev                         # Full-stack Web + SSR + Node.js API (http://localhost:11080)
npm run run-mac                     # Native macOS app
npm run run-exe                     # Cross-compiles Windows .exe via llvm-mingw and runs it in Wine!
npm run native -- ios --app=my-app --run
npm run native -- android --app=my-app --run
Enter fullscreen mode Exit fullscreen mode

No Android Studio or Windows toolchain installed? Build inside a container with zero local setup:

npx lupine-native docker android --app=my-app
npx lupine-native docker windows --app=my-app
Enter fullscreen mode Exit fullscreen mode

And every template ships with real UI integration tests (npx lupine-native test <platform>) that drive actual native controls via testID (click, type, focus, text, sizes and positions) and capture screenshots—even driving a Windows 11 Parallels VM directly from macOS (--vm="Windows 11").

Templates Ready Out of the Box

Running npx create-lupine@latest gives you five starter templates that all build to iOS, Android, macOS, Windows, and Web:

  • fullstack-note: Tabs, side menu, authentication, and server-synced notes
  • fullstack-starter: Accounts, database-backed API, admin console, and 5-platform app
  • responsive-starter: Adaptive tabs/sidebar app with local notes, finance tracker, and tools
  • doc-starter: Markdown documentation site (lupine.press) packaged as native apps & GitHub Pages
  • cv-starter: Multi-language Markdown CV as a site and native app

Battle-Tested in Production

This isn't a toy architecture. We built Lupine.js and lupine.native by shipping real software with it—including a full production music app (with its website and admin console), a desktop video tool for macOS and Windows, and roughly 40 games and utility apps running across iOS, Android, macOS, Windows, and the Web (published on Google Play and the App Store).


Try Lupine.js Today

If you want one TypeScript codebase that covers SSR websites, Node.js APIs, and 4–6 MB native apps on iOS, Android, macOS, and Windows without dragging along a WebView or Virtual DOM:

Give Lupine.js a star on GitHub and spin up your first 5-platform app with npx create-lupine@latest!

Top comments (0)