{"id":25871145,"url":"https://github.com/onmax/nitro-nimiq-core-wasm","last_synced_at":"2026-05-31T20:31:57.828Z","repository":{"id":277294055,"uuid":"931617780","full_name":"onmax/nitro-nimiq-core-wasm","owner":"onmax","description":"Repro for issue in Nitro","archived":false,"fork":false,"pushed_at":"2025-10-10T05:59:47.000Z","size":456,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-10T10:08:02.324Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/nitrojs/nitro/issues/3089","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/onmax.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2025-02-12T15:24:12.000Z","updated_at":"2025-10-10T05:59:51.000Z","dependencies_parsed_at":"2025-02-14T12:33:00.354Z","dependency_job_id":null,"html_url":"https://github.com/onmax/nitro-nimiq-core-wasm","commit_stats":null,"previous_names":["onmax/nitro-nimiq-core-wasm"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/onmax/nitro-nimiq-core-wasm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onmax%2Fnitro-nimiq-core-wasm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onmax%2Fnitro-nimiq-core-wasm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onmax%2Fnitro-nimiq-core-wasm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onmax%2Fnitro-nimiq-core-wasm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/onmax","download_url":"https://codeload.github.com/onmax/nitro-nimiq-core-wasm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onmax%2Fnitro-nimiq-core-wasm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33748607,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-31T02:00:06.040Z","response_time":95,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-03-02T06:35:33.838Z","updated_at":"2026-05-31T20:31:57.823Z","avatar_url":"https://github.com/onmax.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nimiq Core + Nitro on Cloudflare Workers\n\nThis project demonstrates how to use `@nimiq/core` (Rust WASM package) with Nitro on Cloudflare Workers.\n\n## Quick Start\n\n```bash\npnpm install\npnpm dev\n```\n\nVisit `http://localhost:3000`\n\n## Deploy\n\n```bash\npnpm build\nnpx wrangler deploy\n```\n\n## How It Works\n\nThe key to making `@nimiq/core` work on Cloudflare Workers:\n\n1. **Import WASM as ES module** - Cloudflare Workers provides `WebAssembly.Module`\n2. **Use `initSync()` instead of `init()`** - Avoids blocked `WebAssembly.instantiate(bytes)`\n3. **Mark WASM as external** - Let Cloudflare bundle it properly\n\n### Route (`server/routes/index.ts`)\n\n```typescript\nimport {PublicKey, initSync} from '@nimiq/core/web'\n// @ts-ignore - Import WASM as ES module\nimport wasmModule from '@nimiq/core/web/main-wasm/index_bg.wasm'\n\nlet initialized = false\n\nexport default defineLazyEventHandler(async () =\u003e {\n  if (!initialized) {\n    initSync(wasmModule)\n    initialized = true\n  }\n\n  return eventHandler(async () =\u003e {\n    const publicKey = '82d80b86d9bf1906832e9f0ba4fa69018792f59190075c396b0e85aeac444e55'\n    const key = PublicKey.fromHex(publicKey)\n    return {\n      success: true,\n      result: key.toHex(),\n      note: 'Using initSync with ES module WASM - Cloudflare Workers compatible!'\n    }\n  })\n})\n```\n\n### Configuration\n\n**nitro.config.ts:**\n```typescript\nexport default defineNitroConfig({\n  preset: \"cloudflare-module\",\n  experimental: { wasm: false }, // Disable unwasm\n  rollupConfig: {\n    plugins: [{\n      name: 'nimiq-wasm-external',\n      resolveId(id) {\n        if (id.endsWith('.wasm') || id.includes('.wasm?')) {\n          return { id, external: true }\n        }\n      }\n    }]\n  }\n})\n```\n\n## Why This Works\n\n- Cloudflare Workers **blocks** `WebAssembly.instantiate(bytes)` for security\n- `initSync()` uses `new WebAssembly.Instance(module)` which is allowed\n- ES module imports provide `WebAssembly.Module` instead of raw bytes\n\n## Bundle Size\n\n- **Total**: ~1.2 MB (includes WASM as separate module)\n- **Worker code**: 190 KB\n- **Deployed**: 456 KB gzipped\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonmax%2Fnitro-nimiq-core-wasm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fonmax%2Fnitro-nimiq-core-wasm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonmax%2Fnitro-nimiq-core-wasm/lists"}