Alternative to use SSR in elm

Hi, new user here.
Been watching elm since 0.18, but something hold me back to use elm as my language to build my client project, which is SSR. some of my client project require really good SEO and dynamic content. been using sveltekit recently but want to use elm for easy refactoring.
is there any alternative to Nextjs / Sveltekit in elm word?
i know there is elm-pages, but elm-pages only generate static site.
Really want to use elm, kind of tired with javascript fatigue. cheers

elm-pages generates a static site, but once the page is loaded it does rehydration and a dynamic version is made available. So you can transition from static HTML to get the initial view rendered quickly, to a full blown Elm application. I recommend you take a closer look at elm-pages it is definitely the best SSR option for Elm for at the moment. I believe there is also some support for SEO in elm-pages.

1 Like

elm-pages 2.0 was rearchitected in large part to support server side rendering. In fact, that’s exactly how the dev server works - it is able to handle a single URL on-demand, just like SSR mode would do.

We actually had some working proof of concept projects with it, so the core of that functionality already exists under the hood. The main work remaining to ship that functionality is to add adapters (similar to SvelteKit) to help setup glue code to run the server rendering on various platforms, and to build out the high-level API for accessing the request payload.

I created an issue so you can follow updates on that work here if you’re interested.


If you have some use cases for SSR, I’d love to hear about them! And if you join the #elm-pages channel on Slack, you could help us do alpha testing when we open it up for that.

1 Like

Really helpful, i will try to migrate some project to elm-pages and see how it goes. glad that someone take a look to this thing.
When Svelte move forward to sveltekit and Nextjs 12 came out recently, but at the same time i just tired to be javascript / typescript dev. Hope that Roc-lang can have big impact to elm ecosystem when it come.


i’ll keep my eye on it, thanks

1 Like

It might not be the exact answer you are looking for, but another approach to something like Next.js is the islands architecture, a term that was recently popularized with AstroJS Islands Architecture - JASON Format

I figured it was worth a mention :slightly_smiling_face:

Very shortly summarized in this context, it means write “HTML first” and write more advanced “Elm widgets” where they are needed.

I use IHP, a Haskell based multi-page-app/MVC framework. It’s comparable to Rails or Django. I actually mostly write vanilla html template code composed of pure functions (the html syntax is type-checked in IHP).

Whenever I need something more advanced view logic that Elm in suited for, I write that particular part of the page in Elm. So I use Elm like a widget engine instead of writing every part of the view in Elm.

Then I can write straightforward backend-driven HTML that will be server-side rendered. It also saves me from writing lots of HTTP requests for rendering simple views. It’s a huge time-saver with largely the same benefits in my opinion.

In sum, you get SSR code without going the extra step of turning client-side code into SSR code :grinning_face_with_smiling_eyes: And the highly dynamic widget stuff is usually not a concern for SEO.

I made a tutorial for this a while ago that can be used as a starting point.

It also demonstrates how you can share types between the Haskell backend and Elm.


indeed astrojs really appealing, i just tired of javascript stuff and wanting new approach.

come across IHP from youtube comment and right away go to their website and see

" The Haskell Framework for Non-Haskellers. Blazing fast, secure, easy to refactor and the best developer experience with everything you need - from prototype to production."

and it can use elm to, that amazing. Unfortunately a lot of my client have very small business and i don’t want to charge additional money for VPS to run IHP (and it expensive to in my country). Nodejs is the simple solution at the moment.
i’ve been learning haskell few month ago and decide to stop because overwhelmed by language extensions and decide to give elm try.

Recently I’ve been thinking to make library to write sveltekit in elm, i don’t think that is good idea… :joy: and still find a way to fitting the elm architecture in svelte, if i really want to make the library.

1 Like

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