Top Related Projects
Native mobile applications using Vue and 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.
A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
👾 Clean and minimalist React Native template for a quick start with TypeScript.
Remote Administration Tool for Windows
Full featured HTML framework for building iOS & Android apps
Quick Overview
Svelte Native is a framework for building native mobile applications using Svelte and NativeScript. It allows developers to create cross-platform mobile apps with a single codebase, leveraging the simplicity and efficiency of Svelte for the UI layer while utilizing NativeScript for native platform access.
Pros
- Combines the simplicity and reactivity of Svelte with NativeScript's native platform capabilities
- Enables cross-platform mobile app development with a single codebase
- Offers a familiar development experience for Svelte developers
- Provides access to native APIs and UI components
Cons
- Smaller community and ecosystem compared to React Native or Flutter
- Limited documentation and learning resources
- Potential performance overhead compared to fully native development
- Dependency on both Svelte and NativeScript ecosystems
Code Examples
- Creating a simple component:
<page>
<actionBar title="My App" />
<stackLayout>
<label text="Hello, {name}!" />
<button text="Tap me!" on:tap={onTap} />
</stackLayout>
</page>
<script>
let name = 'World';
function onTap() {
name = 'Svelte Native';
}
</script>
- Using native platform APIs:
<button text="Take Photo" on:tap={takePhoto} />
<script>
import { Camera } from '@nativescript/camera';
async function takePhoto() {
const image = await Camera.takePicture();
console.log('Photo taken:', image);
}
</script>
- Implementing a list view:
<listView items={fruits}>
<Template let:item>
<label text={item} />
</Template>
</listView>
<script>
let fruits = ['Apple', 'Banana', 'Orange', 'Mango'];
</script>
Getting Started
-
Install the Svelte Native CLI:
npm install -g svelte-native-cli
-
Create a new Svelte Native project:
svelte-native init my-mobile-app cd my-mobile-app
-
Install dependencies and run the app:
npm install ns run android # or 'ns run ios' for iOS
Competitor Comparisons
Native mobile applications using Vue and NativeScript.
Pros of nativescript-vue
- Larger community and ecosystem, with more resources and third-party plugins available
- Better documentation and learning materials for beginners
- More mature and stable, with a longer development history
Cons of nativescript-vue
- Steeper learning curve for developers new to Vue.js
- Potentially slower performance compared to Svelte's compiled output
- Larger bundle sizes due to Vue.js runtime
Code Comparison
nativescript-vue:
<template>
<Page>
<ActionBar title="Welcome to NativeScript-Vue!"/>
<GridLayout columns="*" rows="*">
<Label class="message" :text="msg" col="0" row="0"/>
</GridLayout>
</Page>
</template>
svelte-native:
<page>
<actionBar title="Welcome to Svelte Native!"/>
<gridLayout columns="*" rows="*">
<label text={msg} class="message" col="0" row="0"/>
</gridLayout>
</page>
Both frameworks offer similar syntax for creating native mobile applications, with slight differences in template structure and binding syntax. nativescript-vue uses Vue.js conventions, while svelte-native follows Svelte's more concise approach. The choice between the two often depends on the developer's familiarity with Vue.js or Svelte, as well as specific project requirements and performance considerations.
⚡ 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.
Pros of NativeScript
- Larger community and ecosystem with more plugins and resources
- Supports multiple JavaScript frameworks (Angular, Vue.js, React)
- More mature and established project with longer history
Cons of NativeScript
- Steeper learning curve for developers new to mobile development
- Larger bundle sizes compared to Svelte Native
- Performance can be slower for complex applications
Code Comparison
NativeScript (using Vue.js):
<template>
<Page>
<ActionBar title="My App" />
<StackLayout>
<Label text="Hello, NativeScript!" />
</StackLayout>
</Page>
</template>
Svelte Native:
<page>
<actionBar title="My App" />
<stackLayout>
<label text="Hello, Svelte Native!" />
</stackLayout>
</page>
Key Differences
- Svelte Native is specifically designed for Svelte, while NativeScript supports multiple frameworks
- Svelte Native typically results in smaller bundle sizes and faster performance
- NativeScript has a larger ecosystem and more third-party plugins available
- Svelte Native's syntax is more concise and closer to standard Svelte code
Use Cases
- Choose NativeScript for larger projects requiring extensive plugins or when using Angular/Vue.js/React
- Opt for Svelte Native for smaller to medium-sized projects prioritizing performance and simplicity, especially if already using Svelte for web development
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 ecosystem and community support
- Cross-platform development for web, iOS, and Android
- Extensive UI component library and theming capabilities
Cons of Ionic Framework
- Steeper learning curve, especially for developers new to Angular
- Potentially larger app size due to comprehensive feature set
- Performance may be slower compared to native solutions
Code Comparison
Svelte Native:
<page>
<actionBar title="Svelte Native App" />
<stackLayout>
<label text="Welcome to Svelte Native!" />
</stackLayout>
</page>
Ionic Framework:
<ion-app>
<ion-header>
<ion-toolbar>
<ion-title>Ionic Framework App</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-label>Welcome to Ionic Framework!</ion-label>
</ion-content>
</ion-app>
Key Differences
- Svelte Native focuses on native mobile development using NativeScript, while Ionic Framework targets hybrid mobile and web applications
- Svelte Native leverages Svelte's lightweight and efficient approach, whereas Ionic Framework relies on Angular's robust ecosystem
- Ionic Framework offers a more comprehensive set of UI components and tools out of the box, while Svelte Native provides a more minimalist starting point
Use Cases
- Choose Svelte Native for smaller, performance-critical native mobile apps
- Opt for Ionic Framework when building cross-platform applications with a rich UI and extensive feature set
👾 Clean and minimalist React Native template for a quick start with TypeScript.
Pros of react-native-template-typescript
- Larger community and ecosystem, providing more resources and third-party libraries
- Better documentation and extensive learning materials available
- More mature and stable, with a longer track record in production environments
Cons of react-native-template-typescript
- Steeper learning curve, especially for developers new to React or TypeScript
- Larger bundle size and potentially slower performance compared to Svelte Native
- More complex state management solutions required for large-scale applications
Code Comparison
react-native-template-typescript:
import React from 'react';
import { View, Text } from 'react-native';
const App: React.FC = () => (
<View>
<Text>Hello, React Native!</Text>
</View>
);
svelte-native:
<page>
<actionBar title="Svelte Native" />
<stackLayout>
<label text="Hello, Svelte Native!" />
</stackLayout>
</page>
The React Native example uses JSX syntax and TypeScript, while Svelte Native uses a more HTML-like syntax. Svelte Native's approach is generally more concise and easier to read, especially for those familiar with web development. However, React Native's TypeScript integration provides stronger type checking and better tooling support out of the box.
Remote Administration Tool for Windows
Pros of Quasar
- Comprehensive UI component library with Material Design support
- Supports multiple build targets (web, mobile, desktop) from a single codebase
- Active community and extensive documentation
Cons of Quasar
- Steeper learning curve due to its extensive feature set
- Larger bundle size compared to more lightweight frameworks
- Opinionated structure may limit flexibility for some projects
Code Comparison
Quasar (Vue.js-based):
<template>
<q-page>
<q-btn color="primary" label="Click me" @click="handleClick" />
</q-page>
</template>
<script>
export default {
methods: {
handleClick() {
// Handle button click
}
}
}
</script>
Svelte Native:
<page>
<actionBar title="My App" />
<button text="Click me" on:tap="{handleTap}" />
</page>
<script>
function handleTap() {
// Handle button tap
}
</script>
Both frameworks offer mobile app development capabilities, but Quasar provides a more comprehensive ecosystem for cross-platform development, while Svelte Native focuses on a lightweight, performant approach specifically for mobile apps using NativeScript.
Full featured HTML framework for building iOS & Android apps
Pros of Framework7
- More mature and feature-rich framework with a larger ecosystem
- Supports multiple view engines (React, Vue, Svelte) for flexibility
- Extensive UI components and pre-built themes for rapid development
Cons of Framework7
- Steeper learning curve due to its comprehensive nature
- Larger bundle size, which may impact performance on low-end devices
- Less native-like look and feel compared to NativeScript-based solutions
Code Comparison
Svelte Native:
<page>
<actionBar title="Svelte Native App" />
<stackLayout>
<label text="Welcome to Svelte Native!" />
</stackLayout>
</page>
Framework7:
<template>
<f7-page>
<f7-navbar title="Framework7 App"></f7-navbar>
<f7-block>
<p>Welcome to Framework7!</p>
</f7-block>
</f7-page>
</template>
Summary
Framework7 offers a more comprehensive solution with cross-platform support and a rich set of UI components. It's suitable for developers who prioritize rapid development and flexibility in view engines. However, Svelte Native provides a more native-like experience and potentially better performance on mobile devices, especially for simpler applications. The choice between the two depends on project requirements, target platforms, and developer preferences.
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
Svelte Native
Create Mobile applications using native widgets via Svelte and NativeScript.
See https://svelte-native.technology for docs and tutorials
Features
Svelte-Native includes Svelte specific integrations such as
- The ability to use svelte components to create native applications on top of NativeScript core
- Svelte specific navigation and modals eg
navigate({ page: MySvelteComponent })
- Integration with svelte's transistions eg
<label transition:fade="{duration: 2000}">
- Integration with sveltes scoped styles
- Complete coverage of the Nativescript core UI modules
- Uses unmodified Svelte and Nativescript modules
Work In Progress
While Svelte Native is feature complete, there are some items outstanding to bring it to the level of other Nativescript library integrations
- At least 1 emoji in readme.md :+1:
- More Tests ð³ #54
Installation
You can get started developing with this using the latest template
$ npm install -g nativescript
$ tns create myapp --template @nativescript/template-blank-svelte
A fresh Svelte Native app will be found in the myapp
folder
Once installed use the tns preview
, tns build
or tns run
commands as for a normal NativeScript application.
Usage
App.svelte
<page>
<actionBar title="Svelte Native"></actionBar>
<stackLayout>
<label text={msg}></label>
<button text="Change" on:tap="{toggle}"></button>
</stackLayout>
</page>
<script>
export let msg = 'Hello World!'
const toggle = () => {
msg = "Hi from svelte"
}
</script>
Main.ts
import App from './components/App.svelte';
import { svelteNative } from 'svelte-native'
svelteNative(App, {msg: "Hi from launcher"});
Examples
Svelte Native HackerNews
Simple HackerNews client in Svelte Native.
See https://github.com/halfnelson/svelte-native-hackernews for the repo.
Svelte Native Grocery
Grocery app example in Svelte Native.
See https://github.com/halfnelson/svelte-native-grocery for the repo.
Svelte Native Realworld
Realworld implementation app in Svelte Native.
See https://github.com/halfnelson/svelte-native-realworld for the repo.
Credits
The DOM implementation is based on the one from Nativescript-Vue. Thanks! The API Docs were ported from the Nativescript-Vue Too The Site Design is from SvelteJS
Top Related Projects
Native mobile applications using Vue and 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.
A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
👾 Clean and minimalist React Native template for a quick start with TypeScript.
Remote Administration Tool for Windows
Full featured HTML framework for building iOS & Android apps
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