Skip to content

PacktPublishing/Web-Development-with-Blazor-4E

Repository files navigation

Web Development with Blazor, Fourth Edition

Thanks for stopping by. This is the code repository for Web Development with Blazor, Fourth Edition, published by Packt.

A practical guide to building interactive UIs with C# 14 and .NET 10

Jimmy Engström

      Free PDF       Graphic Bundle       Amazon      

About the book

Web Development with Blazor, Fourth Edition

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.

Key learnings

  • 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

Chapters

Unity Cookbook, Fifth Edition
  1. Hello Blazor
  2. Creating Your First Blazor App
  3. Exploring Render Modes
  4. Uncovering Aspire
  5. Managing State – Part 1
  6. Understanding Basic Blazor Components
  7. Creating Advanced Blazor Components
  8. Building Forms with Validation
  9. Creating an API
  10. Adding Authentication and Authorization
  11. Sharing Code and Resources
  12. JavaScript Interop
  13. Managing State – Part 2
  14. Debugging the Code
  15. Exploring Tracing and Metrics
  16. Testing
  17. Deploy to Production
  18. Moving From, or Combining, an Existing Site
  19. Going Deeper into WebAssembly
  20. Examining Source Generators
  21. Visiting .NET MAUI
  22. 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.


Requirements for this book

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 bookOS requirements
Visual Studio 2026, .NET 10Windows 10 or later, macOS, Linux

Getting Started

To get rolling:

  1. Clone this repo git clone https://github.com/PacktPublishing/Web-Development-with-Blazor-4E.git

  2. Pick the chapter you want to run Example: cd Chapter05

  3. Open the solution file in Visual Studio (or VS Code, if you prefer)

  4. 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.


Chapter folders in repo

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 app
  • Chapter03: Render modes in .NET 8 and beyond
  • Chapter04: Working with .NET Aspire
  • Chapter05: Data access and repositories
  • Chapter06: Blazor components
  • Chapter08: Forms and validation
  • Chapter09: Creating APIs
  • Chapter10: Auth with Auth0
  • Chapter12: Managing state
  • Chapter16: Testing with bUnit
  • Chapter18: Mixing Blazor with other frameworks (if you really have to)

And more.


Got questions?

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.


Get to know the author

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.


Other related books


Stay in touch

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors