One Elm "app" per page

I am interested in potentially using Elm to render my entire frontend, but not in an SPA-style. Rather, I am interested in the approach of rendering a template which contains all of the data and then passing the data to my Elm app for each page. (i.e. routing, core data fetching, etc is done server-side)

My basic question is, do I need to somehow create N elm apps and compile them all separately, or what is the best approach to this? That seems like it would be very difficult to maintain.

I don’t see why that would be more difficult to maintain. With a SPA, you have only one entry point: Main.elm. Implementing one Elm app per page would mean that you just replace Main.elm with PageOne.elm, PageTwo.elm etc.

The common stuff stays common.

You have the option of creating independent files for each page or you can create a single file with all the pages.

You have the option of creating independent files for each page or you can create a single file with all the pages.

If you decide to have a single page app, you could check the URL as a normal SPA, but adapting the parser to process the actual URL and not the #hash part.

This is fine, you will need to create different apps for each page. But you can compile them all at the same time in one big bundle. Something like elm make App1.elm App2.elm.

Another advantage of this approach is the ability to reuse the localization facility of your backend framework.

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