
Security News
GitHub Actions Pricing Whiplash: Self-Hosted Actions Billing Change Postponed
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.
@rocket.chat/ddp-client
Advanced tools
Add `@rocket.chat/ddp-client` and `@rocket.chat/emitter` as dependencies of your project:
Add @rocket.chat/ddp-client and @rocket.chat/emitter as dependencies of your project:
yarn add @rocket.chat/ddp-client @rocket.chat/emitter
or:
npm install @rocket.chat/ddp-client @rocket.chat/emitter
@rocket.chat/emitter is listed as a peer dependency of ddp-client and is strictly necessary to make it work.
Tip: The whole project is typed using typescript. For that reason, references to interfaces and objects will be kept to a minimum.
This works out of the box for browsers. if you want to use it on NodeJS, you need to offer a
WebSocketimplementation and afetchimplementation.
First things first, let's import the SDK:
import { DDPSDK } from '@rocket.chat/ddp-client';
Now we need to create a new SDK instance. Fortunately, DDPSDK exposes a create function that initalizes everything for a quick setup:
const sdk = DDPSDK.create('http://localhost:3000');
We can then try to connect to the Rocket.Chat instance by doing:
await sdk.connection.connect();
You can check the connection status by referencing sdk.connection.status. If everything went right, it's value should be 'connected'.
If you're feeling fancy, you can create and connect in a single function call:
const sdk = DDPSDK.createAndConnect('http://localhost:3000');
Responsible for the connection to the server, status and connection states.
Responsible for the account management, login, logout, handle credentials, get user information, etc.
Responsible for the DDP communication, method calls, subscriptions, etc.
Responsible for the Reconnection control
Responsible for the REST API communication for more info see here
The just created sdk exposes an account interface (sdk.account), which should have everything you need. It has 3 methods:
sdk.account.loginWithPassword(username, hashedPassword)
username and password. The password must be hashed as sha-256 for it to worksdk.account.loginWithToken('userTokenGoesHere')
sdk.account.logout()
While the sdk instance is kept in memory, you can find some user information and credentials by referencing sdk.account.user
TIP: You might have to enable CORS in your Rocket.Chat instance for this to work.
The sdk exposes a rest interface, which accept all rest methods (get, post, put, delete).
Example call:
await sdk.rest.post('/v1/chat.sendMessage', { message: { rid: id, msg } });
WARNING: if you wrap a rest call in a try catch block, the error will be of type
Response. By callingerror.json()you get access to the server error response.
Rocket.Chat uses websockets as to provide realtime data. You can subscribe to publications in order to listen to data updates.
Below is an example of subscribing to the room-messages publication, which receives message updates from a room:
const messages = new Map([]);
const stream = sdk.stream('room-messages', roomId, (args) => {
setMessages((messages) => {
messages.set(args._id, args);
return new Map(messages);
});
});
// Stop the stream when you're done
stream.stop();
TIP: always unsubscribe from publications when you're done with them. This saves bandwidth and server resources
FAQs
Add `@rocket.chat/ddp-client` and `@rocket.chat/emitter` as dependencies of your project:
The npm package @rocket.chat/ddp-client receives a total of 22 weekly downloads. As such, @rocket.chat/ddp-client popularity was classified as not popular.
We found that @rocket.chat/ddp-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.