<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: sivakumar</title>
    <description>The latest articles on DEV Community by sivakumar (@sivasundar).</description>
    <link>https://dev.to/sivasundar</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F167522%2F4c514aaa-c0cc-46ad-b27b-6c875dbf2ad8.jpeg</url>
      <title>DEV Community: sivakumar</title>
      <link>https://dev.to/sivasundar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sivasundar"/>
    <language>en</language>
    <item>
      <title>Mount light weighted apps into Ember</title>
      <dc:creator>sivakumar</dc:creator>
      <pubDate>Tue, 27 Apr 2021 15:58:59 +0000</pubDate>
      <link>https://dev.to/sivasundar/mount-light-weighted-apps-into-ember-21ga</link>
      <guid>https://dev.to/sivasundar/mount-light-weighted-apps-into-ember-21ga</guid>
      <description>&lt;p&gt;This article is a demonstration on how to mount light weighted apps made with Preact, Svelte, etc. along with a dedicated router into Ember.&lt;/p&gt;

&lt;p&gt;Right now, this can be achieved with certain router packages​ like &lt;a href="https://single-spa.js.org"&gt;https://single-spa.js.org&lt;/a&gt;. However, let's try a different approach.&lt;br&gt;
&lt;br&gt;&lt;br&gt;
For demo, let's choose &lt;strong&gt;Ember and Preact&lt;/strong&gt; and define two routes in Ember&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RtLKWCQM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uye1s6tw35ysznxfficz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RtLKWCQM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uye1s6tw35ysznxfficz.png" alt="image"&gt;&lt;/a&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;And again define three routes in Preact&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6EArdrO6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8kjoaxfecmp3ud7eeuv3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6EArdrO6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8kjoaxfecmp3ud7eeuv3.png" alt="image"&gt;&lt;/a&gt;&lt;br&gt; &lt;/p&gt;

&lt;p&gt;At this point, these are two stand-alone apps, which would render in different html pages. Let &lt;strong&gt;Ember&lt;/strong&gt; be our &lt;strong&gt;base app&lt;/strong&gt;,  and to mount Preact App into Ember, we need &lt;strong&gt;a route(page) which certainly acts as an exit point for Ember and entry point for the Preact App&lt;/strong&gt;.&lt;br&gt;
​&lt;br&gt;
There are two set of changes here.&lt;/p&gt;

&lt;p&gt;​1. Define &lt;strong&gt;exit route&lt;/strong&gt; in Ember(Say &lt;code&gt;/ember-exit-route&lt;/code&gt;)​&lt;br&gt;
​2. Use &lt;code&gt;/ember-exit-route&lt;/code&gt; as &lt;strong&gt;base url&lt;/strong&gt; for the Preact App.&lt;br&gt;
​&lt;br&gt;
Now, we add two more routes in the Ember App, which handles the url &lt;code&gt;/ember-exit-route&lt;/code&gt; and all child paths beyond that say(&lt;code&gt;/ember-exit-route/home&lt;/code&gt;, &lt;code&gt;/ember-exit-route/profile&lt;/code&gt;,...)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--j0w4gp-F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ro194krrg0xmtth9u812.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--j0w4gp-F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ro194krrg0xmtth9u812.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;/*path&lt;/code&gt; denotes a wildcard, which catches all the paths coming after &lt;code&gt;/ember-exit-route&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;​​​&lt;br&gt;
And we define the ​exit url as base path in the Preact App.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZEmdRQ0O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iq5xxqt9o8nar63erdd9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZEmdRQ0O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iq5xxqt9o8nar63erdd9.png" alt="image"&gt;&lt;/a&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;​​​Now, the last part, once we visit &lt;code&gt;/ember-exit-route&lt;/code&gt;, we need to load the assets of the Preact App and render it inside an element.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--W28Daz0p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/snlvgnl5bm5bf0w01xzu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--W28Daz0p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/snlvgnl5bm5bf0w01xzu.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Demo link&lt;/strong&gt;: &lt;a href="https://ember-preact-demo.netlify.app/"&gt;https://ember-preact-demo.netlify.app/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let me know your thoughts on this.&lt;/p&gt;

</description>
      <category>ember</category>
      <category>svelte</category>
      <category>react</category>
      <category>lightweightapps</category>
    </item>
  </channel>
</rss>
