A template for using Leptos ssr + server functions in a Cloudflare worker.
Install Rust from rustup.rs. Then:
cargo install cargo-leptos --locked
You'll need a custom build of worker-build
that adds the static asset manifest to the list of external modules.
One such forks is here.
This will only be necessary until they add it to the official workers-rs
repo.
git clone https://github.com/BrandonDyer64/workers-rs.git
cd workers-rs
git checkout external-static-assets
cargo install --path worker-build
You'll need some version of Node.js. I personally recommend using nvm. Then:
npm install --global wrangler
wrangler dev
wrangler deploy
Q: I'm getting an error like this in my console:
- Unhandled Promise Rejection: LinkError: import function wbg:__wbindgen_closure_wrapper268 must be callable
A: You need to hard refresh in your browser between compiles
- Firefox/Chrome:
Ctrl-Shift-R
or⌘ R
- Safari:
⌥ ⌘ E
+⌘ R