Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Hello, NativeScript

Hello, NativeScript

A light introduction to what NativeScript is and why you should care!

Jamie Birch

May 31, 2024
Tweet

More Decks by Jamie Birch

Other Decks in Technology

Transcript

  1. Why use NativeScript? A 1-minute pitch • use web tech

    to develop a native app: • HTML, CSS, JS • React, Vue, Angular, Svelte, Solid… JQuery? • Tailwind • access all native APIs via JS NativeScript allows you to:
  2. A taste of NativeScript The web tech export function HomeScreen({

    navigation }) { return ( <flexboxLayout> <label className="text-2xl mb-4 font-bold text-center"> Hello World! </label> <button onTap={() => Dialogs.alert("Tapped!")}> Tap me for an alert </button> <button onTap={() => navigation.navigate("Two", { message: "Hello, world!" })} > Go to next screen </button> </flexboxLayout> ); }
  3. A taste of NativeScript The native API access export function

    callPhoneNumber(platform, phoneNumber) { if(platform === "ios"){ UIApplication.sharedApplication.openURLOptionsCompletionHandler( NSURL.URLWithString(`tel://${phoneNumber}`), {}, (success) => console.log(success), ); return; } if(platform === "android"){ Application.android.foregroundActivity.startActivity( new android.content.Intent( android.content.Intent.ACTION_DIAL, android.net.Uri.parse(`tel:${phoneNumber}`), ) ); return; } }
  4. How does NativeScript work? The JS→native runtime • It’s a

    V8-based runtime, like Node.js • It provides 1:1 JS bindings to all iOS or Android APIs • In future, will be an npm library (based on Node-API) • will work on Hermes, QuickJS, JSC, etc. • will work inside React Native, Node.js, Bun, and Deno
  5. How does NativeScript work? The app development framework • It’s

    a framework for app dev, like React Native • It implements cross-platform UI components using the NativeScript runtime • These components are then adapted for React, Vue, Angular, etc.
  6. Conclusion • NativeScript is a natural tool for building native

    apps with web tech • It can be used standalone (as an end-to-end app framework) • … or just as a runtime (to access native APIs from JS) • It’s capable • It’s an openly governed community project with 23.8k GitHub stars • Give it a try!