Getting Started

Configuration

Configure the Nuxt WebSocket module.

There are only a few options to configure the Nuxt WebSocket module. They are all optional and you can set these options in your nuxt.config.ts file.

A complete example would look like this:

nuxt.config.ts
export default defineNuxtConfig({
  modules: ['nuxt-ws'],

  ws: {
    route: '/_ws',
    topics: {
      defaults: ['session'],
      internals: ['_internal', 'notifications'],
    },
  }
})

Options

route
string

Defines the default route for useWS to connect to the WebSocket server. - Default to undefined

topics.defaults
string[]

Defines the topics that are automatically subscribed to when a connection is established. - Default to []

topics.internals
string[]

Defines the topics that are considered internal and can only be listened to by the clients. Interactions with these are only possible via hooks - Default to []