<story><title>Don’t build a general purpose API to power your own front end (2021)</title><url>https://max.engineer/server-informed-ui</url></story><parent_chain><item><author>Y-bar</author><text>&amp;gt; Imagine if you could just send it the whole “page” worth of JSON. Make an endpoint for &amp;#x2F;page&amp;#x2F;a and render the whole JSON for &amp;#x2F;page&amp;#x2F;a there. Do this for every page. Don’t force your front-end developers to send a bunch of individual requests to render a complex page. Stop annoying them with contrived limitations. Align yourselves.&lt;p&gt;Why not just send HTML as a single response at this stage? Sometimes it feels like we are doing web development more complex than it needs to be.</text></item></parent_chain><comment><author>renegade-otter</author><text>How did we get to the point where simple and effective server-side pages are either unknown as a way of doing things or are considered to be a technical heresy?&lt;p&gt;Younger developers scoff at us fossils and the olden ways, but this is exactly how this ignorance of classic, tried-and-true, performant patterns results in atrocious complexity and performance, only because &amp;quot;this is how things are done&amp;quot;.&lt;p&gt;It HAS to be a BFF, it HAS to be 15 different microservices and 20 different AWS toys, right? There is no other way? Are you sure?&lt;p&gt;It seems like we are talking about the whole industry, but it&amp;#x27;s largely he Node ecosystem in my experience (which is effectively - the industry). It&amp;#x27;s not like there is not Rails development being done out there, with nothing but a trusty Postgres database.&lt;p&gt;Ironically, our existing architecture patterns are beginning to resemble J2EE - a bulky, slow, expensive, boiler-plate-laden process where a simple site costs one million dollars and performs like shit.</text></comment>
<story><title>Don’t build a general purpose API to power your own front end (2021)</title><url>https://max.engineer/server-informed-ui</url></story><parent_chain><item><author>Y-bar</author><text>&amp;gt; Imagine if you could just send it the whole “page” worth of JSON. Make an endpoint for &amp;#x2F;page&amp;#x2F;a and render the whole JSON for &amp;#x2F;page&amp;#x2F;a there. Do this for every page. Don’t force your front-end developers to send a bunch of individual requests to render a complex page. Stop annoying them with contrived limitations. Align yourselves.&lt;p&gt;Why not just send HTML as a single response at this stage? Sometimes it feels like we are doing web development more complex than it needs to be.</text></item></parent_chain><comment><author>littlecranky67</author><text>Feels like the author misses the point of an SPA. If you have website where every &amp;quot;view&amp;quot; is a &amp;#x2F;page&amp;#x2F;a etc., SPA might not be the best choice. But in an SPA i can be dynamic, and trigger data retrieval&amp;#x2F;sending without route changes.&lt;p&gt;A very basic example is if I have a checkbox that allows the user to subscribe to push notifications. On click I sent a xhr request to the backend POST `&amp;#x2F;subscribe&amp;#x2F;1234` which registers the subscription. Next time I&amp;#x27;ll check `&amp;#x2F;subscriptions` or similar to see if the checbbox is in &amp;quot;checked&amp;quot; state (i.e. we are subscribed). This is basic functionality which requires a concise REST&amp;#x2F;JSON API, and has nothing todo with your page&amp;#x2F;route layout à la &amp;#x2F;page&amp;#x2F;a, &amp;#x2F;page&amp;#x2F;b etc.</text></comment>