https://github.com/leptos-rs/start-wasi
A starter template for a WASI SSR server with Leptos
https://github.com/leptos-rs/start-wasi
Last synced: 8 months ago
JSON representation
A starter template for a WASI SSR server with Leptos
- Host: GitHub
- URL: https://github.com/leptos-rs/start-wasi
- Owner: leptos-rs
- License: unlicense
- Created: 2024-11-15T18:21:44.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-17T18:35:53.000Z (about 1 year ago)
- Last Synced: 2025-03-29T19:22:37.284Z (9 months ago)
- Language: Rust
- Size: 12.7 KB
- Stars: 2
- Watchers: 1
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# Leptos WASI Starter Template
This is a template for use with the [Leptos](https://github.com/leptos-rs/leptos) web
framework and the [cargo-leptos](https://github.com/akesson/cargo-leptos) tool
using [leptos_wasi](https://github.com/leptos-rs/leptos_wasi).
## Prerequisites
```bash
cargo install cargo-leptos --locked
cargo install cargo-generate
```
## Init a new project
```bash
cargo leptos new --git https://github.com/leptos-rs/start-wasi
```
### How to serve static files?
You **MUST** write the `serve_static_files` function in
[`src/server.rs`](src/server.rs).
We make no assumptions about which world is available for your component.
It is not guaranteed that you will give filesystem access to your component.
That's why you need to explicitly write the logic to serve static files.
If you do want to use `wasi:filesystem`, then you can check the link
in the comments of the said function. In the future, we may add default
implementation in `leptos_wasi` to ease your life.
## Compiling your project
### For release
```bash
cargo leptos build --release
```
### For development
```bash
cargo leptos build
```
### How to run the component?
Well, by nature, WebAssembly give you the freedom to chose the runtime you want.
For now, we have only tested running the commponents with [Wasmtime](https://wasmtime.dev):
```
wasmtime serve {{component_outdir}}/wasm32-wasip2/debug/{{crate_name}}.wasm -Scli
```
Be sure to add the flags you need to provide the worlds your component depends on:
* `--dir target/site/pkg` if you want, for example, to use `wasi:filesystem` to serve
the static assets,
* `--env` if you want to pass environment variables,
## Licensing
This template itself is released under the Unlicense. You should replace the LICENSE for your own application with an appropriate license if you plan to release it publicly.