Fireship · @fireship

Blazor in 100 Seconds

Uploaded September 1, 2022 · Length 2:33

Blazor in 100 Seconds

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.

  1. 0:00

    blazer a ui framework for building

  2. 0:02

    front-end web applications with html css

  3. 0:06

    and not javascript but c-sharp by

  4. 0:08

    leveraging the power of webassembly it's

  5. 0:10

    able to eliminate javascript from your

  6. 0:12

    front-end stack it was created at

  7. 0:13

    microsoft in 2018 by steve sanderson the

  8. 0:16

    developer famous for creating knockout

  9. 0:18

    js years earlier just like react and

  10. 0:20

    other modern ui libraries you build

  11. 0:22

    components called razer components that

  12. 0:24

    encapsulate parts of the user interface

  13. 0:26

    what makes blazer special is its ability

  14. 0:29

    to blur the lines between client and

  15. 0:31

    server thanks to wasm you can run c

  16. 0:33

    sharp code with your favorite.net

  17. 0:34

    libraries in the browser or

  18. 0:36

    alternatively run your client side code

  19. 0:38

    on the server and stream changes back

  20. 0:40

    into the dom via signal ir a tool built

  21. 0:43

    on top of websockets for real-time

  22. 0:45

    communication in addition blazer

  23. 0:47

    components are capable of running on any

  24. 0:49

    platform with dotnet maui you can reuse

  25. 0:51

    your code natively on ios android or

  26. 0:54

    desktop now if you're not convinced

  27. 0:55

    c-sharp can get the job done by itself

  28. 0:57

    it can easily interop with javascript on

  29. 0:59

    both the client and server to get

  30. 1:01

    started install visual studio with

  31. 1:03

    asp.net capabilities then generate a new

  32. 1:05

    blazer webassembly project the root of

  33. 1:08

    your application contains a router in

  34. 1:09

    the app.razer file notice how it's

  35. 1:12

    structured with a variety of built-in

  36. 1:13

    components like router and layout view

  37. 1:16

    that don't need to be explicitly

  38. 1:17

    imported like a javascript app now

  39. 1:19

    create a new page by adding a razer

  40. 1:21

    component to the pages directory at the

  41. 1:23

    top of that file add the page directive

  42. 1:25

    to specify the url pattern we can then

  43. 1:27

    add a title using a built-in razer

  44. 1:29

    component or simply add some plain html

  45. 1:32

    here but now it's time to add some

  46. 1:33

    reactive state to this application which

  47. 1:36

    can be accomplished with the code

  48. 1:37

    directive which allows us to write logic

  49. 1:39

    with the industrial strength reliability

  50. 1:41

    of c sharp define a property like count

  51. 1:43

    then use it in a template with the at

  52. 1:45

    symbol the value is reactive so any time

  53. 1:48

    it changes the template will re-render

  54. 1:50

    we can add a method to the code to

  55. 1:51

    increment the count then bind it to a

  56. 1:53

    button as the on click event handler now

  57. 1:55

    to make the component look pretty add a

  58. 1:57

    matching css file and all the styles

  59. 1:59

    here will be scoped to that component