Fireship · @fireship
Blazor in 100 Seconds
Uploaded September 1, 2022 · Length 2:33
Summary
blazor ui framework for building web applications with c# and html css
- blazor
- csharp web development
- webassembly
- dotnet maui
- razor components
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
blazer a ui framework for building
- 0:02
front-end web applications with html css
- 0:06
and not javascript but c-sharp by
- 0:08
leveraging the power of webassembly it's
- 0:10
able to eliminate javascript from your
- 0:12
front-end stack it was created at
- 0:13
microsoft in 2018 by steve sanderson the
- 0:16
developer famous for creating knockout
- 0:18
js years earlier just like react and
- 0:20
other modern ui libraries you build
- 0:22
components called razer components that
- 0:24
encapsulate parts of the user interface
- 0:26
what makes blazer special is its ability
- 0:29
to blur the lines between client and
- 0:31
server thanks to wasm you can run c
- 0:33
sharp code with your favorite.net
- 0:34
libraries in the browser or
- 0:36
alternatively run your client side code
- 0:38
on the server and stream changes back
- 0:40
into the dom via signal ir a tool built
- 0:43
on top of websockets for real-time
- 0:45
communication in addition blazer
- 0:47
components are capable of running on any
- 0:49
platform with dotnet maui you can reuse
- 0:51
your code natively on ios android or
- 0:54
desktop now if you're not convinced
- 0:55
c-sharp can get the job done by itself
- 0:57
it can easily interop with javascript on
- 0:59
both the client and server to get
- 1:01
started install visual studio with
- 1:03
asp.net capabilities then generate a new
- 1:05
blazer webassembly project the root of
- 1:08
your application contains a router in
- 1:09
the app.razer file notice how it's
- 1:12
structured with a variety of built-in
- 1:13
components like router and layout view
- 1:16
that don't need to be explicitly
- 1:17
imported like a javascript app now
- 1:19
create a new page by adding a razer
- 1:21
component to the pages directory at the
- 1:23
top of that file add the page directive
- 1:25
to specify the url pattern we can then
- 1:27
add a title using a built-in razer
- 1:29
component or simply add some plain html
- 1:32
here but now it's time to add some
- 1:33
reactive state to this application which
- 1:36
can be accomplished with the code
- 1:37
directive which allows us to write logic
- 1:39
with the industrial strength reliability
- 1:41
of c sharp define a property like count
- 1:43
then use it in a template with the at
- 1:45
symbol the value is reactive so any time
- 1:48
it changes the template will re-render
- 1:50
we can add a method to the code to
- 1:51
increment the count then bind it to a
- 1:53
button as the on click event handler now
- 1:55
to make the component look pretty add a
- 1:57
matching css file and all the styles
- 1:59
here will be scoped to that component


