# Getting Started

> Install and configure @anymux/union.

Source: https://anymux-docs.n.yatsyk.com/docs/union/getting-started

# Getting Started

## Installation

```bash
pnpm add @anymux/union
```

## Basic Usage

```ts
import { UnionFileSystem } from "@anymux/union";
import { MemoryFileSystem } from "@anymux/file-system/mem-fs";

const base = new MemoryFileSystem();
const overlay = new MemoryFileSystem();

const fs = new UnionFileSystem({ layers: [overlay, base] });

// Writes go to the first (highest priority) layer
await fs.writeFile("/hello.txt", new TextEncoder().encode("Hello!"));

// Reads check layers in order
const content = await fs.readFile("/hello.txt");
```
