---
title: Build a Blazor todo list app
author: guardrex
description: Build a Blazor app step-by-step.
monikerRange: '>= aspnetcore-3.0'
ms.author: riande
ms.custom: mvc
ms.date: 08/22/2020
no-loc: ["ASP.NET Core Identity", cookie, Cookie, Blazor, "Blazor Server", "Blazor WebAssembly", "Identity", "Let's Encrypt", Razor, SignalR]
uid: tutorials/build-a-blazor-app
---
# Build a Blazor todo list app
By [Daniel Roth](https://github.com/danroth27) and [Luke Latham](https://github.com/guardrex)
This tutorial shows you how to build and modify a Blazor app. You learn how to:
> [!div class="checklist"]
> * Create a todo list Blazor app project
> * Modify Razor components
> * Use event handling and data binding in components
> * Use routing in a Blazor app
At the end of this tutorial, you'll have a working todo list app.
## Prerequisites
[!INCLUDE[](~/includes/3.1-SDK.md)]
## Create a todo list Blazor app
1. Create a new Blazor app named `TodoList` in a command shell:
```dotnetcli
dotnet new blazorserver -o TodoList
```
The preceding command creates a folder named `TodoList` to hold the app. The `TodoList` folder is the *root folder* of the project. Change directories to the `TodoList` folder with the following command:
```dotnetcli
cd TodoList
```
1. Add a new `Todo` Razor component to the app in the `Pages` folder using the following command:
```dotnetcli
dotnet new razorcomponent -n Todo -o Pages
```
> [!IMPORTANT]
> Razor component file names require a capitalized first letter. Open the `Pages` folder and confirm that the `Todo` component file name starts with a capital letter `T`. The file name should be `Todo.razor`.
1. In `Pages/Todo.razor` provide the initial markup for the component:
```razor
@page "/todo"
Todo
```
1. Add the `Todo` component to the navigation bar.
The `NavMenu` component (`Shared/NavMenu.razor`) is used in the app's layout. Layouts are components that allow you to avoid duplication of content in the app.
Add a `` element for the `Todo` component by adding the following list item markup below the existing list items in the `Shared/NavMenu.razor` file:
```razor
Todo
```
1. Build and run the app by executing the `dotnet run` command in the command shell from the `TodoList` folder. Visit the new Todo page to confirm that the link to the `Todo` component works.
1. Add a `TodoItem.cs` file to the root of the project (the `TodoList` folder) to hold a class that represents a todo item. Use the following C# code for the `TodoItem` class:
[!code-csharp[](build-a-blazor-app/samples_snapshot/3.x/TodoItem.cs)]
1. Return to the `Todo` component (`Pages/Todo.razor`):
* Add a field for the todo items in an `@code` block. The `Todo` component uses this field to maintain the state of the todo list.
* Add unordered list markup and a `foreach` loop to render each todo item as a list item (`
`).
[!code-razor[](build-a-blazor-app/samples_snapshot/3.x/ToDo4.razor?highlight=5-10,12-14)]
1. The app requires UI elements for adding todo items to the list. Add a text input (``) and a button (`