Skip to main content
Deno 2 is finally here 🎉️
Learn more

Sockets

Sockets

A WebSocket library for Deno.


Although Sockets has working code, it is still very much under development and unstable. APIs will change without notice. Sorry for any inconvenience!

Table of Contents

Quickstart

Create your server.

// File: app.ts

import { Server } from "https://deno.land/x/sockets@v0.5.0/mod.ts";

// Create the server
const server = new Server();

// Run the server
server.run({
  hostname: "127.0.0.1",
  port: 1777,
});

console.log(
  `Server started on ws://${server.hostname}:${server.port}`,
);

Run your server.

$ deno run --allow-net app.ts
Server started on ws://127.0.0.1:1777

Connect to your server using wscat and send a ping packet.

$ npm install -g wscat
$ wscat -c ws://127.0.0.1:1777
> ping
< pong

Documentation

Features

  • JSON encoding
  • Zero dependencies

Contributing

Contributors are welcomed!

Please read through our contributing guidelines. Included are directions for opening issues, coding standards, and notes on development.

License

By contributing your code, you agree to license your contribution under the MIT License.