Skip to content

michielpost/Dfinity.Blazor

Repository files navigation

Dfinity.Blazor

Blazor library to work with Dfinity Internet Computer. Use this library to easily integrate login with Internet Identity in your Blazor WebAssembly app. This library can also be used to communicate with Internet Computer canisters.

Deployed to https://syisf-7qaaa-aaaah-aauda-cai.ic0.app/

Available on NuGet: https://www.nuget.org/packages/Dfinity.Blazor/

Features

  • Login with Internet Identity
  • Get Current Internet Identity
  • Store and Get key/value pairs
  • Store and Get key/value pairs for a logged in user

Demo

  1. Publish the sample app:
dotnet publish src/Dfinity.Blazor.SampleApp -c Release
  1. Start a local internet computer.

    dfx start
    
  2. Open a new terminal window.

  3. Reserve an identifier for your canister.

    dfx canister create --all
    
  4. Install frontend dependencies

    npm install
    
  5. Build the canisters

    dfx build
    
  6. Deploy the canisters

    dfx canister install --all
    
  7. Take note of the URL at which the canister is accessible.

    echo "http://localhost:8000/?canisterId=$(dfx canister id www)"
    
  8. Open the URL in your web browser.

How to use this in your own app

Example implementation can be found at https://github.com/michielpost/SkyDocs/tree/feature/dfinity

Steps:

  • Install this library from NuGet Dfinity.Blazor
  • Create a folder for your storage canister and add Main.mo
  • Add your storage canister to dfx.json
 "storage": {
      "main": "src/storage/main.mo",
      "type": "motoko"
    },
  • Add index.js and index.html to your www/asset canister
  • Add package.json to the root of your project
  • Follow the steps to run the demo to build your own project
  • Make sure the compiled/minified index.js end up in the wwwroot of your Blazor app.
  • Include the js file in your html:
 <script defer src="index.js"></script>

Inspiration

About

Blazor library to work with Dfinity Internet Computer

Resources

License

Stars

Watchers

Forks

Packages

No packages published