Skip to main content
It assumes you have deployed a single server before. If not, start with Deploy a Ktor server.

The project

settings.gradle.kts includes every module:
Each module only needs its usual Gradle setup. See Ktor servers, Web apps and Android apps for what the platform looks for.

Pick the primary server

Both :api and :admin are Ktor servers at the same depth. Without a setting, :admin would get the bare host, because it comes first in alphabetical order. Put :api there instead, in gradle.properties:
See The primary module.

Tell the web app where the API is

The web app is static: it learns the API URL when it is built. Set a build-only variable:
Then read it in composeApp/build.gradle.kts and turn it into a constant, for example with a small generated source:
The web app and the API are on different hosts, so the API needs Ktor’s CORS plugin to allow requests from the web app’s host.

Deploy

All four targets build in one deployment. If one fails, the others still go live and the deployment is PARTIAL.

Previews with their own API

When you link the repository, every pull request gets a preview with its own hosts. Point the preview web app at a preview-safe API by setting API_URL for the preview environment:

Add your domains

Then update API_URL to the new API domain and deploy again. See Custom domains.