Understanding Iroh Presets: Empty, Minimal, N0, and N0DisableRelay Explained
Iroh provides four endpoint presets—Empty, Minimal, N0, and N0DisableRelay—that pre-configure cryptographic providers, address lookup services, and relay modes to match different networking requirements.
The n0-computer/iroh repository ships these iroh presets in iroh/src/endpoint/presets.rs to simplify Endpoint initialization. Each preset implements the endpoint::presets::Preset trait and applies specific configurations to the Endpoint builder, ranging from completely manual setup to production-ready defaults with relay connectivity.
Available Iroh Presets
Iroh defines four distinct presets that serve different configuration needs. All presets are located in iroh/src/endpoint/presets.rs and implement the Preset trait's apply method to modify the Endpoint builder state.
| Preset | Location | Configuration Level | Best For |
|---|---|---|---|
Empty |
Line 37 | No defaults | Full manual control |
Minimal |
Line 59 | Crypto provider only | Custom networking stacks |
N0 |
Line 112 | Production defaults | General application development |
N0DisableRelay |
Line 174 | N0 without relays | Direct peer-to-peer only |
Note: The Minimal, N0, and N0DisableRelay presets require a crypto-provider feature flag (tls-ring or tls-aws-lc-rs) to be available at compile time.
Detailed Preset Breakdown
Empty Preset
The Empty preset, defined at line 37 in presets.rs, performs no configuration on the builder. It leaves all mandatory fields unset, including the crypto provider, which is required for bind() to succeed.
Use Empty when you need absolute control over every Endpoint parameter. This preset requires you to manually set the crypto provider and all other options before calling bind().
Minimal Preset
The Minimal preset (line 59) configures only the mandatory crypto provider (rustls with ring or aws-lc-rs depending on enabled features). It provides the smallest viable configuration for a functional endpoint.
Choose Minimal when you want a working cryptographic foundation but need to customize address lookup mechanisms, relay modes, or transport configurations separately.
N0 Preset
The N0 preset (line 112) is the recommended default for most applications. It applies Minimal configurations plus:
- Default address lookup service: Registers
PkarrPublisherandDnsAddressLookuppointing toiroh.link - Default relay mode: Configures production relay servers (switched to staging in test environments)
Use N0 when you want out-of-the-box connectivity through Number 0's public relay infrastructure and DNS-based address resolution.
N0DisableRelay Preset
The N0DisableRelay preset (line 174) applies all N0 configurations but forces RelayMode::Disabled. This gives you the full N0 defaults—crypto provider and address lookup—without relay functionality.
Select this preset when you require direct peer-to-peer connections only, run your own relay infrastructure, or operate in environments where relay connections are restricted.
Practical Code Examples
Building with the N0 Preset
The standard approach for most applications uses the N0 preset for immediate connectivity:
use iroh::{Endpoint, endpoint::presets};
let ep = Endpoint::builder(presets::N0).bind().await?;
This provides the crypto provider, address lookup service, and production relay list in a single call.
Disabling Relays with N0DisableRelay
For direct connections without relay fallback:
use iroh::{Endpoint, endpoint::presets};
let ep = Endpoint::builder(presets::N0DisableRelay).bind().await?;
Customizing the Minimal Preset
Start with Minimal and add specific configurations:
use iroh::{Endpoint, endpoint::presets};
let mut builder = Endpoint::builder(presets::Minimal);
// Add custom address lookup, relay mode, or transport settings
let ep = builder.bind().await?;
Manual Configuration with Empty
For complete control, start from Empty and set all options manually:
use iroh::{Endpoint, endpoint::presets};
let mut builder = Endpoint::builder(presets::Empty);
builder = builder.crypto_provider(my_provider);
// Configure remaining options...
let ep = builder.bind().await?;
Key Implementation Files
Understanding the source structure helps when customizing presets:
iroh/src/endpoint/presets.rs: Defines thePresettrait and all four preset implementations with their specificapplymethods.iroh/src/endpoint.rs: Contains theEndpoint::builderentry point andBuildertype that accepts preset configurations.iroh/src/address_lookup.rs: ImplementsPkarrPublisherandDnsAddressLookupservices used by theN0presets.
Summary
N0provides production-ready defaults with crypto, DNS lookup, and relays—ideal for most applications.N0DisableRelayoffers the same configuration without relay functionality for direct peer-to-peer scenarios.Minimalsupplies only the crypto provider, serving as a foundation for custom networking stacks.Emptygives you complete manual control but requires setting all mandatory fields including the crypto provider.- All presets except
Emptyrequiretls-ringortls-aws-lc-rsfeature flags to compile.
Frequently Asked Questions
What is the difference between Minimal and N0 presets?
The Minimal preset configures only the cryptographic provider, leaving address lookup and relay mode unset. The N0 preset extends Minimal by adding the default DNS-based address lookup service (PkarrPublisher + DnsAddressLookup) and configuring production relay servers. Use Minimal when building custom networking configurations and N0 for standard production deployments.
When should I use the Empty preset instead of Minimal?
Use Empty when you need to configure the cryptographic provider manually or want to ensure no default settings are applied. Unlike Minimal, which automatically selects ring or aws-lc-rs based on feature flags, Empty leaves the builder in a blank state. This is useful for testing experimental crypto providers or when you need explicit control over every configuration parameter.
How do I disable relays while keeping other N0 defaults?
Use the N0DisableRelay preset, which applies all N0 configurations—including the crypto provider and address lookup—but sets RelayMode::Disabled. This is preferable to manually configuring N0 and then overriding the relay mode, as it ensures consistency with the preset's intended behavior.
Are iroh presets available without crypto provider features?
No. The Minimal, N0, and N0DisableRelay presets are conditionally compiled and only available when you enable either the tls-ring or tls-aws-lc-rs feature flags. The Empty preset is always available since it performs no configuration and has no crypto provider dependencies.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →