Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blazor support #2

Open
franklupo opened this issue Mar 28, 2024 · 3 comments
Open

Blazor support #2

franklupo opened this issue Mar 28, 2024 · 3 comments

Comments

@franklupo
Copy link

how can you use blazor?

Best regards

@Juff-Ma
Copy link
Owner

Juff-Ma commented Mar 28, 2024

You would need to build a standalone static blazor wasm page. You can load this page like any other HTML webside using

window.SetRootFolder("blazor_wasm_folder");
window.Show("index.html");

On the blazor side you would need to include webui.js in the main layout and you can either use the WebUI api using JavaScript/TypeScript or build a C# wrapper using JsImport.

@franklupo
Copy link
Author

could you create an example?

Thank you

@Juff-Ma
Copy link
Owner

Juff-Ma commented Mar 29, 2024

Creating an example would propably not be very helpful as i ddn't find a way to get WebUI to always build the blazor wwwroot and copy it to it's own output. However here are some more detailed steps:

  • Create a blazor wasm project and add <script src="/webui.js"></script> to the index.html located in the wwwroot folder.
  • Now to the tricky part: Blazor wasm only builds its full static output on publish builds, so if you're ready you can publish your blazor project and copy the contents of the wwwroot folder to the WebUI project.
  • On the WebUI side the easiest example to follow would propably be the text editor, you can just delete the ui folder and replace it with wwwroot. and change the .csproj and Program.cs accordingly. Also if you're building this as a finished app you can remove the local nuge includes and just replace them with normal ones.
  • You can use the WebUI api like you would normally. In the blazor side just use javascript invokes or JsImport to call your backend methods. js invokes would propably be easier as you will need to work with promises when calling backend functions. to learn more i recommend taking a look at the webui documentation

I will keep this issue open until i find a way to build a blazor project in such a way it will automatically be copied to the WebUI project. because while you could build a script i don't think thats an optimal solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants