Can someone explain it to me. I don't get the conn...
# server
o
Can someone explain it to me. I don't get the connection of compose wasm to CMP. Compose wasm is to build the UI framework for web, but does it have a backend logic. If I create a project that uses, Android, Ios, WASM, and the app size is 50MB will the wasm also be 50mb. most of those code should go to the backend, right? how does wasm know and communicate with the backend( the logic of the code)
b
no, your clients dont typically have backend logic. you would break it down into ktor-client dependencies and ktor-server dependencies. server is typically jvm (and native). i would put ktor-server dependencies in a common-jvm (or main-backend for example) module. as for ktor-client, hope i'm not wrong i think its a complete multiplatform library and can sit all the way in your common code/module to be consumed by all targets. and you have to implement the client side and the backend site of your apis🙂 what you don't use gets removed by dead code removal. i.e. ktor-client code+dependencies will be removed from your backend-jvm target when you build it. ktor-server gets removed from your android target for example (assuming you put it in a common-jvm, android is also jvm). i think the platforms/targets have very different binaries and outputs. 50mb for one of them doesn't tell you anything about the others. ah only the code in common is "truly multiplatform". most of the code should go to common! in common-jvm, common-js, common-browser, ios-main, wasm-main, etc, i would do my best to write only "bridging abstractions" and i would try to write as much code as i can in common. it can hold all your data types, User, Unicorn, Book, etc, also expect FileManager, expect DocumentManager. and implement them with "actual" in downstream modules. its easier to rely on dead code removal than to be missing something in common. hope this is not confusing 🙂
o
if I want to build a web app and my html and css is not so good. But I understand you
✅ 2
b
there is almost no html and definitely no css involved if you are doing compose.
o
Yes, I am coming from CMP and server side. But not front-end
b
you will need a file like this to put in resources folder of compose web/html:
Copy code
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>My WASM App</title>
</head>
<body>
    <canvas id="ComposeTarget"></canvas> 
    
    <script src="composeApp.js"></script> 
</body>
</html>
👌 2