# List Channels (/sdks/nodejs/how-to/management/list-channels)



## Overview [#overview]

Listing channels turns the broker into a discoverable inventory instead of a black box — instead of hardcoding channel names everywhere, you ask the server what actually exists right now. That's exactly what monitoring dashboards, cleanup scripts, and "did my deployment create the channels it should have" checks need. It's read-only and has no effect on message flow, so it's safe to run against production at any time.

Under the hood, `client.listChannels(type, search)` queries channels of one type — events, events-store, queues, commands, or queries — and an optional `search` string narrows results server-side to names starting with that prefix. Each result is a `ChannelInfo` exposing `name`, `type`, and `isActive`, reflecting whether a subscriber is currently connected.

**Gotchas:** the `search` filter is a prefix match, not a glob or regex — there's no wildcard syntax to anchor or exclude mid-string. `isActive` and any traffic stats are a snapshot at query time, so a channel can go idle a moment later. And a filter that matches nothing returns an empty array rather than throwing — automation scripts need to handle that case explicitly, not assume a non-empty result.

## Prerequisites [#prerequisites]

* KubeMQ server running on `localhost:50000`
* Node.js SDK installed (`npm install kubemq-js`)

## Code [#code]

```typescript title="list-channels.ts"
import { KubeMQClient } from 'kubemq-js';

async function main() {
  const client = await KubeMQClient.create({
    address: 'localhost:50000',
    clientId: 'js-management-list-channels-client',
  });

  try {
    const channels = await client.listChannels('queues', 'js-');
    console.log('Found', channels.length, 'queue channels matching "js-":');
    for (const ch of channels) {
      console.log(`  ${ch.name} — type: ${ch.type}, active: ${ch.isActive}`);
    }
  } finally {
    await client.close();
  }
}

main().catch(console.error);

```

## How It Works [#how-it-works]

* `client.listChannels(type, search)` returns an array of `ChannelInfo` objects; the first argument filters by channel type, the second is an optional name-prefix filter.
* The `search` parameter (`'js-'`) narrows results to channels whose names start with the prefix, reducing response payload on servers with many channels.
* Each `ChannelInfo` exposes `name`, `type`, and `isActive` — `isActive` is `true` if there is at least one active subscriber currently connected.
* An empty array is returned (not an error) when no channels match the filter; handle this case explicitly in automation scripts.

## Related [#related]

* [Node.js SDK Reference](/sdks/nodejs/reference)
* [Create Channel](/sdks/nodejs/how-to/management/create-channel)
* [Delete Channel](/sdks/nodejs/how-to/management/delete-channel)
