Join our book community on Discord
https://packt.link/EarlyAccess
The Blazor WebAssembly framework makes it possible for us to run C# code on the browser. However, there are some scenarios that C# simply cannot handle, and for those scenarios, we need to use JavaScript functions.
In this chapter, we will learn how to use JavaScript with Blazor WebAssembly. We will learn how to invoke a JavaScript function from a .NET method with and without a return value. Conversely, we will learn how to invoke a .NET method from a JavaScript function. We will accomplish both scenarios by using JavaScript interop (JS interop). Finally, we will learn how to store data on the browser by using localStorage.
The project that we will create in this chapter will be a local storage service that will read and write to the application’s Local Storage. To access the application’s Local Storage, we will use JavaScript. We will also create a test component to test the local storage service. The...