staydecent / nativescript-preact

Build cross-platform iOS and Android apps using Preact.
99 stars 3 forks source link

NativeScript Preact

This plugin integrates Preact and NativeScript, allowing you to build cross-platform iOS and Android apps using Preact.

Why? Because I prefer the (P)React pattern of building UIs over what Angular offers, and find that NativeScript has several technical advantages over ReactNative.

Getting Started

  1. Install NativeScript CLI
  2. Generate a new repo based on NativeScript Preact Template
  3. Clone your new repo.
  4. npm install and nativescript run android (or ios)

This is Alpha Software!

This is a very early working example, and should not be used for a production app unless you really know what you're doing. I hope to build a side-project using this as well as add unit tests for all NativeScript components.

How it Works

This was made possible by undom library, allowing Preact to rending into a pure JavaScript DOM, within the NativeScript runtime. Currently, I'm shipping a modified undom with basic MutationObserver API implemented which is what nativescript-preact uses to sync changes from the DOM to the NativeScript widgets. I aimed to keep this code generalized (and hopefully small), so the bridge code is easier to maintain and less prone to bugs.

Get Involved!

File issues! Feel free to post questions as issues here or look for the #preact channel on the NativeScript Slack Community.