Thanks for stopping by. This is the code repository for Web Development with Blazor, Fourth Edition, published by Packt.
Jimmy Engström
Blazor has grown, and with that growth comes a simple question: How should we build Blazor apps today?
This book answers that question by building a real application step by step. We start with what Blazor is, why it is not just WebAssembly, and how the different hosting models fit together. From there, we create components, manage state, build forms with validation, add APIs, secure the app with authentication and authorization, use JavaScript when it makes sense, and test our components with bUnit.
We also look at the key aspects of modern Blazor development, including render modes, server-side rendering, WebAssembly, Aspire, OpenTelemetry, debugging, deployment, and how to work with existing sites when starting from scratch is not an option.
The goal is not only to copy code but also to understand why we choose one approach over another. Should this be SSR, Server, WebAssembly, or Auto? Where should interactivity live? What changes when the code runs in the browser? We answer those questions without making things more complicated than they need to be.
Whether you're new to Blazor or upgrading from an earlier edition, the fourth edition brings the book up to date with .NET 10, Aspire, tracing, metrics, testing, and modern Blazor app development.
Own a raccoon cover already? The collection must continue. The raccoons insist.
- Understand how Blazor works and when to use each render mode
- Build simple and advanced Blazor components with confidence
- Structure applications to separate concerns and support multiple hosting models
- Implement authentication and authorization using modern .NET patterns
- Improve performance with caching and rendering optimizations
- Use OpenTelemetry to gain insights into application behavior and performance
- Build, run, and manage applications using Aspire
- Hello Blazor
- Creating Your First Blazor App
- Exploring Render Modes
- Uncovering Aspire
- Managing State – Part 1
- Understanding Basic Blazor Components
- Creating Advanced Blazor Components
- Building Forms with Validation
- Creating an API
- Adding Authentication and Authorization
- Sharing Code and Resources
- JavaScript Interop
- Managing State – Part 2
- Debugging the Code
- Exploring Tracing and Metrics
- Testing
- Deploy to Production
- Moving From, or Combining, an Existing Site
- Going Deeper into WebAssembly
- Examining Source Generators
- Visiting .NET MAUI
- Where to Go from Here
The book is all about getting you started with Blazor – whether you're building with Blazor Server, Blazor WebAssembly, or just curious about what’s new in .NET and how it all fits together.
We start from scratch, building a blog engine that evolves through the chapters. Along the way, we cover:
- Blazor Server and WebAssembly
- Forms and validation
- APIs and minimal APIs
- Authentication with Auth0
- State management (in a few different ways)
- JavaScript interop
- Testing with bUnit
- New stuff like SSR, render modes, and .NET Aspire
- And even how to deploy the whole thing
Each chapter has its own folder, and you can jump in wherever you want. If you’re just testing things out, you can grab the code for a specific chapter without reading everything before it. You do you.
I recommend reading the first few chapters to ensure you are up to speed with the basic concepts of Blazor in general. The project we are creating is adapted for real-world use, but some parts are left out, such as proper error handling. You should, however, get a good grasp of the building blocks of Blazor.br> The book focuses on using Visual Studio 2026. That said, feel free to use whichever version you are comfortable with that supports Blazor.
| Software covered in this book | OS requirements |
| Visual Studio 2026, .NET 10 | Windows 10 or later, macOS, Linux |
To get rolling:
-
Clone this repo
git clone https://github.com/PacktPublishing/Web-Development-with-Blazor-4E.git -
Pick the chapter you want to run Example:
cd Chapter05 -
Open the solution file in Visual Studio (or VS Code, if you prefer)
-
Make sure you have the correct .NET SDK installed (we use .NET 10 in the book)
I would love for you to share your progress while reading this book or in Blazor development in general. Tweet me at @EngstromJimmy.
Each folder in the repo matches a chapter in the book. Most of them are self-contained, so feel free to jump around:
Chapter02: Setting up your first Blazor appChapter03: Render modes in .NET 8 and beyondChapter04: Working with .NET AspireChapter05: Data access and repositoriesChapter06: Blazor componentsChapter08: Forms and validationChapter09: Creating APIsChapter10: Auth with Auth0Chapter12: Managing stateChapter16: Testing with bUnitChapter18: Mixing Blazor with other frameworks (if you really have to)
And more.
If you run into issues with the code, feel free to open an issue here on GitHub. Just remember, things move fast in .NET land. Aspire especially gets updates all the time, so there might be slight differences from when the book was written.
Jimmy Engström has been programming since he was 7 years old and got his first computer. He loves staying on the cutting edge of technology and trying new things. When he first discovered Blazor, he immediately saw its potential and adopted it while it was still in beta. He has been running Blazor in production since Microsoft launched it.
His passion for the .NET industry and community has taken him around the world, speaking about development and sharing knowledge with other developers. Microsoft has recognized this passion by awarding him the Microsoft Most Valuable Professional (MVP) award 12
years in a row.
Jimmy was named Educator of the Year 2025 for his contributions to the developer community. He is also an instructor on Dometrain, where he creates video courses focused on .NET and Blazor development.
In addition to writing books, Jimmy is an international speaker, content creator, and host of the Coding After Work podcast and YouTube channel, where he talks with developers and technology leaders from around the world.
I speak at a lot of conferences about Blazor, so you might catch a live demo somewhere near you. You can also find more Blazor experiments and real-world stuff on my GitHub.
Thanks again for picking up the book, and happy Blazoring.
