Guides
Load a dev server or bundled assets
Point your app at a dev server during development and at its built frontend in release builds.
Your app loads its first page from a URL or from a directory. See app:// and your frontend for how each is served.
Load a dev server
Point the app at the dev server with App::url:
use kurogane::App;
fn main() {
App::url("http://localhost:5173").run_or_exit();
}
It works with Vite, React, Vue, Svelte and any HTTP server. Start the dev server before the app. kurogane dev doesn’t start it for you.
Changes to the frontend reload in the window as they do in a browser.
Load bundled assets
Load a built frontend from a directory with App::new:
use kurogane::App;
fn main() {
App::new("content").run_or_exit();
}
The directory needs an index.html. A bundle carries your built frontend in content. A relative directory resolves inside the bundle wherever the app was started from.
Switch between them
Pick the source per build profile. The starters do this:
use kurogane::App;
fn main() {
#[cfg(debug_assertions)]
App::url("http://localhost:5173").run_or_exit();
#[cfg(not(debug_assertions))]
App::new("content").run_or_exit();
}
Any condition works. An environment variable, a command-line flag or a Cargo feature can choose the source just as well:
use kurogane::App;
fn main() {
let app = match std::env::var("APP_DEV_URL") {
Ok(url) => App::url(url),
Err(_) => App::new("content"),
};
app.run_or_exit();
}
Use another dev server port
The URL in src/main.rs and the dev server’s port must match. Change both together. With Vite set the port in frontend/vite.config.ts:
import { defineConfig } from "vite";
export default defineConfig({
server: { port: 3000, strictPort: true },
});
Then point the app at it:
App::url("http://localhost:3000")
strictPort makes Vite fail instead of moving to another port when this one is taken. Your app would otherwise load nothing.
Serve a directory you build yourself
kurogane bundle copies frontend-dist from kurogane.toml into the bundle’s content. Point frontend-dist at your build output and frontend-build at the command that makes it:
[app]
frontend-dist = "web/build"
frontend-build = "npm --prefix web run build"
Leave frontend-build out when you build the frontend yourself before bundling.
Run without a frontend
An app needs no HTML frontend of its own. App::url can open any site. An app that serves its own pages can do so from its own scheme.