Deploying Blazor WebAssembly

Deploying Blazor WebAssembly is the process of compiling (building) your code and hosting the HTML file on a web server.

This guide builds on the previous steps in the Getting Started tutorial and shows you how to deploy your website.


Prerequisites

Best practice is to host your website locally before you deploy it into production. To host your website locally, you will need to install one of the web servers on your computer. Some examples of web servers are: NGINX, Apache, IIS.


Publish your website

  1. Prepare the website. You can follow the Getting Started steps to create your own website or download the Blazor WebAssemby Online Shop it.
  2. Open a cmd in the root folder of the project and use the dotnet publish command.
dotnet publish -c Release -o "YourFolder"

By default, publish command uses the debug build configuration. For production ready, you need to specify the -c Release to specify build by release configuration. The -o "YourFolder" part is to specify the output folder, if you don't specify the output folder, you can see the published files at [project_folder]/bin/[configuration]/[framework]/publish/ folder by default.


Hosting your website

The next step would be hosting your website. There are many web servers that can host Blazor WebAssembly, we are going to demonstrate how to host with NGINX.

  1. Update your nginx.conf file.
http {
    ... 
    server {
        listen       80;
        server_name  localhost;

        location / {
            root   D:/Web/wwwroot;
            index  index.html index.htm;
        }
        ....
    }
}
  1. Open a cmd in the root folder of NGINX then run the command:
nginx
  1. Open localhost and observe the result.


What's next

You have learned the foundation of Blazor WebAssembly and experience the full circle from creating a website to deploying and hosting it. To further explore Blazor WebAssemby, continue to the Understanding Blazor WebAssembly.

BLAZOR SCHOOL
Designed and built with care by our dedicated team, with contributions from a supportive community. We strive to provide the best learning experience for our users.
Docs licensed CC-BY-SA-4.0
Copyright © 2021-2025 Blazor School
An unhandled error has occurred. Reload 🗙