---
title: "Embed fx"
description: "Choose whether to run fx through the native CLI, ACP server, or the libfx package."
canonical_url: https://fx.sh/docs/lib
markdown_url: https://fx.sh/docs/lib.md
---

# Embed fx

fx provides the agent runtime and tools for building coding-agent interfaces. You can run its native command-line interface (CLI) in a terminal, connect an editor or another application over Agent Client Protocol (ACP), or embed the agent in a JavaScript application with the `libfx` package.

## Choose an interface

| Goal | Interface | Runs as |
| --- | --- | --- |
| Use fx in a terminal | `fx` | Native process |
| Connect an editor or another ACP client | `fx acp` | Native process over stdio |
| Build a JavaScript interface around the agent | `createFxAgent()` | Native addon on Node, `fx-core.wasm` in the browser |
| Add the fx terminal to a JavaScript application | `createFxTerminal()` | `fx-term.wasm` |

## Run fx directly

Start the native CLI from the project you want to work on:

```bash
cd /absolute/path/to/project
fx
```

The current directory becomes the primary workspace. See the [CLI reference](https://fx.sh/docs/using-fx/cli.md) for commands and global options.

## Connect a native client over ACP

Run fx as an [Agent Client Protocol (ACP)](https://fx.sh/docs/using-fx/acp.md) server:

```bash
fx acp
```

The ACP client launches fx as a native process and communicates with it over standard input and output. Use this interface for editors and applications that support ACP.

## Load fx from JavaScript

The `libfx` package on npm carries both builds the JavaScript SDK can run: a native Node addon and the WebAssembly builds the browser needs. Which one loads depends on where your code runs, and on which of the two surfaces you ask for.

```bash
npm install libfx
```

The [Node SDK](https://fx.sh/docs/lib/node.md) covers the native addon, backend selection, and what the embedded agent can and cannot do. The [WebAssembly SDK](https://fx.sh/docs/lib/webassembly.md) covers the browser, where the [try page](/try) runs the terminal build of fx. For browser storage, authentication, command execution, and network requests, see [Browser integration](https://fx.sh/docs/lib/host-integration.md).

---

[Browse all fx documentation](https://fx.sh/llms.txt)
