I’m confident this solution is more performant than using REST, PHP, and database queries (or similar) and I’m certain it’s more efficient than rendering the entire site on the client.
The reason I wrote it up is because it’s a good example of the kind of problem I like to solve, and how I like to solve it.
Build-rendered beats server-rendered beats client-rendered.
Where you delegate the complex logic and data-lifting to the build (using a template filter, in this case) and only supplement this using client-side scripts, you can begin to create engaging experiences with barely any loss of performance.