Files
nym/documentation/docs/pages/developers/mix-websocket/get-started.mdx
T
mfahampshire 7c890ea0c5 TS SDK docs (#6840)
* First sweep packages + some minor tweaking

* Second sweep

* Regenerate lockfile + package.json mods

* Regenerate lockfile again

* Fix CI

* Fix CI again

* All building properly

* unblock

* Tweak examples

* Comments + readme + fix rotten unit test

* First pass docs

* Big pass

* Massive pass on new docs

* Update integrations.md w mobile

* Partial overhaul review

* new playground + big pass

* new fix lychee err

* IPR notice tweak
2026-06-09 13:31:08 +00:00

53 lines
1.3 KiB
Plaintext

---
title: "Get started with mix-websocket"
description: "Install @nymproject/mix-websocket and open a WebSocket through the Nym mixnet."
schemaType: "TechArticle"
section: "Developers"
lastUpdated: "2026-06-05"
---
# Get started
## Installation
```bash
npm install @nymproject/mix-websocket
```
ESM only, with the worker and WASM inlined via [`mix-tunnel`](/developers/mix-tunnel/get-started#installation); no bundler config needed.
## Quick start
Echo against `wss://echo.websocket.org`, the same endpoint the smolmix dev tool uses:
```ts
import { setupMixTunnel, MixWebSocket } from '@nymproject/mix-websocket';
await setupMixTunnel();
const ws = new MixWebSocket('wss://echo.websocket.org');
ws.addEventListener('open', () => {
console.log('connected');
ws.send('hello mixnet');
});
ws.addEventListener('message', (e) => {
console.log('received:', e.data);
ws.close();
});
ws.addEventListener('close', () => console.log('closed'));
ws.addEventListener('error', (e) => console.error('error:', e));
```
Or `await` on the upgrade instead of subscribing to the `open` event:
```ts
const ws = new MixWebSocket('wss://echo.websocket.org');
await ws.opened();
ws.send('hello mixnet');
```
Open a `MixWebSocket` live in the [mixnet playground](/developers/playground), which echoes messages and runs an echo burst over the live mixnet.