Skip to main content
CodeSpeedTest
Languages
Start TypingJump into a test — pick any languageAdaptive TrainingUnlock chars as you master themPractice DrillsFocused sessions targeting weak spotsDaily ChallengesNew coding challenges every dayRace ModeCompete against others in real timeAI OpponentRace against an AI at your WPM levelTournamentsLive coding speed tournamentsArcade GamesZType, Overkill Survival, Glyphica & moreGamificationXP, coins, badges & quests
LeaderboardGlobal rankings for every languageCertificatesEarn verifiable Bronze / Silver / Gold certsActivityDaily streaks & historical analyticsProfileYour stats, badges & achievements
Browse Languages500+ languages with real code examplesBlogTips, guides & deep divesFree ToolsWPM calculator, typing speed report & moreFAQCommon questions answeredGetting StartedNew to CodeSpeedTest?AboutOur story & missionSupportGet help — Pro users get priorityContactGet in touch with the team
Pricing
  1. Home
  2. /
  3. Learn
  4. /
  5. Nativescript

Learn Nativescript - 8 Code Examples & CST Typing Practice Test

NativeScript is an open-source framework for building truly native mobile applications using JavaScript, TypeScript, Angular, or Vue. It allows developers to write cross-platform apps that access native APIs directly without using WebViews.

View all 8 Nativescript code examples →
NativeScript Vue Counter ExampleNativeScript Vue Step CounterNativeScript Vue Auto Increment CounterNativeScript Vue Dark Mode CounterNativeScript Vue Multi CounterNativeScript Vue Toggle CounterNativeScript Vue Countdown TimerNativeScript Vue Counter With Alert

Learn NATIVESCRIPT with Real Code Examples

Updated Nov 23, 2025

Explain

NativeScript enables building native iOS and Android apps from a single codebase using familiar web technologies or TypeScript.

It provides direct access to native UI components and device APIs, offering true native performance.

Ideal for developers who want cross-platform apps with the look, feel, and performance of fully native applications.

Core Features

Native UI rendering for iOS and Android

CLI for project creation, building, and running apps

Plugin architecture to access native APIs

Support for TypeScript, Angular, Vue

Live sync and hot module replacement during development

Basic Concepts Overview

Projects have `app/` folder for source code

`package.json` and `nsconfig.json` manage dependencies and config

Plugins provide access to native APIs

CLI commands handle builds, platforms, and live sync

Native UI components mapped directly from JavaScript/TypeScript

Project Structure

app/ - source code including components, styles, and logic

package.json - npm dependencies

node_modules/ - installed packages

platforms/ - platform-specific builds

hooks/ - build scripts and automation

Building Workflow

Create project using NativeScript CLI

Add platforms for target devices

Install plugins for device API access

Develop using Angular, Vue, or plain JS/TS

Build, deploy, and test on simulators or real devices

Difficulty Use Cases

Beginner: simple apps using core UI components

Intermediate: adding plugins and handling device APIs

Advanced: optimizing performance and native interactions

Expert: creating custom plugins or deep native integration

Community: contributing to NativeScript plugins or core

Comparisons

NativeScript vs Cordova: NativeScript renders real native UI, Cordova uses WebView

NativeScript vs React Native: Both offer native UI, NativeScript supports Angular/Vue directly

True native performance vs hybrid approach

Plugin ecosystem differences

Steeper learning curve than Cordova, easier native integration than Flutter in JS/TS

Versioning Timeline

2015 - NativeScript initial release by Progress

2016-2018 - Angular and Vue integrations added

2019-2020 - Performance and plugin ecosystem improvements

2021-2023 - CLI enhancements and platform updates

2024-2025 - Ongoing community contributions and maintenance

Glossary

Native app: app using platform-native UI components

Plugin: module providing access to device API

CLI: command-line interface for project management

app/ folder: source code and UI for NativeScript apps

LiveSync: live update of app during development

Installation Setup

Install Node.js and npm

Install NativeScript CLI: `npm install -g @nativescript/cli`

Create project: `ns create MyApp`

Add platforms: `ns platform add android ios`

Build and run: `ns run android` or `ns run ios`

Environment Setup

Install Node.js and npm

