https://kotlinlang.org logo
#compose-web
Title
# compose-web
d

Dragos Rachieru

11/03/2023, 7:45 PM
Can I serve my compose application using ktor? I want to create a server that hosts a rest API for all platforms and also the web version Right now I only succeeded in running the compose application as a kotlin/js application
h

hfhbd

11/03/2023, 7:47 PM
Yes. The resulting JS files are plain normal static JS files you can serve like any other static file with Ktor (or any other platform like GitHub pages, etc.)
d

Dragos Rachieru

11/03/2023, 7:49 PM
Is Github pages free?
I use compose web using canvas tho
h

hfhbd

11/03/2023, 7:49 PM
Yes, if your pages will be public accessible.
d

Dragos Rachieru

11/03/2023, 7:50 PM
Do I have to use browser instead of nodejs?
I still don't understand the difference between them
p

Pablichjenkov

11/03/2023, 8:12 PM
To deploy a static JS webpage you don't need nodejs, just research how to serve files with ktor and deploy ktor in any cloud hosting alternative. I use Google AppEngine but there is many. If no need ktor, just a JS webpage you can use firebase hosting, is free, however a custom domain and features like that you have to pay.
d

David Herman

11/03/2023, 8:20 PM
Creating a ktor server that serves static files is easy! Check out: https://ktor.io/docs/serving-static-content.html If you're using GHP however, all you need to do is check in the html / js files to the right place and it will serve them for you.
d

Dragos Rachieru

11/06/2023, 2:41 PM
Where does gradle generate the static files for ktor?
d

David Herman

11/06/2023, 5:49 PM
My recommendation to figure out what Gradle is doing is by going into your project, running
./gradlew clean
, and then running
./gradlew build
. Then, search your
build/
folder for
*.js
files.
9 Views