What this book covers
Chapter 1, Understanding the Anatomy of a Blazor WebAssembly Project, introduces Blazor WebAssembly, guides you to set up a project and understand its structure, and covers essential topics such as environments and dependency injection.
Chapter 2, Components in Blazor, explains the concept of components in Blazor WebAssembly and SPAs, covering how to build, communicate, and style them.
Chapter 3, Developing Advanced Components in Blazor, introduces advanced component types such as layouts, templated components, and dynamic components, showing you how to use Razor class library projects to build reusable components.
Chapter 4, Navigation and Routing, explains the navigation process in a SPA and how to implement it in your Blazor apps. The chapter also covers how to use query parameters, send and receive data via a URL, and respond to navigation changes.
Chapter 5, Capturing User Input with Forms and Validations, explains how to create and submit forms in Blazor, use the built-in input components, validate user input, and create your own custom input component.
Chapter 6, Consuming JavaScript in Blazor, explains how and when to use JS in your Blazor WebAssembly project and how to call JS code from your Blazor app, and vice versa. It also shows how to wrap an existing JS package into a Blazor component using JS.
Chapter 7, Managing Application State, introduces the concept of state management in an SPA and shows three different techniques for preserving the state of your application – using local storage, in memory, or a URL.
Chapter 8, Consuming Web APIs from Blazor WebAssembly, provides an overview of web APIs and web API clients, showing you how to understand an existing web API and send HTTP requests to it from Blazor. It also covers delegating handlers, IHttpClientFactory
, and how to organize API calls in your app.
Chapter 9, Authenticating and Authorizing Users in Blazor, explains what authentication and authorization are, and then deep-dives into how Blazor handles authentication and how to develop your custom authentication flow with JSON Web Tokens. It also shows you how to control the UI and the app logic based on the authentication state and call secured web API endpoints.
Chapter 10, Handling Errors in Blazor WebAssembly, shows you how to make your app reliable and the techniques to handle errors efficiently in your apps.
Chapter 11, Giving Your App a Speed Boost, provides you with advanced mechanisms in Blazor that help you make your app as efficient as possible, by increasing the rendering speed and reducing the app size for faster load time.
Chapter 12, RenderTree in Blazor, explains in detail how Blazor renders components and manages the Document Object Model (DOM), introducing the concept of RenderTree
. It also shows how you can improve your app performance by learning how things work under the hood.
Chapter 13, Testing Blazor WebAssembly Apps, introduces the concept of component testing and the bUnit library, providing you with what you need to write efficient unit tests for your components. The chapter also covers End-to-End (E2E) testing and the Playwright package.
Chapter 14, Publishing Blazor WebAssembly Apps, shows the checks to do before publishing an app, introduces the Blazor WebAssembly ASP.NET Core Hosted app model, and guides you step by step to release your apps to Azure App Service and Azure Static Web Apps.
Chapter 15, What’s Next?, provides an overview of more components and use cases to help you apply what you learned in this book.