What's the purpose of "ASP.NET Core hosted" in Blazor WASM app?

Blazor server app almost works like a distributed desktop app. Every event on the browser is sent to the server, the server handles the event, calculates resulting changes in the DOM and sends the diffed DOM which is then applied to the page by the browser side js and the page is updated.

The use of traditional web API style pattern is completely optional here. In a Blazor server app you need not write a single web API for the app to work. Everything can be written as if it is a single desktop application.

A webassembly app is richer. The app actually runs on the browser, everything (event handling, UI refresh etc) is done on the client side only. These are so called 'static apps/websites' which, once loaded, require nothing else to execute. Imagine a single player, flash style games - they don't need connection to a database/application server.

However, there are hardly any rich apps which do not require even the basic database connectivity. So how does an app - say a gaming app that maintains a leaderboard - communicate with application servers and databases which maintain application data remotely? This is where the hosted model comes handy. In a typical web application scenario, you essentially need three components 1) Client side code - the app 2) Server side code - the web API - to maintain state 3) Shared object model - so that the first two can communicate seamlessly. That is what you see in a ".net core hosted" option. The template creates boilerplate for all three components. The classes that will be used by both client and server are put in the shared project. The server side and client side logic exists in their respective projects and both of these refer to the shared project without referring to each other.

Is it mandatory to have this to run a webassembly app? No. You can write your server side logic on any platform of your choice - it need not be asp.net - and call that API from the Blazor webassembly app . However, you will still end up creating mappers for client server communication classes. The .net core hosted option offers a very convenient way to do this.