# What Are iroh Presets and Which One Should You Use?

> Discover iroh presets for fast P2P networking. Learn what iroh presets are and choose the right one for your application. Get started with presets::N0 for production.

- Repository: [number zero/iroh](https://github.com/n0-computer/iroh)
- Tags: how-to-guide
- Published: 2026-07-14

---

**Iroh presets are reusable configuration bundles that implement the `Preset` trait to inject predefined defaults—including crypto providers, DNS services, and relay modes—into an `Endpoint` builder, with `presets::N0` being the recommended choice for most production applications.**

Iroh presets provide a streamlined way to configure endpoints in the n0-computer/iroh repository without manually specifying every builder option. These reusable bundles implement a common trait that applies sets of defaults for crypto providers, address lookup services, and relay modes. Understanding which iroh preset matches your networking requirements ensures you start with the appropriate security and connectivity baseline.

## Understanding the Preset Trait

According to the iroh source code, presets are defined in [`iroh/src/endpoint/presets.rs`](https://github.com/n0-computer/iroh/blob/main/iroh/src/endpoint/presets.rs) as types implementing the `Preset` trait. Each preset exposes a single method:

```rust
fn apply(self, builder: Builder) -> Builder

```

This method consumes the preset and returns a modified builder containing the preset's configuration. Presets gate behind the `with_crypto_provider` feature flag, requiring either `tls-ring` or `tls-aws-lc-rs` Cargo features to be enabled at compile time.

## Available Preset Options

The iroh library provides four distinct presets ranging from empty bundles to full production defaults.

### presets::Empty

The `Empty` preset returns the builder unchanged without setting any mandatory options. You must manually configure every aspect including the crypto provider, address lookup, and relay mode.

Use this when you need **full manual control** over the endpoint configuration.

### presets::Minimal

The `Minimal` preset configures only mandatory options, specifically selecting the crypto provider based on your compiled TLS implementation (`ring` or `aws-lc-rs`).

Use this when you want a **working minimal endpoint** without higher-level services like relay servers or DNS resolution.

### presets::N0

The `N0` preset (named after Number 0) provides production-ready defaults by:
- Calling `Minimal` to set the crypto provider
- Publishing and resolving PKARR records via the `iroh.link` DNS service
- Adding a fallback DNS resolver (outside browsers)
- Enabling the default relay mode

This is the **recommended preset for most applications** as it provides immediate peer discovery via public relay and DNS services.

### presets::N0DisableRelay

Identical to `N0` but forces `RelayMode::Disabled`, this preset configures all production defaults while disabling the relay infrastructure.

Use this when you operate in **peer-to-peer only environments** or utilize custom relay infrastructure rather than the public iroh relay network.

## Selecting the Right iroh Preset for Your Use Case

Choose your configuration bundle based on connectivity requirements:

- **General purpose networking**: Use `presets::N0` for immediate connectivity with public relay and DNS services.
- **Restricted environments**: Use `presets::N0DisableRelay` when relay servers are unavailable or undesired.
- **Embedded systems**: Use `presets::Minimal` when you need minimal code footprint and no external service dependencies.
- **Custom stacks**: Use `presets::Empty` when integrating proprietary crypto providers or custom discovery mechanisms.

## Implementation Examples

The following examples demonstrate how to apply each preset when building an endpoint. All examples assume the `with_crypto_provider` feature is enabled with either `tls-ring` or `tls-aws-lc-rs`.

Production-ready configuration with full defaults:

```rust
let endpoint = iroh::Endpoint::builder(presets::N0).bind().await?;

```

Peer-to-peer only without relay:

```rust
let endpoint = iroh::Endpoint::builder(presets::N0DisableRelay)
    .bind()
    .await?;

```

Minimal configuration:

```rust
let endpoint = iroh::Endpoint::builder(presets::Minimal).bind().await?;

```

Manual configuration with Empty preset:

```rust
let endpoint = iroh::Endpoint::builder(presets::Empty)
    .crypto_provider(Arc::new(rustls::crypto::ring::default_provider()))
    .bind()
    .await?;

```

## Summary

- Iroh presets are reusable configuration bundles defined in [`iroh/src/endpoint/presets.rs`](https://github.com/n0-computer/iroh/blob/main/iroh/src/endpoint/presets.rs) that implement the `Preset` trait's `apply` method.
- The `N0` preset provides production-ready defaults including crypto providers, DNS resolution, and relay connectivity.
- `N0DisableRelay` offers identical configuration but disables relay functionality for pure peer-to-peer networking.
- `Minimal` configures only mandatory crypto providers without external services.
- `Empty` provides no defaults, requiring manual configuration of all options.
- All presets require the `with_crypto_provider` feature and a TLS backend (`tls-ring` or `tls-aws-lc-rs`).

## Frequently Asked Questions

### What is the Preset trait in iroh?

The `Preset` trait is defined in the iroh source code as a configuration interface that exposes a single method `fn apply(self, builder: Builder) -> Builder`. This method allows preset types to inject predefined configurations into an `Endpoint` builder before binding, enabling reusable configuration patterns across different deployment scenarios.

### When should I use presets::Empty instead of presets::N0?

Use `presets::Empty` when your application requires full manual control over every configuration aspect, such as when integrating custom crypto providers not covered by the standard `ring` or `aws-lc-rs` implementations, or when implementing proprietary address lookup mechanisms. Unlike `presets::N0`, which automatically configures DNS and relay services, `Empty` leaves the builder unchanged and requires you to explicitly set all mandatory options including the crypto provider.

### How do I disable the relay server in iroh?

Apply the `presets::N0DisableRelay` preset when constructing your endpoint, which configures all production defaults from `presets::N0` but explicitly sets `RelayMode::Disabled`. This approach maintains the DNS resolution and crypto provider configuration while preventing the endpoint from utilizing the public relay infrastructure, forcing direct peer-to-peer connections only.

### What Cargo features are required to use iroh presets?

All presets require the `with_crypto_provider` feature flag to be enabled in your [`Cargo.toml`](https://github.com/n0-computer/iroh/blob/main/Cargo.toml), along with either `tls-ring` or `tls-aws-lc-rs` to specify the underlying TLS implementation. These features determine which crypto provider the `Minimal`, `N0`, and `N0DisableRelay` presets automatically configure in the endpoint builder.