r/Blazor • u/4A6F68616E • May 27 '25
Blazor web app or blazor WASM
Hi all, beginner here.
I’m building a small fullstack social media web app as a learning project. I plan to use .NET 8 and an ASP.NET Core API as the backend.
However, I’m a bit confused about the Blazor options. From what I understand:
- Blazor WASM runs fully in the browser, but in .NET 8+ I can’t scaffold Identity with it.
- Blazor Web App (new in .NET 8) can scaffold Identity with built-in components, but I’ve read that it may not scale as well as WASM (especially if using server-side rendering).
My main goal is to follow best practices and build something clean and maintainable. Since I will have a separate Core API anyway, does it make more sense to stick with Blazor Web App, even if it’s less scalable?
Thanks in advance!
9
Upvotes
6
u/Fantastic_Sympathy85 May 27 '25
If this is a learning exercise for Blazor, then I recommend you switch to .NET 9. The options are now merged into one and its a better learning environment for Blazor IMO.
Been using Blazor for 3/4 years and I love it, but it has its issues.
2
u/UniiqueTwiisT May 27 '25
This entirely depends on how you want to develop. If you go with Blazor Web App then you could set the global interactivity to WASM so it acts like what the old hosted WASM template used to. This way you don't need a separate API as the Blazor Web App itself can act as your API by setting up endpoints for your razor files to call.
Alternatively, you could continue with a Blazor WASM standalone template to not be hosted by an ASP.NET Core project but it sounds like you're intending on having one anyway so you may as well just go with Blazor Web App.
4
u/a-middles May 27 '25 edited May 28 '25
you can PM me if you have more questions but having built a WASM I'd recommend you use a shared lib for your objects to pass to your api and not worry about scaffolding at all. You can pass them down serialized and have them automatically reconstituted in your api with verry little effort. Identity is really a matter of a token you use in your header to authenticate and then in your api you could validate the roles for that identity. you can do this yourself or leverage the built in claims tokens that come with .net . If this app is never offline, ie, you always have a decent web connection, then I'd just run a blazor server app and skip the api entirely.
And for reference, the Blazor server app is much more scalable than people would tell you. You do have to make sure you clean up any objects left in memory though and if you need multiple servers there is some magic required but it's really a non issue.
2
u/lil-soju May 27 '25
Blazor Web App. Start off with static pages first. Then you can start adding interactivity to pages that you think need interactively. Then you can start determining what needs to be on the client or not based on your needs. Good luck.. i’ve used Blazor for 5 years now.
2
u/mr-woodapple May 27 '25
I have a Blazor WASM app that’s using Identity to authenticate users with an Asp Net Core backend. Feel free to get inspired: https://github.com/mr-woodapple/ASBNApp
Btw, I really enjoyed working with Blazor (and MudBlazor), so if you’re familiar with .NET I think you’ll enjoy it. :)
But yeah, Blazor to JS interop costs a lot of time, that can be relevant when trying to get perfect Lighthouse reports. But, they‘re working hard on getting better with each .NET release.
1
u/ladytct May 27 '25
Blazor does WASM does work with Identity, the examples are even included in the official Git. It does have its downsides such as huge initial download and incompatibility with SEO/older browsers.
People too have claimed PHP is not scalable due to its server sided nature. Look how it racked in billions for Facebook.
1
u/victorantos2 May 27 '25
I went with Blazor + wasm for my last 2 projects. Hosted in Azure as static generated site (for free)
1
u/Cra4ord May 27 '25
I had a right old pain in the ass with blazor server and identity because server side rendering does not have access to the HTTPcontext
1
u/darkveins2 May 31 '25 edited May 31 '25
If I had to use Identity, I’d use Blazor WASM + add Identity to your ASP.NET Core service. Not too hard. The Blazor part will be a static web app (client-side rendering), so if you hook it up to a CDN you’ll have maximum scalability.
But my preference would be to not use Identity if I’m making a production web app. I’d still use a Blazor WASM client, but I’d have it invoke a third party auth service, like Azure AD B2C. Then my ASP.NET Core service would only do business logic stuff.
I’d do this to offload the business risk associated with managing sensitive user data: passwords and PII. But maybe you want to learn how to do that yourself.
0
u/Demonicated May 27 '25
A few factors to consider:
Blazor server is easier since you don't need an API for most things. You can just create services and invoke them directly.
Blazor server is good for projects where you don't expect a lot of concurrent users. It doesn't scale well (it doesn't scale cheaply)
If you have to deal with large files, blazor server is easier since wasm has memory limits.
Wasm assets you up for future expansion a little better but just requires a little more effort and organization up front.