Passing a channel name via constructor considered deprecated

Just a short post today about a part of our JS API we’d like you to consider deprecated. If you use it in your applications, please consider upgrading.

At the moment, you can currently do this:

var pusher = new Pusher("API_KEY", "CHANNEL_NAME");

In fact, this has always been the way we suggested getting set up in the documentation.

However, we’d like to encourage everyone to subscribe to channels separately, eg:

var pusher = new Pusher("API_KEY");
var channel = pusher.subscribe("CHANNEL_NAME");

Why did we originally have that API?

This is a legacy constructor from when we only supported a single channel per connection. It didn’t therefore make sense to have a separate subscribe method.

Why do we want you to change?

The old method doesn’t help you think about channels in the correct way, in particular it gives the impression that your app only has access to single global channel.

We want to encourage using multiple channel names, and making them part of your design decisions. As I mentioned previously, channels give you a lot of flexibility about what you can do, and it seems a shame to limit yourself by using this API.

It is not just a question of aesthetics though, some people are creating multiple connections in their javascript, when they really just need to subscribe to multiple channels. Doing the former increases your usage stats (and could lead to getting bumped up a pricing tier in future).


Have you built realtime apps with Pusher? If not, go on, create a free Pusher account and let us know what you think!

Ready to begin?

Start building your realtime experience today.

From in-app chat to realtime graphs and location tracking, you can rely on Pusher to scale to million of users and trillions of messages