> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/xmtp/libxmtp/llms.txt
> Use this file to discover all available pages before exploring further.

# Development Setup

> Set up your development environment for LibXMTP

This guide will help you set up your development environment for contributing to LibXMTP.

## Prerequisites

Before you begin, ensure you have the following tools installed:

<Steps>
  <Step title="Install Rust">
    Install [Rustup](https://rustup.rs/), the Rust toolchain installer:

    ```bash theme={null}
    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
    ```
  </Step>

  <Step title="Install Docker">
    Install [Docker Desktop](https://www.docker.com/get-started/) to run the XMTP node and other services.

    After installation, make sure Docker Desktop is running.
  </Step>

  <Step title="Install Foundry">
    Install [Foundry](https://book.getfoundry.sh/getting-started/installation#using-foundryup) for Ethereum development tools:

    ```bash theme={null}
    curl -L https://foundry.paradigm.xyz | bash
    foundryup
    ```
  </Step>
</Steps>

## Environment Setup Options

You can set up your development environment using one of three methods:

### Method 1: Standard Setup

Start Docker Desktop, then install dependencies and start background services:

```bash theme={null}
dev/up
```

This command:

* Installs required dependencies
* Creates and runs an XMTP node in Docker Desktop
* Sets up other necessary services

### Method 2: Nix Setup (Recommended)

LibXMTP supports [Determinate Nix](https://docs.determinate.systems/) for reproducible development environments with pinned toolchains for Rust, Android, iOS, WebAssembly, and Node.js.

<Steps>
  <Step title="One-time setup">
    Install Determinate Nix, direnv, and binary caches:

    ```bash theme={null}
    ./dev/nix-up
    ```
  </Step>

  <Step title="Enter dev shell">
    ```bash theme={null}
    nix develop
    ```
  </Step>
</Steps>

<Note>
  To temporarily disable/enable direnv:

  ```bash theme={null}
  dev/direnv-down  # Disable direnv auto-activation
  dev/direnv-up    # Re-enable direnv
  ```
</Note>

For more details, see the [Nix setup documentation](https://github.com/xmtp/libxmtp/blob/main/docs/nix-setup.md).

### Method 3: Dev Containers

For containerized development using Visual Studio Code:

1. Install the Dev Containers extension
2. Open the command palette and select "Reopen in Container"
3. Select the Dockerfile as the target

Or build the container manually:

```bash theme={null}
docker build . -t libxmtp:1
```

## Managing Dependencies

When adding Rust dependencies, you must regenerate the `workspace-hack` crate:

```bash theme={null}
nix develop --command cargo hakari generate
```

<Info>
  Optionally verify correctness:

  ```bash theme={null}
  nix develop --command cargo hakari verify
  ```
</Info>

## Managing Backend Services

### Start Services

<CodeGroup>
  ```bash Standard theme={null}
  dev/up
  ```

  ```bash Backend with Validation Service theme={null}
  just backend up
  ```
</CodeGroup>

### Stop Services

<CodeGroup>
  ```bash Docker Only theme={null}
  dev/docker/down
  ```

  ```bash Backend Services theme={null}
  just backend down
  ```
</CodeGroup>

## Using Just Command Runner

LibXMTP uses [`just`](https://github.com/casey/just) as a command runner for common development tasks.

List all available commands:

```bash theme={null}
just
```

This will show all available recipes, including submodules for Android, iOS, Node.js, and WASM.

## Next Steps

Now that your environment is set up:

* Learn about [Testing](/development/testing)
* Explore [Benchmarks](/development/benchmarks)
* Read the [Contributing Guidelines](/development/contributing)