Install NativeScript CLI globally

Install platform SDKs (Android Studio, Xcode)

Configure paths and environment variables

Create and build projects with NativeScript

Config Files

package.json - npm dependencies

nsconfig.json - CLI configuration

app/ - source code

hooks/ - build automation scripts

platforms/ - platform-specific builds

Cli Commands

ns create MyApp

ns platform add android ios

ns plugin add <plugin-name>

ns build android

ns run ios

Internationalization

i18n libraries supported (ngx-translate, vue-i18n)

Text content and labels fully customizable

Supports LTR and RTL layouts

Date/number formatting via JS libraries

Localization configuration per platform

Accessibility

Leverages platform accessibility APIs

Supports screen readers and ARIA roles

Keyboard navigation and focus management

Testing required across iOS and Android

Custom accessible components encouraged

Ui Styling

Native UI components styled via CSS or framework-specific styles

Layouts adapt to different screen sizes

Supports Angular and Vue templating

Animations via native transitions or CSS

Themes can be customized per app

State Management

Handled via Angular, Vue, or JS frameworks

Plugin state maintained internally

Events manage parent-child and plugin communication

App-level state can use NgRx, Vuex, or other libraries

Integration with backend APIs for persistent state

Data Management

Local storage via plugins or native modules

Remote data via REST APIs, GraphQL, or WebSockets

Database plugins (SQLite, Couchbase) available

No built-in global state; use frameworks for complex apps

Offline caching via plugins or framework libraries

Architecture

NativeScript runtime bridges JavaScript/TypeScript to native APIs

CLI manages project lifecycle and builds

Plugin-based access to device features

Direct native UI rendering, not WebView-based

Event-driven architecture for app lifecycle and device events

Rendering Model

NativeScript runtime maps JS/TS to native UI

Plugins expose device APIs to JavaScript

Direct rendering of native UI without WebView

Event-driven communication for app lifecycle

Framework integration enables structured UI components

Architectural Patterns

Direct native UI rendering

Plugin-based API access

CLI-driven project lifecycle

Event-driven state and lifecycle management

Separation of app logic and UI components

Real World Architectures

Enterprise mobile dashboards

Cross-platform productivity apps

Consumer apps with high-performance UI

Data-driven mobile apps

Rapid prototyping and MVPs

Design Principles

Direct access to native UI components

Single codebase for multiple platforms

Integration with Angular, Vue, or plain JS/TS

Plugin-based native API access

Open-source and community-driven

Scalability Guide

Use modular app structure

Lazy-load pages and modules

Optimize images and assets

Use plugins judiciously

Combine with state management frameworks for large apps

Migration Guide

Update CLI and plugin versions for new releases

Refactor code for Angular/Vue version upgrades

Adjust native module calls for platform SDK updates

Verify app lifecycle and permissions

Check plugin compatibility

Performance Notes

Leverage native UI components for smooth rendering

Minimize heavy JS computations on main thread

Use lazy-loading for large views

Optimize images and assets for mobile

Test performance on real devices

Security Notes

Validate and sanitize all user inputs

Secure plugin usage and API calls

Follow platform security guidelines

Keep NativeScript and plugins up to date

Use HTTPS for network communications

Monitoring Analytics

Use analytics SDKs for mobile

Monitor plugin usage and performance

Track app crashes and errors

Audit native module performance

Ensure consistent behavior across devices

Code Quality

Follow best practices for Angular/Vue/TS/JS

Document plugins and modules

Ensure proper lifecycle and event handling

Optimize performance for real devices

Test thoroughly across platforms

Practical Examples

Enterprise apps with native dashboards

Cross-platform mobile productivity apps

Apps requiring access to camera, GPS, or sensors

Consumer apps with high-performance UI

Rapid prototypes for mobile startups

Troubleshooting

Ensure platform SDKs (Xcode, Android Studio) installed correctly

Check plugin compatibility with platform versions

Debug native code with Xcode or Android Studio

Resolve plugin conflicts

Verify app permissions and platform settings

Testing Guide

Test UI on iOS and Android devices

Verify plugin behavior on each platform

Check responsiveness and layout consistency

Monitor memory usage and performance

