https://github.com/delneg/fullstackwasmfsharpapp
Fullstack WASM Application written in F#, using WASI to compile backend to be run using wasmer / wastime
https://github.com/delneg/fullstackwasmfsharpapp
blazor dotnet fsharp wasi wasi-sdk wasm wasmer wasmtime
Last synced: about 1 month ago
JSON representation
Fullstack WASM Application written in F#, using WASI to compile backend to be run using wasmer / wastime
- Host: GitHub
- URL: https://github.com/delneg/fullstackwasmfsharpapp
- Owner: delneg
- License: mit
- Created: 2022-05-23T09:17:08.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-05-24T21:08:32.000Z (almost 3 years ago)
- Last Synced: 2025-03-18T18:44:48.988Z (about 1 month ago)
- Topics: blazor, dotnet, fsharp, wasi, wasi-sdk, wasm, wasmer, wasmtime
- Language: F#
- Homepage:
- Size: 108 KB
- Stars: 18
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Example F# WASI App
This is an example app to demonstrate the use of F# in WASI using the new https://github.com/SteveSandersonMS/dotnet-wasi-sdk
Here's the introductory video from CNCF Europe WASM Conference [Bringing WebAssembly to the .NET Mainstream - Steve Sanderson, Microsoft](https://www.youtube.com/watch?v=PIeYw7kJUIg)
Shoutout to https://www.strathweb.com/2022/03/running-net-7-apps-on-wasi-on-arm64-mac/
written by http://twitter.com/filip_woj for tips on running it on macOSUpd: The issue is fixed in Wasi.Sdk > 0.1.1, https://github.com/dotnet/aspnetcore/pull/41123#issuecomment-1135884829
## Preview

## Running Backend
Ensure you have at least .NET 7.0 preview 3 - you can download it here https://dotnet.microsoft.com/en-us/download/dotnet/7.0
Also, please install `wasmtime` - https://wasmtime.dev/
Command to install it from their website is `curl https://wasmtime.dev/install.sh -sSf | bash` - be sure to check the script first (always check what you `sh` from the internet)
Then:
```bash
cd TodoBackend
dotnet build
wasmtime bin/Debug/net7.0/FullstackWasmFSharpAppBackend.wasm --tcplisten localhost:8080 --env ASPNETCORE_URLS=http://localhost:8080
> info: Microsoft.Hosting.Lifetime
> Now listening on: http://localhost:8080
```## Running frontend
Please note, that currently the backend has hard-coded address of "localhost:5000" for CORS to work.
Also, the frontend has hard-coded address of the backend to "http://localhost:8080" for simplicity.
That said, you should be able to run interactive (with .NET Interpreter in WASM) frontend using:
```bash
cd TodoFrontend
dotnet run
```You can build the portable (i.e. AOT and optimized) version of the frontend which can be deployed as static website with:
```bash
cd TodoFrontend
dotnet publish -o $(pwd)/publish/ -r Portable
```After that, you can serve it like any other SPA - for example, locally using [Serve](https://github.com/vercel/serve)
```bash
serve publish/wwwroot/ -p 5000
```#### License
MIT