Skip to content

Fix WASM support in Nakama and Satori#171

Open
ilmalte wants to merge 2 commits intoheroiclabs:mainfrom
ilmalte:fix/125-wasm-support
Open

Fix WASM support in Nakama and Satori#171
ilmalte wants to merge 2 commits intoheroiclabs:mainfrom
ilmalte:fix/125-wasm-support

Conversation

@ilmalte
Copy link
Collaborator

@ilmalte ilmalte commented Feb 22, 2026

Add dart.library.js_interop conditional import to resolve the correct
client implementation on WASM. WASM does not expose dart.library.js,
so the stub (which throws UnsupportedError) was incorrectly selected.

dart.library.js is kept as a fallback for Dart SDKs < 3.3 where
dart.library.js_interop is not available.


Note: this is dependent on PR #169 (changes from commit 72a3baf).

Really affected files are in commit 818046a:

  • nakama/lib/nakama.dart
  • nakama/lib/src/nakama_client/stub/nakama_client_stub.dart
  • nakama/example/web/index.html
  • satori/lib/satori.dart
  • satori/lib/src/satori_client/stub/satori_client_stub.dart

Refactor RPC payload handling and remove unused code.

In details:
- Updated the NakamaGrpcClient to directly use the payload without preparation (payload encoding is only needed for REST and not for gRPC).
- Simplified the preparePayload function to always encode the payload as JSON.
- Deleted platform-specific stub files/logic (no longer used).
- Added tests (covers issue heroiclabs#167)
Add `dart.library.js_interop` conditional import to resolve the correct
client implementation on WASM. WASM does not expose `dart.library.js`,
so the stub (which throws UnsupportedError) was incorrectly selected.

`dart.library.js` is kept as a fallback for Dart SDKs < 3.3 where
`dart.library.js_interop` is not available.
@ilmalte ilmalte requested a review from DannyIsYog February 22, 2026 20:49
@ilmalte ilmalte linked an issue Feb 22, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nakama is not supported WASM.

2 participants