# Elm 0.19 Single Page App with Capacitor

**URL:** https://discourse.elm-lang.org/t/elm-0-19-single-page-app-with-capacitor/3988
**Category:** Learn
**Created:** [July 15, 2019, 2:26am UTC](https://discourse.elm-lang.org/t/elm-0-19-single-page-app-with-capacitor/3988 "2019-07-15T02:26:04Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![sammarten](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/sammarten/32/2344_2.png) [@sammarten](https://discourse.elm-lang.org/u/sammarten)
#### Post date: [July 15, 2019, 2:26am UTC](https://discourse.elm-lang.org/t/elm-0-19-single-page-app-with-capacitor/3988/1 "2019-07-15T02:26:04Z")

</div>

I would love to use one code base for an app I’m creating. It needs to run on both web and native mobile (for push notifications).

I’ve enjoyed the routing features introduced with Elm 0.19 and [Capacitor](https://capacitor.ionicframework.com/docs/getting-started/) seems to be a simple solution for adding native platforms to a project. For those interested, Will Strinz wrote an excellent introduction for using Elm with Capacitor [here](https://bendyworks.com/blog/capacitor-elm).

I created the app for web first and then added in Capacitor. As the app was booting in the iOS simulator it errored out because Capacitor attempts to serve the app in iOS from `capacitor://localhost` while `elm/url` accepts only `http` or `https` as valid schemes.

[This issue](https://github.com/elm/url/issues/10) addresses the problem. I am so close on this that I don’t want to abandon Capacitor. And I don’t want to give up Elm routing either. My thought is to download `elm/url` and `elm/browser` locally, make a small update to `elm/url` so that it supports the `capacitor` scheme and rebuild both locally. However, I encounter this error attempting to compile `elm/browser`:

```auto
elm make src/Browser.elm
Dependencies loaded from local cache.
Dependencies ready!                
elm: Cannot find kernel import of: Browser.Dom
CallStack (from HasCallStack):
  error, called at compiler/src/Elm/Kernel.hs:99:9 in main:Elm.Kernel

```

This makes me wonder if it is even possible to compile core Elm packages locally 🤔

Ultimately I have two questions:

1. Has anyone been successful running Elm 0.19 with `elm/browser`'s routing in Capacitor?
2. Is it possible to build core Elm components locally?

I would very much like to know how either or both of these can be achieved.

Thank you very much for your time!

---

<div class="post-metadata">

### Author: ![miniBill](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/minibill/32/800_2.png) [@miniBill](https://discourse.elm-lang.org/u/miniBill)
#### Post date: [July 15, 2019, 5:38am UTC](https://discourse.elm-lang.org/t/elm-0-19-single-page-app-with-capacitor/3988/2 "2019-07-15T05:38:23Z")

</div>

You cannot have Kernel code in your own application, so some core packages cannot be compiled locally, normally.

You’ve basically got three solutions:

1. use the hackish way of patching your local cached copy in `$HOME/.elm` while you wait for the updated package to be published. This is documented in some discussions here, it’s hackish, doesn’t scale if you want to collaborate with someone else, but works for this kind of “small edit, while waiting a patch” scenarios
2. recompile the Elm compiler removing the kernel code restriction
3. monkey patch the js object that is used by elm-url so that it lies

---

<div class="post-metadata">

### Author: ![sammarten](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/sammarten/32/2344_2.png) [@sammarten](https://discourse.elm-lang.org/u/sammarten)
#### Post date: [July 15, 2019, 7:25pm UTC](https://discourse.elm-lang.org/t/elm-0-19-single-page-app-with-capacitor/3988/3 "2019-07-15T19:25:52Z")

</div>

Thank you very much for the reply @miniBill!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)
#### Post date: [July 26, 2019, 10:11am UTC](https://discourse.elm-lang.org/t/elm-0-19-single-page-app-with-capacitor/3988/5 "2019-07-26T10:11:41Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
