nukedbit / blazor-wasm-servicestack

This template integrate ServiceStack with Blazor on .NET 6 and ServiceStack. The blazor wasm app is served through the main ServiceStack web host so you can deploy a single package with both api and client ux.

Home Page:https://nukedbit.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This template is now unmantained, ServiceStack as released a new Officially supported template with a better native integration check it out ServiceStack v6 Release Notes

Blazor WASM & ServiceStack for .NET 6.0 RTM

This template integrate ServiceStack with Blazor on .NET 6 RTM and ServiceStack 5.13.

The blazor wasm app is served through the main ServiceStack web host so you can deploy a single package with both api and client ux.

Quick Start

Use the x tool to install this template

$ dotnet tool install -g x

$ x new nukedbit/blazor-wasm-servicestack ProjectName

This template come with sqlite db preconfigured so it work out of the box.

The blazor example provide a login page with the following default credentials.

admin@localhost.local
p@55wOrd

Once logged in you can test calling protected endpoints on call hello page.

ServiceStack auth is integrated with blazor on ServiceStackStateProvider and I have provided a StackBaseComponent to use as a base component in your project, so it provide the JsonHttpClient with the bearer token once authenticated.

Inside the client project you can see this.

        builder.Services.AddScoped<JsonHttpClient>(s =>
        {
            return BlazorClient.Create("https://localhost:5001");
        });

Maybe i will make this automatically get the base url in the future, any contribution is appreciated :).

Code Sharing

Right now I have got dto sharing by using MyApp.ServiceModel project with success as suggested on Physical Project Structure

Running your app

There are two launch profiles for VSCode, the firt one it will launch the app with blazor debugging, the other one it will launch only the WebHost Debugging.

  1. Launch and Debug Blazor WebAssembly
  2. .NET Core Launch (web)

If you don't know ServiceStack give it a try it come with a AGPL 3 license, but you can get a commercial license for cheap and it will make your day more productive and enjoyable :)

Check the following links for more info

Executing Blazor and ServiceStack as a Standalone Desktop app

@mythz Published an update to the app dotnet tool that allow you to embedd this in a Windows Chromium Desktop App very easily with the latest v0.0.81+ app tool.

$ dotnet tool update -g app
$ x new nukedbit/blazor-wasm-servicestack Acme
$ cd Acme\Acme
$ dotnet public -c Release
$ cd bin\Release\net6.0\publish
$ app Acme.dll

When it will launch this is the end result.

As he suggested here

You can also create a Windows Desktop Shortcut.

$ app shortcut Acme.dll

References

About

This template integrate ServiceStack with Blazor on .NET 6 and ServiceStack. The blazor wasm app is served through the main ServiceStack web host so you can deploy a single package with both api and client ux.

https://nukedbit.dev

License:MIT License


Languages

Language:C# 57.3%Language:HTML 33.0%Language:CSS 9.7%