Getting Started

Introduction

Some of the key features of Nuxt WebSocket.

This module aims to simplify the integration of WebSocket in Nuxt applications.

Key Features

  • 🔄 Automatic reconnection
  • 📦 Built-in shared state management per-topic
  • 🤖 Build-in validation with Standard Schema
  • 🔐 Type-safe messages and topics
  • 📢 Hooking system to trigger messages globaly
  • ⛓️ Integrates easily with other Nuxt modules

Composables and Utilities

There are available a number of client composables and server utilities. Used in conjunction we can achieve a seamless integration, but they can also be used independently.

Client-Side

  • useWS: A WebSocket implementation with built-in shared state management, topic subscriptions, and type safety.
  • useWSState: A reactive state management based on Nuxt's useState to share state between components.

Server-Side

  • defineWSHandler: wraps Nitro's defineWebSocketHandler to provide additional configuration, hooks and automatic topic subscription.