Discussion: Imagine a Storefront Hook API

This is just food for thought, something I've been pondering lately:

For manipulating the storefront UI experience of a shopify store, the only extension point available to apps is liquid templates and client-side JS. The main issue I see is that liquid, being only a templating language, is ill-suited for performing business logic. So, what we're left with is business logic being implemented in client-side JS, which may work fine but doesn't really feel like the best place for it. Of course, an app can make calls out to home to perform logic server-side I guess.

But anyway, what I'm getting at is what if Shopify had another extension point in the form of some kind of Storefront Hook API. This would be a way for apps to write code to be executed server-side (on Shopify servers) at various points in the storefront UX process. Hooks could be used to modify or decorate the context/variables that's made available to the liquid templates on product pages, the cart, checkout, etc. In the hooks the code could call out to external resources, perform business logic, whatever. This would move all of that out of liquid and into whatever programming language they wanted to execute them in, and perhaps minimize the amount of client-side DOM manipulation that apps need to do.

Maybe this is dumb, but what do you all think?

A place I've seen this kind of thing work well is in Auth0's "hooks" and "rules" abstractions: https://auth0.com/docs/hooks