Vonage Client SDK (Legacy Nexmo Client)
The `nexmo-client` package provides a JavaScript SDK for integrating programmable conversation features, including in-app messaging and voice, into web and Node.js applications. While the package name is `nexmo-client`, it is functionally the predecessor to the Vonage Client SDK. The current stable version, 9.6.1, was last published over a year ago (as of 2026), indicating it is in a deprecated or maintenance state, with active development having shifted to the official `@vonage/client-sdk` package. It offers capabilities like offline message synchronization, push notifications, rich text and image support for messaging, and advanced in-app voice features such as group calling and user controls. Its primary differentiators lie in enabling robust real-time communication within applications through the Vonage API platform.
Common errors
-
NexmoClient is not defined
cause The `NexmoClient` object was not correctly imported or made available in the current scope. This often happens in browser environments if the script tag isn't loaded, or in module environments if `require` or `import` fails.fixFor browser usage via script tag, ensure `nexmoClient.min.js` is loaded before your script. For module environments (Node.js, bundlers), use `import NexmoClient from 'nexmo-client';` or `const NexmoClient = require('nexmo-client');`. -
Failed to authenticate: Invalid JWT
cause The JSON Web Token (JWT) provided to `client.login()` is either malformed, expired, incorrectly signed, or does not contain the necessary claims (e.g., `acl`, `sub`).fixVerify that your backend service is generating a valid, unexpired JWT with the correct Vonage application ID, private key, and standard claims (e.g., `exp`, `jti`, `iat`, `application_id`, `sub`, `acl`). Use JWT debuggers to inspect the token payload. -
TypeError: NexmoClient is not a constructor
cause This typically occurs when the `require()` or `import` statement for `nexmo-client` does not yield the expected constructor function, often due to incorrect export handling or a mismatch between CommonJS and ESM imports.fixEnsure you are using the correct import syntax for your environment: `import NexmoClient from 'nexmo-client';` for ESM, or `const NexmoClient = require('nexmo-client');` for CommonJS. Avoid using named imports like `import { NexmoClient }` as the class is likely a default export.
Warnings
- breaking This `nexmo-client` package is deprecated. While it may still function, active development, new features, and ongoing maintenance have moved to the official `@vonage/client-sdk` package. Projects should migrate to the new package for continued support and access to the latest capabilities.
- gotcha The package name `nexmo-client` refers to an SDK now branded as 'Vonage Client SDK'. This can cause confusion when searching for documentation or examples, which are predominantly under the 'Vonage' brand. Ensure you are referencing documentation specific to the older `nexmo-client` or consider migrating.
- gotcha The SDK is licensed under a custom 'Vonage Client SDK License Agreement'. This is not a standard open-source license (e.g., MIT, Apache). Developers must review and comply with its specific terms and conditions, especially regarding distribution and modification.
- gotcha Authentication requires a JSON Web Token (JWT) signed by your backend. Exposing the private key or generating the JWT on the client-side is a severe security vulnerability. The client-side SDK only consumes the JWT.
Install
-
npm install nexmo-client -
yarn add nexmo-client -
pnpm add nexmo-client
Imports
- NexmoClient
import { NexmoClient } from 'nexmo-client';import NexmoClient from 'nexmo-client';
- NexmoClient (CommonJS)
const NexmoClient = require('nexmo-client'); - NexmoClient (Browser Global)
import NexmoClient from 'nexmo-client';
<!-- In HTML --> <script src="node_modules/nexmo-client/dist/nexmoClient.min.js"></script> // Then access `NexmoClient` directly
Quickstart
import NexmoClient from 'nexmo-client';
// Obtain a JWT from your backend for client authentication.
// In a production environment, this should never be hardcoded.
const JWT = process.env.VONAGE_CLIENT_SDK_JWT ?? 'YOUR_GENERATED_JWT_HERE';
async function initializeAndConnect() {
if (!JWT || JWT === 'YOUR_GENERATED_JWT_HERE') {
console.error('Please provide a valid JWT for authentication.');
return;
}
try {
const client = new NexmoClient({ debug: true });
client.on('connection:status', (status) => {
console.log(`Connection status changed: ${status}`);
if (status === 'disconnected') {
console.warn('Client disconnected. Check network or JWT validity.');
}
});
console.log('Attempting to log in with JWT...');
await client.login(JWT);
console.log('Successfully logged in to Vonage client SDK.');
// You can now access client features, e.g., get conversations, make calls.
const conversations = await client.getConversations();
console.log(`Found ${conversations.items.length} conversations.`);
} catch (error) {
console.error('Failed to initialize or login:', error.message, error);
}
}
initializeAndConnect();