{"id":13564443,"url":"https://github.com/richardanaya/wasm-service","last_synced_at":"2025-04-04T08:06:51.400Z","repository":{"id":61566092,"uuid":"552569233","full_name":"richardanaya/wasm-service","owner":"richardanaya","description":"HTMX, WebAssembly, Rust, ServiceWorkers","archived":false,"fork":false,"pushed_at":"2024-02-18T02:51:17.000Z","size":1628,"stargazers_count":708,"open_issues_count":2,"forks_count":30,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-03-28T07:05:17.671Z","etag":null,"topics":["htmx","rust","webassembly"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/richardanaya.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-16T21:52:04.000Z","updated_at":"2025-03-23T09:30:14.000Z","dependencies_parsed_at":"2024-02-18T03:28:45.698Z","dependency_job_id":"c56cd420-8e2e-4d20-8c59-bc03384bdd36","html_url":"https://github.com/richardanaya/wasm-service","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardanaya%2Fwasm-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardanaya%2Fwasm-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardanaya%2Fwasm-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardanaya%2Fwasm-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/richardanaya","download_url":"https://codeload.github.com/richardanaya/wasm-service/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247142032,"owners_count":20890651,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["htmx","rust","webassembly"],"created_at":"2024-08-01T13:01:31.454Z","updated_at":"2025-04-04T08:06:51.375Z","avatar_url":"https://github.com/richardanaya.png","language":"Rust","funding_links":[],"categories":["Rust","webassembly"],"sub_categories":[],"readme":"# wasm-service\n\nThis is a simple proof of concept that shows how you could use HTMX and Rust for frontend development. The basic idea in HTMX is that a webserver is being called on interactions with DOM elements, and returning back snippets of HTML that will replace certain DOM elements. Instead of http requests going to a regular web server, this project shows how service workers can intercept calls to a server and return back responses driven from WebAssembly instead.\n\nSee the demo here: https://richardanaya.github.io/wasm-service/\n\nYou can also find a framework inspired by this PoC here: https://github.com/edezhic/prest\n\n# Developing `wasm-service`\n\n## Install \u0026 build\n\nInstall the WASM target via `rustup` in order to compile to wasm binaries:\n\n```sh\nrustup target add wasm32-unknown-unknown\n```\n\nCompile the lib crate into `wasm_service.wasm`:\n\n```sh\ncargo build --target wasm32-unknown-unknown --release\n```\n\nCopy the `.wasm` file to `app.wasm` in current dir:\n\n```sh\ncp target/wasm32-unknown-unknown/release/wasm_service.wasm app.wasm\n```\n\n## Serve repo root dir on localhost http\n\nUse any method to serve the files from the root dir (in particular `index.js`, `sw.js`, and `app.wasm`). Note you need to serve on localhost or via https for service workers to be enabled. Here's how you can do it with [`caddy`](https://caddyserver.com/) in bash:\n\n```\ncaddy run --adapter caddyfile --config - \u003c\u003c\u003c $'http://127.0.0.1:8000 \\n log \\n root / . \\n file_server browse'\n```\n\n## Rebuild and run automatically with `cargo watch`\n\nInstall:\n\n```sh\ncargo install cargo-watch\n```\n\nBuild and copy on change:\n\n```sh\ncargo watch -i app.wasm -x 'build --target wasm32-unknown-unknown --release' -s 'cp target/wasm32-unknown-unknown/release/wasm_service.wasm app.wasm'\n```\n\n## Resources for developing with service workers\n\n* [Service Worker API @ MDN](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API)\n* [Workers overview @ web.dev](https://web.dev/workers-overview/)\n* `about:debugging` in firefox\n* Open serviceworker console `about:devtools-toolbox?id=\u003cservice-worker-id\u003e\u0026type=worker`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frichardanaya%2Fwasm-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frichardanaya%2Fwasm-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frichardanaya%2Fwasm-service/lists"}