---
title: "Packaging"
description: "Build a Slint desktop application into something your users install and start like any other application."
---
{/* cSpell: ignore myapp */}

import { Steps, Tabs, TabItem } from '@astrojs/starlight/components';
import LangRefLink from '@slint/common-files/src/components/LangRefLink.astro';

Packaging turns your application into files your users install and start without your development tools.
First set your application up for release, which depends on your programming language.
Then each platform page shows how to build and package it.

<Steps>

1. Set your application up for release:

   <Tabs syncKey="dev-language">
   <TabItem label="Rust" icon="seti:rust">

   A release build, with `cargo build --release`, makes an optimized executable.
   It contains your compiled `.slint` files and the images and fonts they use,
   so it depends only on system libraries.

   </TabItem>
   <TabItem label="C++" icon="seti:cpp">

   Build in release mode, with `CMAKE_BUILD_TYPE` set to `Release`.
   Embed the images and fonts of your `.slint` files into the executable,
   since by default the application loads them from their paths on the build machine:

   ```cmake
   set_property(TARGET my_application PROPERTY SLINT_EMBED_RESOURCES embed-files)
   ```

   See <LangRefLink lang="cpp" relpath="cmake-reference/resource-embedding/">Resource Embedding</LangRefLink> for the other options.
   The package also contains Slint's shared library.
   Each platform page shows where it goes so that the executable finds it.

   </TabItem>
   <TabItem label="NodeJS" icon="node">

   Node.js builds an executable from its own binary, as a [single executable application](https://nodejs.org/api/single-executable-applications.html).
   Your code goes into the executable, and Slint's native addon and your `.slint` files stay next to it.
   This requires Node.js 25.5 or newer, which is also the Node.js your application runs on.
   Build on each platform you target:
   npm installs native addons, including Slint's, for the platform it runs on.

   #### Bundle Your Code

   The executable runs one script built into it,
   and that script [loads only the built-in modules](https://nodejs.org/api/single-executable-applications.html#module-loading-in-the-injected-main-script) of Node.js.
   A bundler combines your code and its dependencies into that script.
   Use esbuild with the plugin of `slint-ui` so that `import { MainWindow } from "./ui/main.slint"` works in the bundle.

   Install [esbuild](https://esbuild.github.io/):

   ```sh
   npm install --save-dev esbuild
   ```

   Save this as `build.mjs`, with your entry point in `entryPoints`:

   ```js
   import * as esbuild from "esbuild";
   import { slint } from "slint-ui/esbuild";

   await esbuild.build({
       entryPoints: ["main.js"],
       bundle: true,
       platform: "node",
       format: "esm",
       outfile: "main.bundle.mjs",
       plugins: [slint()],
   });
   ```

   `node build.mjs` writes `main.bundle.mjs`, and copies Slint's native addon next to it.
   The plugin compiles `import { MainWindow } from "./ui/main.slint"` into a `loadFile()` call,
   so the `.slint` file loads at run time from the same path relative to the bundle.
   In every module of the bundle, `import.meta.url` is the location of the bundle,
   so build other paths, such as those for `loadFile()`, relative to it.

   #### Describe the Executable

   Describe the executable in `sea-config.json`.
   On Windows, name the output `myapp.exe`:

   ```json
   {
       "main": "main.bundle.mjs",
       "mainFormat": "module",
       "output": "myapp",
       "disableExperimentalSEAWarning": true
   }
   ```

   `node --build-sea sea-config.json` then builds the executable.
   It loads Slint's addon, `slint-ui.<platform>.node`, from the directory that contains the executable,
   and your `.slint` files and other assets from the paths the bundle uses.
   The platform pages show where these files go in the package.
   The native addons of other packages your application uses are loaded the same way, as their documentation describes.

   #### Without esbuild

   If your project already uses another bundler, keep it.
   It works if your code loads `.slint` files with `loadFile()`, and you copy Slint's addon next to the bundle.

   Some dependencies break when bundled,
   such as one that reads files next to its own source, or that picks the module to load at run time.
   For those, skip the bundler, at the cost of putting your code and `node_modules` next to the executable.
   The executable's built-in script can only load built-in modules,
   so build it from a `sea-main.cjs` that starts `start.cjs` from the disk.
   Leave out `mainFormat`, and put `start.cjs` next to the executable:

   ```js
   // sea-main.cjs, built into the executable
   require("node:module").createRequire(__filename)("./start.cjs");
   ```

   ```js
   // start.cjs
   import("slint-ui/register").then(() => import("./main.js"));
   ```

   </TabItem>
   </Tabs>

2. Build and package it for each platform:

   - [Windows](/guide/platforms/desktop/packaging/windows/)
   - [macOS](/guide/platforms/desktop/packaging/macos/)
   - [Linux](/guide/platforms/desktop/packaging/linux/)

</Steps>