NativeScript
⚡ Empowering JavaScript with native platform APIs. ✨ Best of all worlds (TypeScript, Swift, Objective C, Kotlin, Java, Dart). Use what you love ❤️ Angular, Capacitor, Ionic, React, Solid, Svelte, Vue with: iOS (UIKit, SwiftUI), Android (View, Jetpack Compose), Dart (Flutter) and you name it compatible.
Top Related Projects
A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
A framework for building native applications using React
Flutter makes it easy and fast to build beautiful apps for mobile and beyond
Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
Remote Administration Tool for Windows
Quick Overview
NativeScript is an open-source framework for building truly native mobile applications using JavaScript, TypeScript, or Angular. It allows developers to create cross-platform apps for iOS and Android with a single codebase, leveraging native UI components and providing access to platform-specific APIs.
Pros
- Cross-platform development with a single codebase
- Native performance and UI components
- Access to native APIs and third-party libraries
- Large and active community with extensive plugin ecosystem
Cons
- Steeper learning curve compared to some other cross-platform frameworks
- Smaller developer pool compared to React Native or Flutter
- Occasional performance issues with complex applications
- Limited IDE support compared to native development
Code Examples
- Creating a simple page with a button:
import { EventData, Page } from '@nativescript/core';
export function navigatingTo(args: EventData) {
const page = <Page>args.object;
page.bindingContext = {};
}
export function onTap() {
console.log('Button tapped!');
}
- Making an HTTP request:
import { Http } from '@nativescript/core';
Http.getJSON('https://api.example.com/data').then(
(result: any) => {
console.log(result);
},
(error) => {
console.error(error);
}
);
- Using a ListView:
<ListView items="{{ myItems }}">
<ListView.itemTemplate>
<Label text="{{ name }}" />
</ListView.itemTemplate>
</ListView>
Getting Started
-
Install NativeScript CLI:
npm install -g nativescript
-
Create a new project:
ns create MyApp --template @nativescript/template-blank-ts
-
Navigate to the project directory:
cd MyApp
-
Run the app on an emulator or device:
ns run android # or ns run ios
Competitor Comparisons
A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
Pros of Ionic Framework
- Larger community and ecosystem, with more plugins and third-party integrations
- Better performance for web-based applications and progressive web apps (PWAs)
- Easier learning curve for web developers familiar with HTML, CSS, and JavaScript
Cons of Ionic Framework
- Less native performance compared to NativeScript, especially for complex applications
- Limited access to native APIs without additional plugins or custom development
- Slightly larger app size due to the inclusion of web technologies
Code Comparison
NativeScript (XML and TypeScript):
<StackLayout>
<Label text="Hello, NativeScript!" />
<Button text="Click Me" tap="{{ onButtonTap }}" />
</StackLayout>
export function onButtonTap() {
console.log("Button tapped!");
}
Ionic Framework (HTML and TypeScript):
<ion-content>
<h1>Hello, Ionic!</h1>
<ion-button (click)="onButtonClick()">Click Me</ion-button>
</ion-content>
onButtonClick() {
console.log("Button clicked!");
}
Both frameworks offer cross-platform development capabilities, but NativeScript focuses on native performance and direct access to platform APIs, while Ionic Framework emphasizes web technologies and easier adoption for web developers. The choice between them depends on project requirements, team expertise, and performance needs.
A framework for building native applications using React
Pros of React Native
- Larger community and ecosystem, resulting in more third-party libraries and resources
- Better performance for complex UI interactions and animations
- Stronger corporate backing from Facebook, ensuring long-term support and development
Cons of React Native
- Steeper learning curve for developers new to React or mobile development
- More frequent breaking changes and updates, requiring regular maintenance
- Less direct access to native APIs, often requiring additional bridge modules
Code Comparison
React Native:
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
const App = () => (
<View style={styles.container}>
<Text>Hello, React Native!</Text>
</View>
);
NativeScript:
<Page xmlns="http://schemas.nativescript.org/tns.xsd">
<StackLayout>
<Label text="Hello, NativeScript!" />
</StackLayout>
</Page>
Both frameworks allow developers to create native mobile applications using JavaScript, but they differ in their approach and syntax. React Native uses JSX and React components, while NativeScript uses XML-based markup for UI definition. React Native's ecosystem and performance advantages make it a popular choice for large-scale applications, while NativeScript's simpler learning curve and direct native API access can be beneficial for smaller projects or teams with existing Angular experience.
Flutter makes it easy and fast to build beautiful apps for mobile and beyond
Pros of Flutter
- Faster development with hot reload feature
- Extensive widget library for UI components
- Strong performance with compiled native code
Cons of Flutter
- Larger app size due to bundled runtime
- Less mature ecosystem compared to NativeScript
- Steeper learning curve for developers new to Dart
Code Comparison
NativeScript (JavaScript):
import { Label } from "@nativescript/core";
export function createLabel() {
const label = new Label();
label.text = "Hello, NativeScript!";
return label;
}
Flutter (Dart):
import 'package:flutter/material.dart';
Widget buildLabel() {
return Text('Hello, Flutter!');
}
Both frameworks allow for creating native mobile apps, but they differ in approach and language. NativeScript uses JavaScript or TypeScript and provides direct access to native APIs, while Flutter uses Dart and its own rendering engine. Flutter's widget-based approach and hot reload feature can lead to faster development, but NativeScript's use of familiar web technologies may be more appealing to some developers. The choice between them often depends on project requirements and team expertise.
Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
Pros of Xamarin.Forms
- Stronger integration with native platform APIs and UI components
- Extensive ecosystem of .NET libraries and NuGet packages
- Better performance for complex, data-intensive applications
Cons of Xamarin.Forms
- Steeper learning curve, especially for developers new to C# and .NET
- Larger app size due to inclusion of .NET runtime
- Less frequent updates compared to NativeScript
Code Comparison
Xamarin.Forms (XAML):
<StackLayout>
<Label Text="Hello, World!" />
<Button Text="Click Me" Clicked="OnButtonClicked" />
</StackLayout>
NativeScript (XML):
<StackLayout>
<Label text="Hello, World!" />
<Button text="Click Me" tap="onButtonTap" />
</StackLayout>
Both frameworks use XML-based markup languages for UI definition, but Xamarin.Forms uses XAML while NativeScript uses a custom XML syntax. The code structure is similar, with minor differences in attribute naming conventions and event handling.
Xamarin.Forms relies on C# for business logic, while NativeScript typically uses JavaScript or TypeScript. This difference in programming languages can significantly impact development experience and ecosystem compatibility.
Remote Administration Tool for Windows
Pros of Quasar
- Offers a wider range of UI components and layouts out-of-the-box
- Supports multiple build targets (web, mobile, desktop) from a single codebase
- Has a more active community and frequent updates
Cons of Quasar
- Steeper learning curve due to its extensive feature set
- Less native performance optimization compared to NativeScript
- Limited access to native APIs without additional plugins
Code Comparison
NativeScript (XML-based UI):
<StackLayout>
<Label text="Hello, NativeScript!" />
<Button text="Click me" tap="onButtonTap" />
</StackLayout>
Quasar (Vue.js-based UI):
<q-layout>
<q-page-container>
<q-page>
<q-btn label="Click me" @click="onButtonClick" />
</q-page>
</q-page-container>
</q-layout>
Both frameworks offer different approaches to building cross-platform applications. NativeScript focuses on native UI rendering and performance, while Quasar provides a more web-centric development experience with a rich set of pre-built components. The choice between the two depends on specific project requirements, team expertise, and desired application characteristics.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
NativeScript empowers you to access native APIs from JavaScript directly. Currently iOS, Android, and visionOS runtimes are provided for rich mobile development across a variety of diverse use cases.
Contribute
-
Clone to contribute:
$ git clone https://github.com/NativeScript/NativeScript.git
$ cd NativeScript
# setup workspace for development
$ npm run setup
# list all available commands to run
$ npm start
We love you and your pull requests ð¤. Please follow our contributing guide and see our code of governance to become as involved as you want to be.
@nativescript/*
- @nativescript/core Singular primitives offering an easy-to-use API surface for diverse iOS/visionOS/Android APIs implemented with NativeScript.
- @nativescript/types Types for both iOS/Android below wrapped up as a convenience. Most commonly used.
- @nativescript/types-ios Types for iOS.
- @nativescript/types-android Types for Android.
- @nativescript/types-minimal A very minimal set of types for only the latest Android and iOS sdks. Most commonly used to optimize Web-based IDE's which auto load all type declarations from node_modules.
- @nativescript/ui-mobile-base UI mobile base native classes used by core.
- @nativescript/webpack Webpack build utilities and configs used by NativeScript apps.
Quick Links
- NativeScript Home
- NativeScript Tutorials
- NativeScript documentation
- JavaScript starter: https://nativescript.new/javascript
- TypeScript starter: https://nativescript.new/typescript
- Angular starter: https://nativescript.new/angular
- React starter: https://nativescript.new/react
- Solid starter: https://nativescript.new/solid
- Svelte starter: https://nativescript.new/svelte
- Vue starter: https://nativescript.new/vue
- NativeScript on Twitter
- NativeScript on Discord
- NativeScript on Stack Overflow
Other source repos
Outside the source centralized in this repo, NativeScript consists of a few other source repos. Here are the major ones:
- iOS and visionOS Runtime Empowers JavaScript code to be executed on iOS and visionOS devices written in a mix of C++, Objective-C, and Swift.
- Android Runtime Empowers JavaScript code to be executed on Android devices written in a mix of C++, Java and Kotlin.
- CLI Command-line interface empowering you to create, build, and run apps using NativeScript.
- Docs Documentation available at http://docs.nativescript.org/ written in Markdown.
- Plugins Various TSC managed plugins. Also a good reference is the plugin marketplace with several additional plugins.
- Firebase Modular Firebase ð¥ implementation for supported platforms.
- ML Kit Google's ML Kit SDKs for supported platforms.
- Payments In-App Purchase, Subscriptions, Google Pay and Apple Pay.
- Artwork Want to use our logo or colors? Feel free to use any of our ready-to-use media material.
Copyright notice
Copyright OpenJS Foundation and NativeScript
contributors. All rights reserved. The OpenJS Foundation has registered trademarks and uses trademarks. For a list of trademarks of the OpenJS Foundation, please see our Trademark Policy and Trademark List. Trademarks and logos not indicated on the list of OpenJS Foundation trademarks are trademarks⢠or registered® trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.
The OpenJS Foundation | Terms of Use | Privacy Policy | OpenJS Foundation Bylaws | Trademark Policy | Trademark List | Cookie Policy
Made with â¤ï¸
Top Related Projects
A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
A framework for building native applications using React
Flutter makes it easy and fast to build beautiful apps for mobile and beyond
Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
Remote Administration Tool for Windows
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot