<a href="https://www.packtpub.com/en-us/unlock"><img src="https://drive.google.com/uc?export=view&id=1lQCTQQ8iV5pGuPA1n5wuds-3pwJi0OD_"></a>
<h1 align="center">
Web Development with Blazor, Fourth Edition</h1>
<p align="center">Thanks for stopping by. This is the code repository for <a href ="https://www.packtpub.com/en-us/product/web-development-with-blazor-fourth-edition/9781806112890"> Web Development with Blazor, Fourth Edition</a>, published by Packt.
</p>

<h2 align="center">
A practical guide to building interactive UIs with C# 14 and .NET 10
</h2>
<p align="center">
Jimmy Engström</p>

<p align="center">
   <a href="https://discord.gg/8VuShAAtK" alt="Discord" title="Learn more on the Discord server"><img width="32px" src="https://cliply.co/wp-content/uploads/2021/08/372108630_DISCORD_LOGO_400.gif"/></a>
  &#8287;&#8287;&#8287;&#8287;&#8287;
  <a href="https://packt.link/free-ebook/9781806112890"><img width="32px" alt="Free PDF" title="Free PDF" src="https://cdn-icons-png.flaticon.com/512/4726/4726010.png"/></a>
 &#8287;&#8287;&#8287;&#8287;&#8287;
  <a href="https://packt.link/gbp/9781806112890"><img width="32px" alt="Graphic Bundle" title="Graphic Bundle" src="https://cdn-icons-png.flaticon.com/512/2659/2659360.png"/></a>
  &#8287;&#8287;&#8287;&#8287;&#8287;
   <a href="https://www.amazon.com/Web-Development-Blazor-practical-interactive/dp/1806112892"><img width="32px" alt="Amazon" title="Get your copy" src="https://cdn-icons-png.flaticon.com/512/15466/15466027.png"/></a>
  &#8287;&#8287;&#8287;&#8287;&#8287;
</p>

<details open> 
  <summary><h2>About the book</summary>
<a href="https://www.packtpub.com/en-us/product/web-development-with-blazor-fourth-edition/9781806112890">
<img src="https://content.packt.com/B34552/cover_image_small.jpg" alt="Web Development with Blazor, Fourth Edition" height="256px" align="right">
</a>

Blazor has grown, and with that growth comes a simple question: How should we build Blazor apps today?</br>
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.</br>
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.</br>
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.</br>
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.</br>
Own a raccoon cover already? The collection must continue. The raccoons insist.</details>


<details open> 
  <summary><h2>Key learnings</summary>
<ul>

<li>Understand how Blazor works and when to use each render mode</li>

<li>Build simple and advanced Blazor components with confidence</li>

<li>Structure applications to separate concerns and support multiple hosting models</li>

<li>Implement authentication and authorization using modern .NET patterns</li>

<li>Improve performance with caching and rendering optimizations</li>

<li>Use OpenTelemetry to gain insights into application behavior and performance</li>

<li>Build, run, and manage applications using Aspire</li>

</ul>

  </details>

<details open> 
  <summary><h2>Chapters</summary>
     <img src="https://cliply.co/wp-content/uploads/2020/02/372002150_DOCUMENTS_400px.gif" alt="Unity Cookbook, Fifth Edition" height="556px" align="right">
<ol>

  <li>Hello Blazor</li>

  <li>Creating Your First Blazor App</li>

  <li>Exploring Render Modes</li>

  <li>Uncovering Aspire</li>

  <li>Managing State – Part 1</li>

  <li>Understanding Basic Blazor Components</li>

  <li>Creating Advanced Blazor Components</li>

  <li>Building Forms with Validation</li>

  <li>Creating an API</li>

  <li>Adding Authentication and Authorization</li>

  <li>Sharing Code and Resources</li>

  <li>JavaScript Interop</li>

  <li>Managing State – Part 2</li>

  <li>Debugging the Code</li>

  <li>Exploring Tracing and Metrics</li>

  <li>Testing</li>

  <li>Deploy to Production</li>

  <li>Moving From, or Combining, an Existing Site</li>

  <li>Going Deeper into WebAssembly</li>

  <li>Examining Source Generators</li>

  <li>Visiting .NET MAUI</li>

  <li>Where to Go from Here</li>

</ol>

</details>

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.

---

<details open> 
  <summary><h2>Requirements for this book</summary>
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.</br></br>
     
<table>
   <tr><td><b>Software covered in this book</b></td><td><b>OS requirements</b></td></tr>
   <tr><td>Visual Studio 2026, .NET 10</td><td>Windows 10 or later, macOS, Linux</td></tr>
</table>
     

<h3>Getting Started</h3>

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`.
  </details>

---  

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

---

<details> 
  <summary><h2>Get to know the author</h2></summary>

_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.</br>
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.</br>
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.</br>
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.

---

</details>
<details> 
  <summary><h2>Other related books</h2></summary>
<ul>

  <li><a href="https://www.packtpub.com/en-us/product/blazor-webassembly-by-example-third-edition/9781807428679">Blazor WebAssembly by Example, Third Edition</a></li>

  <li><a href="https://www.packtpub.com/en-us/product/apps-and-services-with-net-10-third-edition/9781835462201">Apps and Services with .NET 10, Third Edition</a></li>
 
</ul>

</details>

---

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