# js-libp2p-websockets
**Repository Path**: mirrors_libp2p/js-libp2p-websockets
## Basic Information
- **Project Name**: js-libp2p-websockets
- **Description**: WebSockets module that libp2p uses and that implements the interface-transport spec
- **Primary Language**: Unknown
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2020-08-09
- **Last Updated**: 2026-07-11
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# 📁 Archived - this module has been merged into [js-libp2p](https://github.com/libp2p/js-libp2p/tree/master/packages/transport-websockets)
# @libp2p/websockets
[](http://libp2p.io/)
[](https://discuss.libp2p.io)
[](https://codecov.io/gh/libp2p/js-libp2p-websockets)
[](https://github.com/libp2p/js-libp2p-websockets/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)
> JavaScript implementation of the WebSockets module that libp2p uses and that implements the interface-transport spec
## Table of contents
- [Install](#install)
- [Browser `
```
[](https://github.com/libp2p/interface-transport)
[](https://github.com/libp2p/interface-connection)
## Usage
```sh
> npm i @libp2p/websockets
```
### Constructor properties
```js
import { createLibp2pNode } from 'libp2p'
import { webSockets } from '@libp2p/webrtc-direct'
const node = await createLibp2p({
transports: [
webSockets()
]
//... other config
})
await node.start()
await node.dial('/ip4/127.0.0.1/tcp/9090/ws')
```
| Name | Type | Description | Default |
| -------- | -------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| upgrader | [`Upgrader`](https://github.com/libp2p/js-libp2p-interfaces/tree/master/packages/libp2p-interfaces/src/transport#upgrader) | connection upgrader object with `upgradeOutbound` and `upgradeInbound` | **REQUIRED** |
| filter | `(multiaddrs: Array) => Array` | override transport addresses filter | **Browser:** DNS+WSS multiaddrs / **Node.js:** DNS+\[WS, WSS] multiaddrs |
You can create your own address filters for this transports, or rely in the filters [provided](./src/filters.js).
The available filters are:
- `filters.all`
- Returns all TCP and DNS based addresses, both with `ws` or `wss`.
- `filters.dnsWss`
- Returns all DNS based addresses with `wss`.
- `filters.dnsWsOrWss`
- Returns all DNS based addresses, both with `ws` or `wss`.
## Libp2p Usage Example
```js
import { createLibp2pNode } from 'libp2p'
import { websockets } from '@libp2p/websockets'
import filters from '@libp2p/websockets/filters'
import { mplex } from '@libp2p/mplex'
import { noise } from '@libp2p/noise'
const transportKey = Websockets.prototype[Symbol.toStringTag]
const node = await Libp2p.create({
transport: [
websockets({
// connect to all sockets, even insecure ones
filters: filters.all
})
],
streamMuxers: [
mplex()
],
connectionEncryption: [
noise()
]
})
```
For more information see [libp2p/js-libp2p/doc/CONFIGURATION.md#customizing-transports](https://github.com/libp2p/js-libp2p/blob/master/doc/CONFIGURATION.md#customizing-transports).
## API
### Transport
[](https://github.com/libp2p/interface-transport)
### Connection
[](https://github.com/libp2p/interface-connection)
## API Docs
-
## License
Licensed under either of
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / )
- MIT ([LICENSE-MIT](LICENSE-MIT) / )
## Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.