What are the sensible front-end options for a server-rendered app in the current landscape?
I maintain an application whose framework renders HTML on the server, and it works well. Parts of it now want more interactivity than a page reload gives — live filtering, inline editing, a couple of genuinely dynamic screens.
The advice I find splits between rewriting the front end as a single-page application talking to an API, and adding something lighter on top of the templates. The first sounds like a lot of work to solve a problem in three screens.
How do people decide, and what does the middle ground actually look like?
@web_yasemin · 6d ago
The middle ground is now well populated and it is where most applications in your position land.
The options, in increasing order of commitment:
1. Sprinkles of JavaScript. A small library for attaching behaviour to markup, or plain modern JavaScript. Fine for a dropdown or a toggle, and it stops scaling once state is shared between parts of a page.
2. HTML over the wire. The server keeps rendering HTML, and a small library swaps fragments in response to interactions. Your templates stay authoritative, there is no duplicated model on the client, and you keep the framework's forms and validation. For live filtering and inline editing this is usually the right answer and it is a remarkably small change.
3. Islands. Server-rendered pages with a few components mounted into them by a real framework. Right when you have a genuinely complex widget — a scheduler, a canvas, a rich editor — inside otherwise ordinary pages.
4. A full single-page application with an API. Right when the whole product is an application rather than a set of pages, or when you need offline, or when a separate mobile client wants the same API anyway.
Reply
Report