{"id":1255,"date":"2017-06-12T14:31:57","date_gmt":"2017-06-12T12:31:57","guid":{"rendered":"https:\/\/blog.thecodecampus.de\/?p=1255"},"modified":"2026-02-20T08:51:42","modified_gmt":"2026-02-20T07:51:42","slug":"reuse-angular-code-within-nativescript-apps","status":"publish","type":"post","link":"https:\/\/www.thecodecampus.de\/blog\/reuse-angular-code-within-nativescript-apps\/","title":{"rendered":"Reuse Angular Code within NativeScript Apps"},"content":{"rendered":"<p>NativeScript is a great framework to write mobile Apps for Android and iOS with Angular (2, 4 and so on).<\/p>\n<p>Read on, if you:<\/p>\n<ul>\n<li>have an existing Angular Web App or are planning to develop one<\/li>\n<li>you want to offer a native App for Android and iOS without a lot of extra work<\/li>\n<\/ul>\n<p><b>TL;DR<\/b>\u00a0It is possible to reuse code, especially Services and Pipes, if you are lucky some of the Components.<\/p>\n<p>I will show three possibilities to share code between a web and a native app, but in regards to usability keep following in mind:<\/p>\n<ul>\n<li>a website has more static content and more space to show elements<\/li>\n<li>a smartphone has a smaller screen, users are used to the native elements and want to find\/use stuff inside apps fast without much distraction<\/li>\n<\/ul>\n<p>So maybe it is not the best practice to port a web app 1:1 on a native app.<\/p>\n<p>But now, the three possibilities &#8230;<\/p>\n<h2><\/h2>\n<h2>1. Seed Projects<\/h2>\n<p><a href=\"https:\/\/github.com\/jlooper\/angular-starter\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/jlooper\/angular-starter<\/a><\/p>\n<p><strong>Goal:<\/strong><\/p>\n<ul>\n<li>a single workspace with a working Angular Web App and NativeScript App<\/li>\n<li>maximum code reuse, at first only templates are platform dependent\n<ul>\n<li>Angular: *.html<\/li>\n<li>NativeScript: *.tns.html<\/li>\n<\/ul>\n<\/li>\n<li>shared code in &#8220;shared&#8221; folder<\/li>\n<li>own build system<\/li>\n<\/ul>\n<p><strong>Pro:<\/strong><\/p>\n<ul>\n<li>easy to start a project<\/li>\n<\/ul>\n<p><strong>Contra:<\/strong><\/p>\n<ul>\n<li>mobile and web UIs are different, so at a long run, you are going to need components for each platform and can only share services and pipes<\/li>\n<li>lot&#8217;s of build &#8220;magic&#8221;<\/li>\n<\/ul>\n<h2><\/h2>\n<h2>2. npm-package<\/h2>\n<p><strong>Goal:<\/strong><\/p>\n<ul>\n<li>pack your shared code into a npm package<\/li>\n<li>shared Angular should be placed in Angular modules<\/li>\n<li>use the package and the modules in your NativeScript app<\/li>\n<\/ul>\n<p><strong>Pro:<\/strong><\/p>\n<ul>\n<li>useful if your web app is already finished<\/li>\n<li>projects can be placed in different folders<\/li>\n<\/ul>\n<p><strong>Contra:<\/strong><\/p>\n<ul>\n<li>you need a build system and a private npm repository<\/li>\n<\/ul>\n<h2><\/h2>\n<h2>3. shared-folder<\/h2>\n<p><strong>Goal:<\/strong><\/p>\n<ul>\n<li>web app client: put all shared angular code into a &#8220;shared&#8221; folder<\/li>\n<li>include the &#8220;shared&#8221; folder via symlinks into your NativeScript app\/ folder<\/li>\n<\/ul>\n<p><strong>Pro:<\/strong><\/p>\n<ul>\n<li>nice for prototyping<\/li>\n<li>pragmatic<\/li>\n<li>every project can use the own build tool<\/li>\n<\/ul>\n<p><strong>Contra:<\/strong><\/p>\n<ul>\n<li>not sure, if it works under Windows<\/li>\n<li>Angular versions and other dependencies always have to be the same in both projects<\/li>\n<\/ul>\n<h2><\/h2>\n<h2>Hints<\/h2>\n<ul>\n<li>don&#8217;t reference\u00a0<span class=\"lang:default decode:true crayon-inline \">window<\/span>\u00a0in shared code<\/li>\n<li>abstract platform specific code with e.g. facade pattern (there is no local-storage on a mobile app)<\/li>\n<li>use the same npm dependencies<\/li>\n<\/ul>\n<h2><\/h2>\n<h2>Conclusion<\/h2>\n<p>I used the last approach to write a prototype NativeScript app from an existing web-app (Calendar for Trello). I was able to reuse the a complete redux store and all of the services, after I matched the dependencies on both projects.<\/p>\n<p>I didn&#8217;t reuse any of the components, because in my opinion the mobile app had a different use case. It worked quite well and showed us, that it&#8217;s possible to reuse code and get a native UI with NativeScript.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>NativeScript is a great framework to write mobile Apps for Android and iOS with Angular (2, 4 and so on). Read on, if you: have an existing Angular Web App or are planning to develop one you want to offer a native App for Android and iOS without a lot of extra work TL;DR\u00a0It is [&#8230;]<br \/><a class=\"meta-big\" href=\"https:\/\/www.thecodecampus.de\/blog\/reuse-angular-code-within-nativescript-apps\/\"> READ MORE<\/a><\/p>\n","protected":false},"author":29,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73,2,63],"tags":[],"class_list":["post-1255","post","type-post","status-publish","format-standard","hentry","category-angular","category-javascript","category-nativescript"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Reuse Angular Code within NativeScript Apps - Web Development Blog<\/title>\n<meta name=\"description\" content=\"Revolutionize NativeScript. Reuse Angular code seamlessly. Elevate app efficiency, code sharing. Transform your cross-platform projects now!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.thecodecampus.de\/blog\/reuse-angular-code-within-nativescript-apps\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Reuse Angular Code within NativeScript Apps - Web Development Blog\" \/>\n<meta property=\"og:description\" content=\"Revolutionize NativeScript. Reuse Angular code seamlessly. Elevate app efficiency, code sharing. Transform your cross-platform projects now!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.thecodecampus.de\/blog\/reuse-angular-code-within-nativescript-apps\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Development tips and tricks - theCodeCampus Blog\" \/>\n<meta property=\"article:published_time\" content=\"2017-06-12T12:31:57+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-02-20T07:51:42+00:00\" \/>\n<meta name=\"author\" content=\"theCodeCampus\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"theCodeCampus\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/reuse-angular-code-within-nativescript-apps\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/reuse-angular-code-within-nativescript-apps\\\/\"},\"author\":{\"name\":\"theCodeCampus\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#\\\/schema\\\/person\\\/276bbda2f8da73154f22fb652201cfbc\"},\"headline\":\"Reuse Angular Code within NativeScript Apps\",\"datePublished\":\"2017-06-12T12:31:57+00:00\",\"dateModified\":\"2026-02-20T07:51:42+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/reuse-angular-code-within-nativescript-apps\\\/\"},\"wordCount\":470,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#organization\"},\"articleSection\":[\"Angular\",\"JavaScript\",\"NativeScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/reuse-angular-code-within-nativescript-apps\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/reuse-angular-code-within-nativescript-apps\\\/\",\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/reuse-angular-code-within-nativescript-apps\\\/\",\"name\":\"Reuse Angular Code within NativeScript Apps - Web Development Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#website\"},\"datePublished\":\"2017-06-12T12:31:57+00:00\",\"dateModified\":\"2026-02-20T07:51:42+00:00\",\"description\":\"Revolutionize NativeScript. Reuse Angular code seamlessly. Elevate app efficiency, code sharing. Transform your cross-platform projects now!\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/reuse-angular-code-within-nativescript-apps\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/reuse-angular-code-within-nativescript-apps\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/reuse-angular-code-within-nativescript-apps\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Reuse Angular Code within NativeScript Apps\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/\",\"name\":\"Web Development tips and tricks - theCodeCampus Blog\",\"description\":\"Tips, tricks, and experiences about developing web and mobile applications with Angular, TypeScript, and Testing.\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#organization\",\"name\":\"theCodeCampus\",\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/TCC-Logo-Bildmarke-quadratisch.jpg\",\"contentUrl\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/TCC-Logo-Bildmarke-quadratisch.jpg\",\"width\":156,\"height\":156,\"caption\":\"theCodeCampus\"},\"image\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#\\\/schema\\\/person\\\/276bbda2f8da73154f22fb652201cfbc\",\"name\":\"theCodeCampus\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/TCC-Logo-Bildmarke-quadratisch-96x96.jpg\",\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/TCC-Logo-Bildmarke-quadratisch-96x96.jpg\",\"contentUrl\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/TCC-Logo-Bildmarke-quadratisch-96x96.jpg\",\"caption\":\"theCodeCampus\"},\"description\":\"Our knowledge is not simply gained through reading - it is trained, tested and constantly being expanded. Because first and foremost, we are all developers at W11K. The know-how that we acquire here as developers, consultants and information architects flows immediately into our training courses and articles for theCodeCampus.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/showcase\\\/thecodecampus\\\/\"],\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Reuse Angular Code within NativeScript Apps - Web Development Blog","description":"Revolutionize NativeScript. Reuse Angular code seamlessly. Elevate app efficiency, code sharing. Transform your cross-platform projects now!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.thecodecampus.de\/blog\/reuse-angular-code-within-nativescript-apps\/","og_locale":"en_US","og_type":"article","og_title":"Reuse Angular Code within NativeScript Apps - Web Development Blog","og_description":"Revolutionize NativeScript. Reuse Angular code seamlessly. Elevate app efficiency, code sharing. Transform your cross-platform projects now!","og_url":"https:\/\/www.thecodecampus.de\/blog\/reuse-angular-code-within-nativescript-apps\/","og_site_name":"Web Development tips and tricks - theCodeCampus Blog","article_published_time":"2017-06-12T12:31:57+00:00","article_modified_time":"2026-02-20T07:51:42+00:00","author":"theCodeCampus","twitter_card":"summary_large_image","twitter_misc":{"Written by":"theCodeCampus","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.thecodecampus.de\/blog\/reuse-angular-code-within-nativescript-apps\/#article","isPartOf":{"@id":"https:\/\/www.thecodecampus.de\/blog\/reuse-angular-code-within-nativescript-apps\/"},"author":{"name":"theCodeCampus","@id":"https:\/\/www.thecodecampus.de\/blog\/#\/schema\/person\/276bbda2f8da73154f22fb652201cfbc"},"headline":"Reuse Angular Code within NativeScript Apps","datePublished":"2017-06-12T12:31:57+00:00","dateModified":"2026-02-20T07:51:42+00:00","mainEntityOfPage":{"@id":"https:\/\/www.thecodecampus.de\/blog\/reuse-angular-code-within-nativescript-apps\/"},"wordCount":470,"commentCount":0,"publisher":{"@id":"https:\/\/www.thecodecampus.de\/blog\/#organization"},"articleSection":["Angular","JavaScript","NativeScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.thecodecampus.de\/blog\/reuse-angular-code-within-nativescript-apps\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.thecodecampus.de\/blog\/reuse-angular-code-within-nativescript-apps\/","url":"https:\/\/www.thecodecampus.de\/blog\/reuse-angular-code-within-nativescript-apps\/","name":"Reuse Angular Code within NativeScript Apps - Web Development Blog","isPartOf":{"@id":"https:\/\/www.thecodecampus.de\/blog\/#website"},"datePublished":"2017-06-12T12:31:57+00:00","dateModified":"2026-02-20T07:51:42+00:00","description":"Revolutionize NativeScript. Reuse Angular code seamlessly. Elevate app efficiency, code sharing. Transform your cross-platform projects now!","breadcrumb":{"@id":"https:\/\/www.thecodecampus.de\/blog\/reuse-angular-code-within-nativescript-apps\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.thecodecampus.de\/blog\/reuse-angular-code-within-nativescript-apps\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.thecodecampus.de\/blog\/reuse-angular-code-within-nativescript-apps\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.thecodecampus.de\/blog\/"},{"@type":"ListItem","position":2,"name":"Reuse Angular Code within NativeScript Apps"}]},{"@type":"WebSite","@id":"https:\/\/www.thecodecampus.de\/blog\/#website","url":"https:\/\/www.thecodecampus.de\/blog\/","name":"Web Development tips and tricks - theCodeCampus Blog","description":"Tips, tricks, and experiences about developing web and mobile applications with Angular, TypeScript, and Testing.","publisher":{"@id":"https:\/\/www.thecodecampus.de\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.thecodecampus.de\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.thecodecampus.de\/blog\/#organization","name":"theCodeCampus","url":"https:\/\/www.thecodecampus.de\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.thecodecampus.de\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2024\/01\/TCC-Logo-Bildmarke-quadratisch.jpg","contentUrl":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2024\/01\/TCC-Logo-Bildmarke-quadratisch.jpg","width":156,"height":156,"caption":"theCodeCampus"},"image":{"@id":"https:\/\/www.thecodecampus.de\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.thecodecampus.de\/blog\/#\/schema\/person\/276bbda2f8da73154f22fb652201cfbc","name":"theCodeCampus","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2024\/01\/TCC-Logo-Bildmarke-quadratisch-96x96.jpg","url":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2024\/01\/TCC-Logo-Bildmarke-quadratisch-96x96.jpg","contentUrl":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2024\/01\/TCC-Logo-Bildmarke-quadratisch-96x96.jpg","caption":"theCodeCampus"},"description":"Our knowledge is not simply gained through reading - it is trained, tested and constantly being expanded. Because first and foremost, we are all developers at W11K. The know-how that we acquire here as developers, consultants and information architects flows immediately into our training courses and articles for theCodeCampus.","sameAs":["https:\/\/www.linkedin.com\/showcase\/thecodecampus\/"],"url":"https:\/\/www.thecodecampus.de\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/posts\/1255","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/users\/29"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/comments?post=1255"}],"version-history":[{"count":10,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/posts\/1255\/revisions"}],"predecessor-version":[{"id":3633,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/posts\/1255\/revisions\/3633"}],"wp:attachment":[{"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/media?parent=1255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/categories?post=1255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/tags?post=1255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}