# Bundle a Bare app



A Bare program ships in one of two shapes depending on where it runs: as an **embeddable bundle** loaded by a [worklet](/bare/how-to/run-on-native/embed-bare-in-react-native) inside a native app, or as a **standalone executable** with no peer dependencies. This guide covers both, plus where native addons fit in.

## Embeddable bundle with bare-pack [#embeddable-bundle-with-bare-pack]

[`bare-pack`](/bare/reference/bare/modules) traverses your module graph and produces a single [`bare-bundle`](https://github.com/holepunchto/bare-bundle) with import specifiers pre-resolved and addons and assets embedded. Build one for the platform you're embedding into:

```sh skip="install-instruction"
npm i -g bare-pack
```

```console skip="native-build"
bare-pack --linked --host ios --out app.bundle.mjs app.js
```

Two flags matter for mobile: `--host <platform>[-<arch>[-<environment>]]` targets a specific system (pass it more than once for a combined bundle), and `--linked` makes addons resolve to `linked:` specifiers—required on iOS and Android, which link native code ahead of time rather than loading it from disk at runtime.

Load the result in a worklet by giving `start()` a filename with the `.bundle` extension:

```js skip="snippet-illustration"
import { Worklet } from 'react-native-bare-kit'
import bundle from './app.bundle.mjs'

const worklet = new Worklet()
worklet.start('/app.bundle', bundle)
```

## Standalone executable with bare-build [#standalone-executable-with-bare-build]

[`bare-build`](https://github.com/holepunchto/bare-build) packages your code as a native application bundle or a standalone executable for desktop and mobile. It ships portable runtimes for every supported system, so the output runs with no Node.js, Bare, or [Pear CLI](/pear/reference/pear/cli) installed:

```sh skip="install-instruction"
npm i -g bare-build
```

```console skip="native-build"
bare-build \
  --host darwin-arm64 --host darwin-x64 \
  --standalone \
  --identifier com.example.App \
  app.js
```

The output format depends on platform and mode—`--standalone` emits a self-extracting executable (Mach-O on macOS/iOS, ELF on Linux/Android, PE on Windows), while `--package` emits an installer (`.pkg`, `.AppImage`, `.msix`, …).

<Callout type="info">
  The portable runtimes run only Bare's I/O event loop, which suits headless CLIs and services. A native GUI app needs tight integration with the system event loop—pass a native runtime such as `--runtime bare-app-kit/runtime` (macOS) or `--runtime bare-ndk/runtime` (Android) instead.
</Callout>

This is the path the [`hello-pear-bare`](/p2p/getting-started/from-a-template/start-from-hello-pear-bare) template wires behind `npm run make`, which detects your host and builds the matching target.

## Native addons and prebuilt runtimes [#native-addons-and-prebuilt-runtimes]

Native addons are compiled separately with [`bare-make`](https://github.com/holepunchto/bare-make) (a CMake-based generator using Ninja + Clang); `bare-pack` then embeds the results. To build addons for every platform you ship to, the [Native-addon CI prebuilds](/bare/reference/native-addon-prebuilds) run `bare-make` across a CI matrix. If you only need the runtime itself, [`bare-runtime`](https://github.com/holepunchto/bare-runtime) provides prebuilt Bare binaries for macOS, iOS, Linux, Android, and Windows.

## See also [#see-also]

* [Embed Bare in a React Native app](/bare/how-to/run-on-native/embed-bare-in-react-native)—load the bundle in a worklet.
* [Start from the hello-pear-bare template](/p2p/getting-started/from-a-template/start-from-hello-pear-bare)—a terminal app that builds standalone with `bare-build`.
* [Bare modules](/bare/reference/bare/modules)—`bare-pack`, `bare-bundle`, `bare-make`, and the rest of the build tooling.
* [One core, many platforms](/bare/explanation/bare-on-native)—why the embeddable-bundle path exists.
