Navigation

Serving the assets

The org.oblyx:oblyx-ktor artifact carries the compiled oblyx.js, oblyx.iife.js and oblyx.css as packaged resources. Call installOblyxAssets() once from your application module and Ktor serves them; nothing is copied into your project and no CDN is required.

fun Application.module() {
  installOblyxAssets()

  routing {
    // your routes
  }
}

By default this mounts the three files under /oblyx:/oblyx/oblyx.css, /oblyx/oblyx.js and /oblyx/oblyx.iife.js. Reference them from your page head like any other static asset:

head {
  link(rel = "stylesheet", href = "/oblyx/oblyx.css")
  script(type = "module", src = "/oblyx/oblyx.js") {}
}

Pass path to mount somewhere else, for example alongside other static content your app already serves under its own prefix:

installOblyxAssets(path = "/static/oblyx")

A missing asset fails at startup, not at request time

installOblyxAssets() checks the classpath for all three required files the moment it runs, before it registers a route for them. If any file is missing, the call throws an IllegalStateException immediately, with the missing filenames named in the message:

java.lang.IllegalStateException: oblyx-ktor: missing bundled asset(s) oblyx.js, oblyx.iife.js,
oblyx.css on the classpath under "oblyx-static/". The artifact was built or published without
packages/oblyx/dist, installOblyxAssets() refuses to register a route that would silently 404
for every consumer of this page.

This only happens if an oblyx-ktor artifact was somehow built or published without packages/oblyx/dist, which the project's own Gradle build guards against separately. The point of failing this loudly, rather than registering a route that would quietly 404 on first request once the app is already serving traffic, is the project's general error-handling stance: a broken asset must be visibly wrong at the moment it becomes knowable, not discovered later by a user staring at an unstyled page.

Pointing at a CDN instead

The bundled-assets route above is not the only option. Because oblyx.js/oblyx.css are the exact same build the artifact packages, you can instead link them from a CDN the same way a plain-HTML consumer would, and skip calling installOblyxAssets() entirely:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/oblyx/dist/oblyx.css" />
<script type="module" src="https://cdn.jsdelivr.net/npm/oblyx/dist/oblyx.js"></script>

Reach for the bundled route when you want one artifact, one version, and no dependency on a network request succeeding at runtime, which matters most for an intranet app or anything that has to keep working when a public CDN is unreachable. Reach for the CDN link when you would rather offload the bytes to an edge network you don't operate, and version skew between your Kotlin dependency and the served JS/CSS is not a concern for your deployment. The CDN path also depends on the oblyx npm package actually being published; see Install for its current status.