> ## Documentation Index
> Fetch the complete documentation index at: https://abxbus.archivebox.io/llms.txt
> Use this file to discover all available pages before exploring further.

# NATSEventBridge

> Forward events over NATS subjects.

`NATSEventBridge` publishes events to a NATS subject and subscribes to the same subject for inbound forwarding.

## Go support

> [tab] Go
>
> `NATSEventBridge` is not implemented in `abxbus-go` yet. Use [JSONLEventBridge](https://abxbus.archivebox.io/integrations/bridge-jsonl.md) for the currently supported Go bridge.

> [tab] Rust
>
> ```rust theme={null}
> // Not implemented in the Rust crate yet.
> // Use typed event JSON serialization with an external transport for now.
> ```

## Optional dependencies

> [tab] Python
>
> Install the NATS extra (recommended):
>
> ```bash theme={null}
> pip install "abxbus[nats]"
> ```
>
> Equivalent direct dependency install:
>
> ```bash theme={null}
> pip install nats-py
> ```

> [tab] TypeScript
>
> Install the NATS client package:
>
> ```bash theme={null}
> npm install abxbus nats
> ```
>
> This bridge is Node.js-only.

> [tab] Go
>
> ```go theme={null}
> // NATSEventBridge is not implemented in abxbus-go yet.
> // Use JSONLEventBridge for the currently supported Go bridge.
> ```

> [tab] Rust
>
> ```rust theme={null}
> // Not implemented in the Rust crate yet.
> // Use typed events plus EventBus JSON serialization with an external transport for now.
> ```

## Constructor params

* `server`: NATS server URL (for example `nats://localhost:4222`)
* `subject`: subject name used for publish/subscribe
* `name`: optional bridge label

> [tab] Python
>
> ```python theme={null}
> from abxbus.bridges import NATSEventBridge
>
> bridge = NATSEventBridge(
>     'nats://localhost:4222',
>     'abxbus_events',
>     name='NatsBridge',
> )
> ```

> [tab] TypeScript
>
> ```ts theme={null}
> import { NATSEventBridge } from 'abxbus/bridges'
>
> const bridge = new NATSEventBridge(
>   'nats://localhost:4222',
>   'abxbus_events',
>   'NatsBridge'
> )
> ```

> [tab] Go
>
> ```go theme={null}
> // NATSEventBridge is not implemented in abxbus-go yet.
> // Use JSONLEventBridge for Go process-to-process bridge tests and deployments.
> ```

> [tab] Rust
>
> ```rust theme={null}
> // Not implemented in the Rust crate yet.
> // Use typed events plus EventBus JSON serialization with an external transport for now.
> ```

## Setup with a bus

> [tab] Python
>
> ```python theme={null}
> from abxbus import EventBus
> from abxbus.bridges import NATSEventBridge
>
> bus = EventBus('AppBus')
> bridge = NATSEventBridge('nats://localhost:4222', 'abxbus_events')
>
> bus.on('*', bridge.emit)
> bridge.on('*', bus.emit)
> ```

> [tab] TypeScript
>
> ```ts theme={null}
> import { EventBus } from 'abxbus'
> import { NATSEventBridge } from 'abxbus/bridges'
>
> const bus = new EventBus('AppBus')
> const bridge = new NATSEventBridge('nats://localhost:4222', 'abxbus_events')
>
> bus.on('*', bridge.emit)
> bridge.on('*', bus.emit)
> ```

> [tab] Go
>
> ```go theme={null}
> // NATSEventBridge is not implemented in abxbus-go yet.
> // Use JSONLEventBridge for Go process-to-process bridge tests and deployments.
> ```

> [tab] Rust
>
> ```rust theme={null}
> // Not implemented in the Rust crate yet.
> // Use typed events plus EventBus JSON serialization with an external transport for now.
> ```

## Behavior

* `emit(...)` publishes serialized event JSON bytes to the configured subject.
* `on(...)` registers inbound handlers and auto-starts subscription.
* Inbound messages are decoded, reset, and re-emitted on the internal bus.
* `close()` drains/closes NATS connections and stops the internal bus.
* Runtime requirements: Python needs `nats-py`, TypeScript needs `nats` and Node.js.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.