Test offline and network scenarios

Deployment Options

Build APK for Android and IPA for iOS

Deploy via Google Play and App Store

Use CI/CD for automated builds

Apply code signing and certificates

Test builds on multiple devices before production release

Tools Ecosystem

NativeScript CLI and plugins

Angular, Vue, or TypeScript integration

Device emulators and simulators

Third-party plugins for extended functionality

Build tools (Webpack, ns-bundle, etc.)

Integrations

Angular or Vue for UI development

Backend APIs for data-driven apps

Push notification services

Analytics and crash reporting

Custom native modules for platform-specific features

Productivity Tips

Leverage CLI commands for efficiency

Use plugins for native functionality

Test frequently on devices

Use Angular/Vue integration for consistent UI

Document code and project structure

Challenges

Build a native dashboard app

Integrate device camera and sensors

Trigger push notifications

Use Angular or Vue components in NativeScript

Deploy fully functional cross-platform app

Learning Path

Learn NativeScript CLI commands

Understand project structure and app folder

Explore plugins and native APIs

Integrate Angular or Vue with NativeScript

Build, test, and deploy native mobile apps

Skill Improvement Plan

Week 1: Create projects and add platforms

Week 2: Learn core UI components and layout system

Week 3: Use plugins for camera, GPS, notifications

Week 4: Optimize performance and debug native code

Week 5: Deploy apps to stores and maintain plugins

Interview Questions

Explain NativeScript architecture and runtime.

How does NativeScript access native APIs?

Compare NativeScript with Cordova and React Native.

Describe NativeScript project structure.

How to integrate Angular or Vue in NativeScript apps?

Cheat Sheet

`ns create MyApp` - create project

`ns platform add android ios` - add platform

`ns plugin add <plugin-name>` - add plugin

`ns run android` - run on device/emulator

`ns build ios` - build for iOS

Books

NativeScript 101

Building NativeScript Apps with Angular

Cross-Platform Mobile Development with NativeScript

NativeScript Plugins and Device APIs

Enterprise Mobile Apps with NativeScript

Tutorials

Official NativeScript documentation

YouTube NativeScript tutorials

Community blogs and examples

Angular/Vue + NativeScript projects

CodeSandbox or StackBlitz NativeScript demos

Official Docs

https://docs.nativescript.org/

https://github.com/NativeScript/NativeScript

https://market.nativescript.org/

Community Links

NativeScript GitHub

StackOverflow NativeScript tag

Reddit discussions

Official documentation forum

Twitter #nativescript

Community Support

NativeScript GitHub

StackOverflow NativeScript tag

Reddit discussions

Official documentation

Community plugins and demos

Monetization

Enterprise internal apps

Consumer apps with cross-platform reach

Consulting for NativeScript projects

Plugin development for device features

Rapid deployment solutions

Future Roadmap

Support latest mobile OS versions

Expand plugin ecosystem

Improve performance and debugging tools

Enhance framework integration

Maintain community-driven open-source contributions

When Not To Use

Projects requiring pure web technologies

Teams with no TypeScript or Angular/Vue experience

Apps needing extremely lightweight bundle sizes

Web-first applications with minimal native features

Developers preferring full native platform SDKs for UI

Final Summary

NativeScript allows building truly native iOS and Android apps with one codebase.

Direct access to native APIs ensures real native performance.

Supports Angular, Vue, TypeScript, and JavaScript.

Ideal for enterprise apps, high-performance consumer apps, and rapid prototyping.

Offers a rich plugin ecosystem and CLI tools for building, testing, and deploying.

Faq

Is NativeScript maintained?

Yes, actively maintained by Progress and community.

Can I use Angular or Vue?

Yes, NativeScript supports Angular, Vue, and plain TypeScript/JS.

Does it support native APIs?

Yes, directly without WebView.

Is it suitable for high-performance apps?

Yes, NativeScript renders real native UI components.

Can I deploy to both iOS and Android?

Yes, cross-platform deployment is supported.

Code Sample Descriptions

1

NativeScript Vue Counter Example

<template>
    <Page class="page" :class="{ 'dark-theme': isDark }">
        <ActionBar title="NativeScript Counter" class="action-bar" />
        <StackLayout class="container" horizontalAlignment="center" verticalAlignment="center">
        <Label :text="`Counter: ${count}`" class="counter-text" />
        <Button text="+" @tap="increment" class="btn-primary" />
        <Button text="-" @tap="decrement" class="btn-danger" />
        <Button text="Reset" @tap="reset" class="btn-secondary" />
        <Button text="Switch Theme" @tap="toggleTheme" class="btn-warning" />
        </StackLayout>
    </Page>
</template>

<script>
import { ref } from 'vue';
export default {
    setup() {
        const count = ref(0);
        const isDark = ref(false);

        const increment = () => count.value++;
        const decrement = () => count.value--;
        const reset = () => count.value = 0;
        const toggleTheme = () => { isDark.value = !isDark.value; };

        return { count, increment, decrement, reset, toggleTheme, isDark };
    }
};
</script>

<style scoped>
    .page { background-color: #fff; color: #000; }
    .dark-theme { background-color: #333; color: #fff; }
    .container { margin-top: 50px; text-align: center; }
    .btn-primary, .btn-danger, .btn-secondary { margin: 5px; }
    .btn-warning { margin: 10px 0; }
    .counter-text { font-size: 24px; margin-bottom: 10px; }
</style>

Demonstrates a simple counter layout using NativeScript Vue components and Vue.js for interactivity.

Let’s Try →
2

NativeScript Vue Step Counter

<template>
    <Page class="page" :class="{ 'dark-theme': isDark }">
        <ActionBar title="Step Counter" class="action-bar" />
        <StackLayout class="container" horizontalAlignment="center" verticalAlignment="center">
        <Label :text="`Counter: ${count}`" class="counter-text" />
        <TextField v-model.number="step" keyboardType="number" hint="Step" class="step-input" />
        <Button text="+" @tap="increment" class="btn-primary" />
        <Button text="-" @tap="decrement" class="btn-danger" />
        <Button text="Reset" @tap="reset" class="btn-secondary" />
        </StackLayout>
    </Page>
</template>

<script>
import { ref } from 'vue';
export default {
    setup() {
        const count = ref(0);
        const step = ref(1);
        const isDark = ref(false);

        const increment = () => count.value += step.value;
        const decrement = () => count.value -= step.value;
        const reset = () => count.value = 0;
        const toggleTheme = () => { isDark.value = !isDark.value; };

        return { count, step, increment, decrement, reset, toggleTheme, isDark };
    }
};
</script>

<style scoped>
    .page { background-color: #fff; color: #000; }
    .dark-theme { background-color: #333; color: #fff; }
    .container { margin-top: 50px; text-align: center; }
    .btn-primary, .btn-danger, .btn-secondary { margin: 5px; }
    .step-input { margin: 5px; width: 100px; text-align: center; }
    .counter-text { font-size: 24px; margin-bottom: 10px; }
</style>

Counter example with customizable step increment.

Let’s Try →
3

NativeScript Vue Auto Increment Counter

<template>
    <Page class="page" :class="{ 'dark-theme': isDark }">
        <ActionBar title="Auto Counter" class="action-bar" />
        <StackLayout class="container" horizontalAlignment="center" verticalAlignment="center">
        <Label :text="`Counter: ${count}`" class="counter-text" />
        <Button text="Pause/Resume" @tap="toggleRunning" class="btn-warning" />
        <Button text="Reset" @tap="reset" class="btn-secondary" />
        </StackLayout>
    </Page>
</template>

<script>
import { ref, onMounted, onUnmounted } from 'vue';
export default {
    setup() {
        const count = ref(0);
        const isRunning = ref(true);
        const isDark = ref(false);

        let interval;
        onMounted(() => {
        interval = setInterval(() => { if(isRunning.value) count.value++; }, 1000);
        });
        onUnmounted(() => clearInterval(interval));

        const toggleRunning = () => isRunning.value = !isRunning.value;
        const reset = () => count.value = 0;
        const toggleTheme = () => isDark.value = !isDark.value;

        return { count, isRunning, toggleRunning, reset, toggleTheme, isDark };
    }
};
</script>

<style scoped>
    .page { background-color: #fff; color: #000; }
    .dark-theme { background-color: #333; color: #fff; }
    .container { margin-top: 50px; text-align: center; }
    .btn-warning, .btn-secondary { margin: 5px; }
    .counter-text { font-size: 24px; margin-bottom: 10px; }
</style>

Counter automatically increments every second with pause/resume control.

Let’s Try →
4

NativeScript Vue Dark Mode Counter

<template>
    <Page class="page" :class="{ 'dark-theme': isDark }">
        <ActionBar title="Dark Mode Counter" class="action-bar" />
        <StackLayout class="container" horizontalAlignment="center" verticalAlignment="center">
        <Label :text="`Counter: ${count}`" class="counter-text" />
        <Button text="+" @tap="increment" class="btn-primary" />
        <Button text="-" @tap="decrement" class="btn-danger" />
        <Button text="Reset" @tap="reset" class="btn-secondary" />
        <Button text="Switch Theme" @tap="toggleTheme" class="btn-warning" />
        </StackLayout>
    </Page>
</template>

<script>
import { ref } from 'vue';
export default {
    setup() {
        const count = ref(0);
        const isDark = ref(false);

        const increment = () => count.value++;
        const decrement = () => count.value--;
        const reset = () => count.value = 0;
        const toggleTheme = () => { isDark.value = !isDark.value; };

        return { count, increment, decrement, reset, toggleTheme, isDark };
    }
};
</script>

<style scoped>
    .page { background-color: #fff; color: #000; }
    .dark-theme { background-color: #222; color: #fff; }
    .container { margin-top: 50px; text-align: center; }
    .btn-primary, .btn-danger, .btn-secondary, .btn-warning { margin: 5px; }
    .counter-text { font-size: 24px; margin-bottom: 10px; }
</style>

Simple counter with dark/light theme toggle.

Let’s Try →
5

NativeScript Vue Multi Counter

<template>
    <Page class="page">
        <ActionBar title="Multi Counter" class="action-bar" />
        <StackLayout class="container" horizontalAlignment="center" verticalAlignment="center">
        <StackLayout v-for="(c, index) in counters" :key="index" class="counter-block">
        <Label :text="`Counter ${index+1}: ${c}`" class="counter-text" />
        <Button text="+" @tap="() => increment(index)" class="btn-primary" />
        </StackLayout>
        </StackLayout>
    </Page>
</template>

<script>
import { ref } from 'vue';
export default {
    setup() {
        const counters = ref([0,0,0]);
        const increment = (i) => counters.value[i]++;
        return { counters, increment };
    }
};
</script>

<style scoped>
    .page { background-color: #fff; color: #000; }
    .container { margin-top: 50px; text-align: center; }
    .btn-primary { margin: 5px; }
    .counter-text { font-size: 20px; margin-bottom: 10px; }
</style>

Multiple independent counters in a single page.

Let’s Try →
6

NativeScript Vue Toggle Counter

<template>
    <Page class="page">
        <ActionBar title="Toggle Counter" class="action-bar" />
        <StackLayout class="container" horizontalAlignment="center" verticalAlignment="center">
        <Label :text="`Counter: ${count}`" class="counter-text" />
        <Button text="+" @tap="increment" class="btn-primary" />
        <Button text="-" @tap="decrement" class="btn-danger" />
        <Button text="Reset" @tap="reset" class="btn-secondary" />
        <Button text="Toggle Double: {{ double ? 'ON' : 'OFF' }}" @tap="toggleDouble" class="btn-warning" />
        </StackLayout>
    </Page>
</template>

<script>
import { ref } from 'vue';
export default {
    setup() {
        const count = ref(0);
        const double = ref(false);
        const increment = () => count.value += double.value ? 2 : 1;
        const decrement = () => count.value -= double.value ? 2 : 1;
        const reset = () => count.value = 0;
        const toggleDouble = () => double.value = !double.value;
        return { count, double, increment, decrement, reset, toggleDouble };
    }
};
</script>

<style scoped>
    .page { background-color: #fff; color: #000; }
    .container { margin-top: 50px; text-align: center; }
    .btn-primary, .btn-danger, .btn-secondary, .btn-warning { margin: 5px; }
    .counter-text { font-size: 24px; margin-bottom: 10px; }
</style>

Counter with toggle for double increment mode.

Let’s Try →
7

NativeScript Vue Countdown Timer

<template>
    <Page class="page">
        <ActionBar title="Countdown Timer" class="action-bar" />
        <StackLayout class="container" horizontalAlignment="center" verticalAlignment="center">
        <Label :text="`Time: ${count}`" class="counter-text" />
        <Button text="Start" @tap="startCountdown" class="btn-primary" />
        <Button text="Reset" @tap="reset" class="btn-secondary" />
        </StackLayout>
    </Page>
</template>

<script>
import { ref } from 'vue';
export default {
    setup() {
        const count = ref(10);
        let timer;
        const startCountdown = () => {
        clearInterval(timer);
        timer = setInterval(() => { if(count.value > 0) count.value--; }, 1000);
        };
        const reset = () => { clearInterval(timer); count.value = 10; };
        return { count, startCountdown, reset };
    }
};
</script>

<style scoped>
    .page { background-color: #fff; color: #000; }
    .container { margin-top: 50px; text-align: center; }
    .btn-primary, .btn-secondary { margin: 5px; }
    .counter-text { font-size: 24px; margin-bottom: 10px; }
</style>

Countdown counter starting from 10 to 0.

Let’s Try →
8

NativeScript Vue Counter With Alert

<template>
    <Page class="page">
        <ActionBar title="Counter Alert" class="action-bar" />
        <StackLayout class="container" horizontalAlignment="center" verticalAlignment="center">
        <Label :text="`Counter: ${count}`" class="counter-text" />
        <Button text="+" @tap="increment" class="btn-primary" />
        <Button text="Reset" @tap="reset" class="btn-secondary" />
        </StackLayout>
    </Page>
</template>

<script>
import { ref } from 'vue';
import { alert } from '@nativescript/core/ui/dialogs';
export default {
    setup() {
        const count = ref(0);
        const increment = () => {
        count.value++;
        if(count.value === 10) alert('Count reached 10!');
        };
        const reset = () => count.value = 0;
        return { count, increment, reset };
    }
};
</script>

<style scoped>
    .page { background-color: #fff; color: #000; }
    .container { margin-top: 50px; text-align: center; }
    .btn-primary, .btn-secondary { margin: 5px; }
    .counter-text { font-size: 24px; margin-bottom: 10px; }
</style>

Counter shows an alert when it reaches 10.

Let’s Try →

Frequently Asked Questions about Nativescript

What is Nativescript?

NativeScript is an open-source framework for building truly native mobile applications using JavaScript, TypeScript, Angular, or Vue. It allows developers to write cross-platform apps that access native APIs directly without using WebViews.

What are the primary use cases for Nativescript?

Cross-platform native apps for iOS and Android. Enterprise apps requiring native performance. Apps needing access to full device APIs and native UI. Rapid prototyping of native mobile apps. Integration with Angular, Vue, or plain TypeScript/JavaScript front-end

What are the strengths of Nativescript?

True native performance without WebView. Single codebase for multiple platforms. Rich plugin ecosystem. Seamless integration with popular frameworks. Active open-source community

What are the limitations of Nativescript?

Smaller community than Cordova or React Native. Some plugins may require native code tweaks. Steeper learning curve for web-only developers. Larger app size than minimal native apps. Debugging native issues may require platform knowledge

How can I practice Nativescript typing speed?

CodeSpeedTest offers 8+ real Nativescript code examples for typing practice. You can measure your WPM, track accuracy, and improve your coding speed with guided exercises.

Learn Other Programming Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypherGremlinPartiqlHaskellElixirFsharpView all languages →
CodeSpeedTest

Improve your coding speed, code accuracy, and programming syntax WPM with practice sessions across 500+ programming languages.

Quick Links

HomeAboutFeaturesGetting StartedLanguages

Legal & Support

Pro ⚡ PricingContactPrivacy PolicyTerms of Service

Connect

CodeSpeedTest on GitHubCodeSpeedTest on TwitterEmail CodeSpeedTest

© 2026 CodeSpeedTest. All rights reserved.