Registry / communication / magicbell

magicbell

JSON →
library1.1.1jsnpmunverified

The `magicbell` npm package is a deprecated JavaScript/TypeScript API wrapper designed for interacting with the MagicBell notification service. Originally, it provided client classes like `ProjectClient` and `UserClient` to facilitate sending and managing notifications. As of version 4.5.1, this package is no longer maintained and advises users to migrate to the `magicbell-js` package. The `magicbell-js` package, currently at version 1.6.0, serves as the modern, actively developed JavaScript/TypeScript SDK, offering a unified `Client` for both project and user authentication via tokens, and includes features for real-time notification listening. MagicBell provides a multi-channel push notification service, including in-app, email, mobile push, web push, Slack, and SMS, through a single API, handling preferences and delivery tracking.

npm install magicbell
INSTALL
IMPORT
SIG · MAGICBELL
M
magicbell
communicationjavascriptv1.1.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ProjectClient
import { Client } from 'magicbell-js/project-client';
import { ProjectClient } from 'magicbell/project-client';
The `magicbell` package is deprecated. `ProjectClient` is replaced by `Client` from `magicbell-js/project-client` and requires a `token` instead of `apiKey`/`apiSecret`.
UserClient
import { Client } from 'magicbell-js/user-client';
import { UserClient } from 'magicbell/user-client';
The `magicbell` package is deprecated. `UserClient` is replaced by `Client` from `magicbell-js/user-client` and requires a user JWT `token` for authentication.
Realtime
import { Realtime } from 'magicbell-js/realtime';
import { Socket } from 'magicbell-js/socket';
For real-time notification listening, use the `Realtime` class from `magicbell-js/realtime`. In `magicbell-js` v1.2.0, the `Socket` class was renamed to `Realtime`.

This quickstart demonstrates how to use the `magicbell-js` package (the recommended replacement for `magicbell`) to send a broadcast notification and listen for real-time user notifications.

import { Client } from 'magicbell-js/project-client'; import { Realtime } from 'magicbell-js/realtime'; const MAGICBELL_PROJECT_TOKEN = process.env.MAGICBELL_PROJECT_TOKEN ?? ''; // Replace with your MagicBell Project Token const MAGICBELL_USER_JWT = process.env.MAGICBELL_USER_JWT ?? ''; // Replace with a user-specific JWT async function sendAndListenNotifications() { if (!MAGICBELL_PROJECT_TOKEN || !MAGICBELL_USER_JWT) { console.error('MagicBell tokens are not set. Please provide them as environment variables.'); return; } // Initialize the Project Client with your project token const projectClient = new Client({ token: MAGICBELL_PROJECT_TOKEN, }); // Send a test broadcast notification try { const broadcastResult = await projectClient.broadcasts.create({ broadcast: { recipients: [{ external_id: 'your-user-external-id', email: 'user@example.com' }], title: 'New Feature Alert!', content: 'Check out our latest updates.', }, }); console.log('Broadcast sent:', broadcastResult); } catch (error) { console.error('Failed to send broadcast:', error); } // Initialize the Realtime client with a user JWT for listening const realtimeClient = new Realtime({ token: MAGICBELL_USER_JWT, }); // Listen for new notifications realtimeClient.onNotification((notification) => { console.log('Received new notification:', notification); }); console.log('Listening for real-time notifications...'); // In a real application, you would manage the connection lifecycle (e.g., connect, disconnect) // For this example, we'll keep it simple. // To stop listening, you would typically call realtimeClient.disconnect(); } sendAndListenNotifications().catch(console.error);
Debug
Known issues
breakingThe `magicbell` package is officially deprecated as of version 4.5.0. Users should migrate to the `magicbell-js` package for continued support and new features.
fix
Uninstall `magicbell` and install `magicbell-js`: `npm uninstall magicbell && npm install magicbell-js`. Update import paths and client instantiation logic.
affects: >=4.5.0
breakingClient classes `ProjectClient` and `UserClient` are removed. The `magicbell-js` package unifies these into a single `Client` class, differentiated by the `token` used for instantiation (project token vs. user JWT).
fix
Replace `new ProjectClient({ apiKey, apiSecret })` with `new Client({ token: projectToken })` and `new UserClient({ apiKey, apiSecret })` with `new Client({ token: userJwt })`. Ensure you generate and use the appropriate API tokens or user JWTs.
affects: >=4.5.0 (migration from magicbell to magicbell-js)
breakingAuthentication mechanisms have changed. The deprecated `magicbell` package used `apiKey` and `apiSecret`. The `magicbell-js` package now uses `token` (project token for ProjectClient or JWT for UserClient) for authentication.
fix
Update your authentication logic to generate and pass the appropriate project token or user JWT instead of API keys and secrets. Consult MagicBell's API documentation for token generation.
affects: >=4.5.0 (migration from magicbell to magicbell-js)
breakingThe real-time notification client class `Socket` in `magicbell-js` was renamed to `Realtime` for better discoverability.
fix
If using `magicbell-js` and encountering issues with `Socket`, update imports from `import { Socket } from 'magicbell-js/socket';` to `import { Realtime } from 'magicbell-js/realtime';`.
affects: magicbell-js@>=1.2.0
Errors
Common errors & fixes
TypeError: ProjectClient is not a constructor
Attempting to instantiate `ProjectClient` from the deprecated `magicbell` package after migrating to `magicbell-js` or incorrect import.
fix
Ensure you have updated your imports to `import { Client } from 'magicbell-js/project-client';` and are instantiating `new Client({ token: projectToken })`.
Error: Missing token
Instantiating the `Client` from `magicbell-js` without providing a required `token` in the constructor options.
fix
Provide a valid project token or user JWT: `new Client({ token: 'your-magicbell-token' })`. Tokens are mandatory for authentication.
Cannot find module 'magicbell/project-client' or 'magicbell/user-client'
Trying to import from the deprecated `magicbell` package after it has been uninstalled or dependencies updated to `magicbell-js`.
fix
Update your import statements to use `magicbell-js`, e.g., `import { Client } from 'magicbell-js/project-client';`.
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
18 hits · last 30 days
node
16
Amazon
1
OpenAI (training)
1
Resources