Blazor 1
Blazor 1
scottsauber
Agenda
• What is WebAssembly?
• What is Blazor?
• How does Blazor work?
• Demos
• Questions
scottsauber
Purpose
• Differentiate what is Blazor vs WebAssembly
• Get excited for the future
scottsauber
Who am I?
• Software Consultant at Lean TECHniques
• Primarily .NET/JS Developer
• React fanboy
• Enjoys writing JavaScript
• Blog primarily on ASP.NET Core on scottsauber.com
• Author of Blazor Snippets for VS Code
scottsauber
Current State of the SPA Front End
Pick a Language:
Pick a Framework:
Common
Source: Cory House’s Building a JavaScript Development Environment Pluralsight course
At the end of the day….
Problems
• Whole host of people don’t like JS
• Dynamically typed
• Less integration, more stitching
• Browser support
• Moves too fast, lots of choice, intimidating
• node_modules
• SPA’s are more expensive to maintain
• Front-end + Back-end team
• Training up full stack to be great at both (very difficult)
• When using a different language than JS on the backend…
• Duplicate Business Logic (like validation) or just have server
• No IDE/compiler help between backend models + front end making AJAX calls
• Unless bringing in yet another tool (GraphQL, TypeScript/C# syncer, etc.)
What is Web Assembly (WASM)?
• WebAssembly (WASM) is a low-level binary format language that can
be run in modern web browsers that runs at near-native speeds.
• Compilation Target for other languages
• Browser standard
• No more JS monopoly
Is WASM Ready?
scottsauber
Rapid Fire Questions
• How big is it?
• 2.4MB
• Very little work done thus far to optimize
• Do WASM files cache like JS and CSS files?
• Yes
• How does it work under the hood?
How does Blazor work?
Today Future
Source
Why Mono? Why not .NET Core?
• Already Client-side-focused
• Xamarin, Unity, etc.
• .NET Core is Server-side-focused
• Already developed for unique platforms (iOS, watchOS, PS4, etc.)
• Already had linker (DLL trimmer/tree shaker) for Xamarin
• They got it working first
• Long term it will run on .NET 5
• .NET 5 unified framework for Core, Mono, Full Framework. Single runtime to
target for Mobile, Web, Desktop.
scottsauber
Demo #2
• LocalStorage C# Wrapper
• Code: https://github.com/scottsauber/BlazorToDoMVC
scottsauber
What else can we do?
• Blazor’s component model is de-coupled from the Browser
• …so…
What else can we do?
• Blazor on Electron
• Cross-platform desktop framework. Write once, run anywhere.
• Proof of Concept Running on .NET Core
• Why?
• Faster Code Execution
• Full Debugger in VS
• .NET Core instead of Mono
• Access to Desktop API’s
Demo #3
• Blazor on Electron
• Electron.App
• Code:
https://github.com/SteveSandersonMS/BlazorElectronExperiment.Sa
mple
scottsauber
What else can we do?
• Blazor on the Server
• Feels client-side
• Changes streamed via WebSocket
• Why?
• Small bundle (~400KB)
• Code runs on .NET Core server, no constraints
• Full Debugger in VS
• Why not?
• More load on server
• Does not support disconnects
Demo #4
• Blazor on the Server
scottsauber
Blazor 3rd party Components
• Telerik
• Syncfusion
• DevExpress
Current Status - What’s there?
• Component Model
• Routing
• Layouts
• Dependency Injection
• JS interop
• Share Components between projects
• Debugging in Chrome – Shift + ALT + D
• Forms and Validation
• VS and some VS Code support
• Blazor Server-Side
• Server Side Rendering
Current Status - What’s coming?
• Better tooling
• Hot reloading
• AOT
• Smaller bundle size
• AuthN + AuthZ work
• Debugging in VS
Source: Cory House’s Building a JavaScript Development Environment Pluralsight course
The remainder of these you’ve likely
already decided on the backend!
Pick a Framework:
Common
Future State of the Front End? (besides JS)
Pick a Language:
Slides at scottsauber.com
Resources
• https://blazor.net
• Microsoft Documentation
• https://learn-blazor.net
• Community-led Documentation
• https://github.com/aspnet/blazor
• Blazor Source Code
• https://github.com/mbasso/awesome-wasm and
https://github.com/appcypher/awesome-wasm-langs
• Lists of what other languages are doing with WASM